command interpreter bug fixed
This commit is contained in:
parent
d3174f3574
commit
b39ce5e553
@ -213,8 +213,8 @@ minetest.register_craft({
|
||||
output = "signs_bot:box",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "group:wood", "default:steel_ingot"},
|
||||
{"basic_materials:gear_steel", "default:mese_crystal", "basic_materials:gear_steel"},
|
||||
{"default:tin_ingot", "basic_materials:silicon", "default:tin_ingot"}
|
||||
{"basic_materials:motor", "default:mese_crystal", "basic_materials:gear_steel"},
|
||||
{"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").."]"
|
||||
end
|
||||
|
||||
local commands = [[dig_sign 4
|
||||
local commands = [[dig_sign 6
|
||||
move 2
|
||||
place_sign_behind 4
|
||||
place_sign_behind 6
|
||||
]]
|
||||
|
||||
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)
|
||||
if line then
|
||||
local cmnd, param1, param2 = unpack(string.split(line, " "))
|
||||
if cmnd ~= "--" then -- No comment?
|
||||
sts,res = true, tCommands[cmnd].cmnd(base_pos, mem, param1, param2)
|
||||
--sts, res = pcall(tCommands[cmnd].cmnd(base_pos, mem, param1, param2))
|
||||
if cmnd ~= "--" and tCommands[cmnd] then -- Valid command?
|
||||
--sts,res = true, tCommands[cmnd].cmnd(base_pos, mem, param1, param2)
|
||||
sts, res = pcall(tCommands[cmnd].cmnd, base_pos, mem, param1, param2)
|
||||
if not sts then
|
||||
minetest.sound_play('signs_bot_error', {pos = base_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"))
|
||||
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)
|
||||
line = trim(line or "")
|
||||
local text = meta:get_string("signs_bot_cmnd").."\n"..line
|
||||
@ -88,7 +96,7 @@ local function append_line(pos, meta, line)
|
||||
end
|
||||
|
||||
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)
|
||||
local res,err_msg = signs_bot.check_commands(pos, fields.cmnd)
|
||||
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,
|
||||
is_ground_content = false,
|
||||
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(),
|
||||
})
|
||||
|
||||
|
@ -61,7 +61,7 @@ local function register_sign(def)
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
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(),
|
||||
})
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user