mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-26 09:03:46 +01:00
LBM wieder entfernt
This commit is contained in:
parent
38dafae5a4
commit
49f6c8c13a
@ -229,11 +229,13 @@ local function check_fuel(pos, meta)
|
||||
end
|
||||
|
||||
local function reset_robot(pos, meta)
|
||||
print("robot_pos", meta:get_string("robot_pos"))
|
||||
local robot_pos = minetest.string_to_pos(meta:get_string("robot_pos"))
|
||||
minetest.log("action", "[robby] reset_robot "..meta:get_string("robot_pos"))
|
||||
|
||||
if robot_pos then
|
||||
sl_robot.remove_robot(robot_pos)
|
||||
minetest.after(5, minetest.remove_node, robot_pos)
|
||||
end
|
||||
|
||||
local param2 = (minetest.get_node(pos).param2 + 1) % 4
|
||||
robot_pos = sl_robot.new_pos(pos, param2, 1)
|
||||
local pos_below = {x=robot_pos.x, y=robot_pos.y-1, z=robot_pos.z}
|
||||
|
@ -37,6 +37,7 @@ sl_robot.register_action("forward", {
|
||||
idx = idx + 1
|
||||
end
|
||||
meta:set_string("robot_pos", minetest.pos_to_string(new_pos))
|
||||
minetest.log("action", "[robby] forward "..meta:get_string("robot_pos"))
|
||||
else -- blocked
|
||||
-- because of unloaded areas and the LBM replace blocked robots
|
||||
--minetest.set_node(robot_pos, {name = "sl_robot:robot_dummy", param2 = robot_param2})
|
||||
@ -54,6 +55,7 @@ sl_robot.register_action("left", {
|
||||
local robot_param2 = meta:get_int("robot_param2")
|
||||
robot_param2 = sl_robot.turn_robot(robot_pos, robot_param2, "L")
|
||||
meta:set_int("robot_param2", robot_param2)
|
||||
minetest.log("action", "[robby] left "..meta:get_string("robot_pos"))
|
||||
coroutine.yield()
|
||||
end,
|
||||
help = "tbd"
|
||||
@ -66,6 +68,7 @@ sl_robot.register_action("right", {
|
||||
local robot_param2 = meta:get_int("robot_param2")
|
||||
robot_param2 = sl_robot.turn_robot(robot_pos, robot_param2, "R")
|
||||
meta:set_int("robot_param2", robot_param2)
|
||||
minetest.log("action", "[robby] right "..meta:get_string("robot_pos"))
|
||||
coroutine.yield()
|
||||
end,
|
||||
help = "tbd"
|
||||
@ -83,6 +86,7 @@ sl_robot.register_action("up", {
|
||||
coroutine.yield()
|
||||
end
|
||||
meta:set_string("robot_pos", minetest.pos_to_string(new_pos))
|
||||
minetest.log("action", "[robby] up "..meta:get_string("robot_pos"))
|
||||
coroutine.yield()
|
||||
end,
|
||||
help = "tbd"
|
||||
@ -93,12 +97,14 @@ sl_robot.register_action("down", {
|
||||
local meta = minetest.get_meta(self.meta.pos)
|
||||
local robot_pos = minetest.string_to_pos(meta:get_string("robot_pos"))
|
||||
local robot_param2 = meta:get_int("robot_param2")
|
||||
local new_pos
|
||||
while true do
|
||||
new_pos = sl_robot.robot_down(robot_pos, robot_param2)
|
||||
if new_pos then break end
|
||||
coroutine.yield()
|
||||
end
|
||||
meta:set_string("robot_pos", minetest.pos_to_string(new_pos))
|
||||
minetest.log("action", "[robby] down "..meta:get_string("robot_pos"))
|
||||
coroutine.yield()
|
||||
end,
|
||||
help = "tbd"
|
||||
|
@ -61,7 +61,7 @@ end
|
||||
|
||||
function sl_robot.remove_robot(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "sl_robot:robot" or node.name == "sl_robot:robot_dummy" then
|
||||
if node.name == "sl_robot:robot" then
|
||||
minetest.remove_node(pos)
|
||||
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
node = minetest.get_node(pos1)
|
||||
@ -144,7 +144,7 @@ function sl_robot.robot_up(pos, param2)
|
||||
minetest.swap_node(pos, {name="sl_robot:robot_foot"})
|
||||
end
|
||||
minetest.set_node(pos1, {name="sl_robot:robot", param2=param2})
|
||||
minetest.sound_play('sl_robot_step', {pos = new_pos})
|
||||
minetest.sound_play('sl_robot_step', {pos = pos1})
|
||||
return pos1
|
||||
end
|
||||
return nil
|
||||
@ -154,21 +154,18 @@ end
|
||||
-- [R]
|
||||
-- 1
|
||||
-- 2
|
||||
-- 3
|
||||
function sl_robot.robot_down(pos, param2)
|
||||
if dir == "U" then dir = 1 else dir = -1 end
|
||||
local new_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
local new_pos_node = minetest.get_node(new_pos)
|
||||
local objects = minetest.get_objects_inside_radius(new_pos, 1)
|
||||
if #objects == 0 and new_pos_node.name == "sl_robot:robot_foot" or
|
||||
new_pos_node.name == "sl_robot:robot_leg" then
|
||||
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
local pos2 = {x=pos.x, y=pos.y-2, z=pos.z}
|
||||
local pos3 = {x=pos.x, y=pos.y-3, z=pos.z}
|
||||
local node1 = minetest.get_node_or_nil(pos1) or read_node_with_vm(pos1)
|
||||
if node1.name == "air" and check_pos(pos2, pos3) then
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(new_pos, {name="sl_robot:robot", param2=param2})
|
||||
minetest.sound_play('sl_robot_step', {pos = new_pos})
|
||||
return new_pos
|
||||
minetest.set_node(pos2, {name="sl_robot:robot", param2=param2})
|
||||
minetest.sound_play('sl_robot_step', {pos = pos2})
|
||||
return pos2
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
minetest.sound_play('sl_robot_go_away', {pos = pos, gain = 0.6})
|
||||
pos.y = pos.y-1
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -201,36 +198,36 @@ minetest.register_node("sl_robot:robot", {
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- dummy robots are used as marker for stucked robots in unloaded areas
|
||||
minetest.register_node("sl_robot:robot_dummy", {
|
||||
description = "SaferLua Robot",
|
||||
-- up, down, right, left, back, front
|
||||
tiles = {
|
||||
"sl_robot_robot_top.png^[opacity:127",
|
||||
"sl_robot_robot_bottom.png^[opacity:127",
|
||||
"sl_robot_robot_right.png^[opacity:127",
|
||||
"sl_robot_robot_left.png^[opacity:127",
|
||||
"sl_robot_robot_front.png^[opacity:127",
|
||||
"sl_robot_robot_back.png^[opacity:127",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
use_texture_alpha = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -5/16, 3/16, -5/16, 5/16, 8/16, 5/16},
|
||||
{ -3/16, 2/16, -3/16, 3/16, 3/16, 3/16},
|
||||
{ -6/16, -7/16, -6/16, 6/16, 2/16, 6/16},
|
||||
{ -6/16, -8/16, -3/16, 6/16, -7/16, 3/16},
|
||||
},
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
drop = "",
|
||||
groups = {cracky = 3},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
---- dummy robots are used as marker for stucked robots in unloaded areas
|
||||
--minetest.register_node("sl_robot:robot_dummy", {
|
||||
-- description = "SaferLua Robot",
|
||||
-- -- up, down, right, left, back, front
|
||||
-- tiles = {
|
||||
-- "sl_robot_robot_top.png^[opacity:127",
|
||||
-- "sl_robot_robot_bottom.png^[opacity:127",
|
||||
-- "sl_robot_robot_right.png^[opacity:127",
|
||||
-- "sl_robot_robot_left.png^[opacity:127",
|
||||
-- "sl_robot_robot_front.png^[opacity:127",
|
||||
-- "sl_robot_robot_back.png^[opacity:127",
|
||||
-- },
|
||||
-- drawtype = "nodebox",
|
||||
-- use_texture_alpha = true,
|
||||
-- node_box = {
|
||||
-- type = "fixed",
|
||||
-- fixed = {
|
||||
-- { -5/16, 3/16, -5/16, 5/16, 8/16, 5/16},
|
||||
-- { -3/16, 2/16, -3/16, 3/16, 3/16, 3/16},
|
||||
-- { -6/16, -7/16, -6/16, 6/16, 2/16, 6/16},
|
||||
-- { -6/16, -8/16, -3/16, 6/16, -7/16, 3/16},
|
||||
-- },
|
||||
-- },
|
||||
-- paramtype2 = "facedir",
|
||||
-- is_ground_content = false,
|
||||
-- walkable = false,
|
||||
-- drop = "",
|
||||
-- groups = {cracky = 3},
|
||||
-- sounds = default.node_sound_metal_defaults(),
|
||||
--})
|
||||
|
||||
minetest.register_node("sl_robot:robot_leg", {
|
||||
description = "SaferLua Robot",
|
||||
@ -266,17 +263,17 @@ minetest.register_node("sl_robot:robot_foot", {
|
||||
})
|
||||
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "[sl_robot] Remove Robots",
|
||||
name = "sl_robot:update",
|
||||
nodenames = {"sl_robot:robot", "sl_robot:robot_leg", "sl_robot:robot_foot"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
if node.name == "sl_robot:robot" then
|
||||
minetest.swap_node(pos, {name="sl_robot:robot_dummy", param2 = node.param2})
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
--minetest.register_lbm({
|
||||
-- label = "[sl_robot] Remove Robots",
|
||||
-- name = "sl_robot:update",
|
||||
-- nodenames = {"sl_robot:robot", "sl_robot:robot_leg", "sl_robot:robot_foot"},
|
||||
-- run_at_every_load = true,
|
||||
-- action = function(pos, node)
|
||||
-- if node.name == "sl_robot:robot" then
|
||||
-- minetest.swap_node(pos, {name="sl_robot:robot_dummy", param2 = node.param2})
|
||||
-- else
|
||||
-- minetest.remove_node(pos)
|
||||
-- end
|
||||
-- end
|
||||
--})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user