command interpreter bug fixed
This commit is contained in:
parent
d3174f3574
commit
b39ce5e553
@ -213,8 +213,8 @@ minetest.register_craft({
|
|||||||
output = "signs_bot:box",
|
output = "signs_bot:box",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "group:wood", "default:steel_ingot"},
|
{"default:steel_ingot", "group:wood", "default:steel_ingot"},
|
||||||
{"basic_materials:gear_steel", "default:mese_crystal", "basic_materials:gear_steel"},
|
{"basic_materials:motor", "default:mese_crystal", "basic_materials:gear_steel"},
|
||||||
{"default:tin_ingot", "basic_materials:silicon", "default:tin_ingot"}
|
{"default:tin_ingot", "", "default:tin_ingot"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ local function formspec(cmnd)
|
|||||||
"button_exit[2.5,5.5;2,1;exit;"..I("Exit").."]"
|
"button_exit[2.5,5.5;2,1;exit;"..I("Exit").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local commands = [[dig_sign 4
|
local commands = [[dig_sign 6
|
||||||
move 2
|
move 2
|
||||||
place_sign_behind 4
|
place_sign_behind 6
|
||||||
]]
|
]]
|
||||||
|
|
||||||
minetest.register_node("signs_bot:bot_flap", {
|
minetest.register_node("signs_bot:bot_flap", {
|
||||||
|
@ -567,9 +567,9 @@ function signs_bot.run_next_command(base_pos, mem)
|
|||||||
local line = table.remove(mem.lCmnd, 1)
|
local line = table.remove(mem.lCmnd, 1)
|
||||||
if line then
|
if line then
|
||||||
local cmnd, param1, param2 = unpack(string.split(line, " "))
|
local cmnd, param1, param2 = unpack(string.split(line, " "))
|
||||||
if cmnd ~= "--" then -- No comment?
|
if cmnd ~= "--" and tCommands[cmnd] then -- Valid command?
|
||||||
sts,res = true, tCommands[cmnd].cmnd(base_pos, mem, param1, param2)
|
--sts,res = true, tCommands[cmnd].cmnd(base_pos, mem, param1, param2)
|
||||||
--sts, res = pcall(tCommands[cmnd].cmnd(base_pos, mem, param1, param2))
|
sts, res = pcall(tCommands[cmnd].cmnd, base_pos, mem, param1, param2)
|
||||||
if not sts then
|
if not sts then
|
||||||
minetest.sound_play('signs_bot_error', {pos = base_pos})
|
minetest.sound_play('signs_bot_error', {pos = base_pos})
|
||||||
minetest.sound_play('signs_bot_error', {pos = mem.robot_pos})
|
minetest.sound_play('signs_bot_error', {pos = mem.robot_pos})
|
||||||
|
@ -78,6 +78,14 @@ local function trim(s)
|
|||||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function trim_text(text)
|
||||||
|
local tbl = {}
|
||||||
|
for idx,line in ipairs(string.split(text, "\n", true)) do
|
||||||
|
tbl[#tbl+1] = trim(line)
|
||||||
|
end
|
||||||
|
return table.concat(tbl, "\n")
|
||||||
|
end
|
||||||
|
|
||||||
local function append_line(pos, meta, line)
|
local function append_line(pos, meta, line)
|
||||||
line = trim(line or "")
|
line = trim(line or "")
|
||||||
local text = meta:get_string("signs_bot_cmnd").."\n"..line
|
local text = meta:get_string("signs_bot_cmnd").."\n"..line
|
||||||
@ -88,7 +96,7 @@ local function append_line(pos, meta, line)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function check_and_store(pos, meta, fields)
|
local function check_and_store(pos, meta, fields)
|
||||||
meta:set_string("signs_bot_cmnd", fields.cmnd)
|
meta:set_string("signs_bot_cmnd", trim_text(fields.cmnd))
|
||||||
meta:set_string("sign_name", fields.name)
|
meta:set_string("sign_name", fields.name)
|
||||||
local res,err_msg = signs_bot.check_commands(pos, fields.cmnd)
|
local res,err_msg = signs_bot.check_commands(pos, fields.cmnd)
|
||||||
meta:set_int("err_code", res and 0 or 1) -- zero means OK
|
meta:set_int("err_code", res and 0 or 1) -- zero means OK
|
||||||
@ -172,7 +180,7 @@ minetest.register_node("signs_bot:sign_cmnd", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
drop = "",
|
drop = "",
|
||||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, sign_bot_sign = 1},
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, sign_bot_sign = 1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ local function register_sign(def)
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, sign_bot_sign = 1},
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, sign_bot_sign = 1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user