Switch translation from intllib to minetest.translator
This commit is contained in:
parent
249340d5fd
commit
c5be40a10f
@ -169,4 +169,5 @@ optional: farming redo, node_io, doc, techage, minecart
|
||||
- 2020-06-21 v1.03 * Interpreter bugfixes, node and crop sensors changed
|
||||
- 2020-10-01 v1.04 * Many improvements and bugfixes (Thanks to Thomas-S)
|
||||
- 2021-01-30 v1.05 * Many improvements and bugfixes
|
||||
- 2021-03-14 v1.06 * Switch translation from intllib to minetest.translator
|
||||
|
||||
|
67
basis.lua
67
basis.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -117,24 +114,24 @@ local function status(mem)
|
||||
return mem.error
|
||||
end
|
||||
if mem.running then
|
||||
return I("running")
|
||||
return S("running")
|
||||
end
|
||||
if mem.charging then
|
||||
return I("charging")
|
||||
return S("charging")
|
||||
end
|
||||
return I("stopped")
|
||||
return S("stopped")
|
||||
end
|
||||
|
||||
local function formspec(pos, mem)
|
||||
mem.running = mem.running or false
|
||||
local cmnd = mem.running and "stop;"..I("Off") or "start;"..I("On")
|
||||
local cmnd = mem.running and "stop;"..S("Off") or "start;"..S("On")
|
||||
local bot = not mem.running and "image[0.6,0;1,1;signs_bot_bot_inv.png]" or ""
|
||||
local current_capa = mem.capa or (signs_bot.MAX_CAPA * 0.9)
|
||||
return "size[9,8.2]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[2.1,0;"..I("Signs").."]label[5.3,0;"..I("Other items").."]"..
|
||||
"label[2.1,0;"..S("Signs").."]label[5.3,0;"..S("Other items").."]"..
|
||||
"image[0.6,0;1,1;signs_bot_form_mask.png]"..
|
||||
bot..
|
||||
preassigned_slots(pos)..
|
||||
@ -145,7 +142,7 @@ local function formspec(pos, mem)
|
||||
"label[5.3,0.5;1]label[6.3,0.5;2]label[7.3,0.5;3]label[8.3,0.5;4]"..
|
||||
"list[context;main;5,1;4,2;]"..
|
||||
"label[5.3,3;5]label[6.3,3;6]label[7.3,3;7]label[8.3,3;8]"..
|
||||
"button[0.2,1;1.5,1;config;"..I("Config").."]"..
|
||||
"button[0.2,1;1.5,1;config;"..S("Config").."]"..
|
||||
"button[0.2,2;1.5,1;"..cmnd.."]"..
|
||||
"label[1,3.6;"..status(mem).."]"..
|
||||
"list[current_player;main;0.5,4.4;8,4;]"..
|
||||
@ -153,16 +150,16 @@ local function formspec(pos, mem)
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
local function formspec_cfg(pos, mem)
|
||||
local function formspec_cfg()
|
||||
return "size[9,8.2]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[5.3,0;"..I("Preassign slots items").."]"..
|
||||
"label[5.3,0;"..S("Preassign slots items").."]"..
|
||||
"label[5.3,0.5;1]label[6.3,0.5;2]label[7.3,0.5;3]label[8.3,0.5;4]"..
|
||||
"list[context;filter;5,1;4,2;]"..
|
||||
"label[5.3,3;5]label[6.3,3;6]label[7.3,3;7]label[8.3,3;8]"..
|
||||
"button[0.2,1;1.5,1;back;"..I("Back").."]"..
|
||||
"button[0.2,1;1.5,1;back;"..S("Back").."]"..
|
||||
"list[current_player;main;0.5,4.4;8,4;]"..
|
||||
"listring[context;filter]"..
|
||||
"listring[current_player;main]"
|
||||
@ -182,7 +179,7 @@ local function set_capa(pos, oldnode, digger, capa)
|
||||
capa = techage.power.percent(signs_bot.MAX_CAPA, capa)
|
||||
capa = (math.floor((capa or 0) / 5)) * 5
|
||||
meta:set_int("capa", capa)
|
||||
local text = I("Robot Box ").." ("..capa.." %)"
|
||||
local text = S("Robot Box").." ("..capa.." %)"
|
||||
meta:set_string("description", text)
|
||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||
local left_over = inv:add_item("main", node)
|
||||
@ -195,7 +192,7 @@ function signs_bot.infotext(pos, state)
|
||||
local meta = M(pos)
|
||||
local number = meta:get_string("number")
|
||||
state = state or "<unknown>"
|
||||
meta:set_string("infotext", I("Robot Box ")..number..": "..state)
|
||||
meta:set_string("infotext", S("Robot Box").." "..number..": "..state)
|
||||
end
|
||||
|
||||
local function reset_robot(pos, mem)
|
||||
@ -221,7 +218,7 @@ function signs_bot.start_robot(base_pos)
|
||||
mem.capa = nil
|
||||
end
|
||||
meta:set_string("formspec", formspec(base_pos, mem))
|
||||
signs_bot.infotext(base_pos, I("running"))
|
||||
signs_bot.infotext(base_pos, S("running"))
|
||||
reset_robot(base_pos, mem)
|
||||
minetest.get_node_timer(base_pos):start(CYCLE_TIME)
|
||||
return true
|
||||
@ -240,9 +237,9 @@ function signs_bot.stop_robot(base_pos, mem)
|
||||
mem.charging = false
|
||||
end
|
||||
if mem.power_available then
|
||||
signs_bot.infotext(base_pos, I("charging"))
|
||||
signs_bot.infotext(base_pos, S("charging"))
|
||||
else
|
||||
signs_bot.infotext(base_pos, I("stopped"))
|
||||
signs_bot.infotext(base_pos, S("stopped"))
|
||||
end
|
||||
meta:set_string("formspec", formspec(base_pos, mem))
|
||||
signs_bot.remove_robot(mem)
|
||||
@ -301,7 +298,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
if fields.update then
|
||||
meta:set_string("formspec", formspec(pos, mem))
|
||||
elseif fields.config then
|
||||
meta:set_string("formspec", formspec_cfg(pos, mem))
|
||||
meta:set_string("formspec", formspec_cfg())
|
||||
elseif fields.back then
|
||||
meta:set_string("formspec", formspec(pos, mem))
|
||||
elseif fields.start then
|
||||
@ -399,7 +396,7 @@ local function on_nopower(pos)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:box", {
|
||||
description = I("Signs Bot Box"),
|
||||
description = S("Signs Bot Box"),
|
||||
stack_max = 1,
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
@ -433,7 +430,7 @@ minetest.register_node("signs_bot:box", {
|
||||
meta:set_string("formspec", formspec(pos, mem))
|
||||
meta:set_string("signs_bot_cmnd", "turn_off")
|
||||
meta:set_int("err_code", 0)
|
||||
signs_bot.infotext(pos, I("stopped"))
|
||||
signs_bot.infotext(pos, S("stopped"))
|
||||
if minetest.global_exists("techage") then
|
||||
techage.ElectricCable:after_place_node(pos)
|
||||
mem.capa = get_capa(itemstack)
|
||||
@ -489,12 +486,12 @@ minetest.register_node("signs_bot:box", {
|
||||
on_power = function(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.power_available = true
|
||||
signs_bot.infotext(pos, I("charging"))
|
||||
signs_bot.infotext(pos, S("charging"))
|
||||
end,
|
||||
on_nopower = function(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.power_available = false
|
||||
signs_bot.infotext(pos, I("no power"))
|
||||
signs_bot.infotext(pos, S("no power"))
|
||||
end,
|
||||
nominal = PWR_NEEDED,
|
||||
}
|
||||
@ -532,22 +529,22 @@ end
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "box", {
|
||||
name = I("Signs Bot Box"),
|
||||
name = S("Signs Bot Box"),
|
||||
data = {
|
||||
item = "signs_bot:box",
|
||||
text = table.concat({
|
||||
I("The Box is the housing of the bot."),
|
||||
I("Place the box and start the bot by means of the 'On' button."),
|
||||
I("If the mod techage is installed, the bot needs electrical power."),
|
||||
S("The Box is the housing of the bot."),
|
||||
S("Place the box and start the bot by means of the 'On' button."),
|
||||
S("If the mod techage is installed, the bot needs electrical power."),
|
||||
"",
|
||||
I("The bot leaves the box on the right side."),
|
||||
I("It will not start, if this position is blocked."),
|
||||
S("The bot leaves the box on the right side."),
|
||||
S("It will not start, if this position is blocked."),
|
||||
"",
|
||||
I("To stop and remove the bot, press the 'Off' button."),
|
||||
S("To stop and remove the bot, press the 'Off' button."),
|
||||
"",
|
||||
I("The box inventory simulates the inventory of the bot."),
|
||||
I("You will not be able to access the inventory, if the bot is running."),
|
||||
I("The bot can carry up to 8 stacks and 6 signs with it."),
|
||||
S("The box inventory simulates the inventory of the bot."),
|
||||
S("You will not be able to access the inventory, if the bot is running."),
|
||||
S("The bot can carry up to 8 stacks and 6 signs with it."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
24
bot_flap.lua
24
bot_flap.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPLv3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local function formspec(cmnd)
|
||||
cmnd = minetest.formspec_escape(cmnd)
|
||||
@ -28,7 +22,7 @@ local function formspec(cmnd)
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[0.3,0.3;"..cmnd.."]"..
|
||||
"button_exit[2.5,5.5;2,1;exit;"..I("Exit").."]"
|
||||
"button_exit[2.5,5.5;2,1;exit;"..S("Exit").."]"
|
||||
end
|
||||
|
||||
local commands = [[dig_sign 6
|
||||
@ -37,7 +31,7 @@ place_sign_behind 6
|
||||
]]
|
||||
|
||||
minetest.register_node("signs_bot:bot_flap", {
|
||||
description = "Bot Flap",
|
||||
description = S("Bot Flap"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {
|
||||
"signs_bot_bot_flap_top.png",
|
||||
@ -69,13 +63,13 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "bot_flap", {
|
||||
name = I("Bot Flap"),
|
||||
name = S("Bot Flap"),
|
||||
data = {
|
||||
item = "signs_bot:bot_flap",
|
||||
text = table.concat({
|
||||
I("The flap is a simple block used as door for the bot."),
|
||||
I("Place the flap in any wall, and the bot will automatically open"),
|
||||
I("and close the flap as it passes through it."),
|
||||
S("The flap is a simple block used as door for the bot."),
|
||||
S("Place the flap in any wall, and the bot will automatically open"),
|
||||
S("and close the flap as it passes through it."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,22 +13,19 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local lib = signs_bot.lib
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
M(pos):set_string("infotext", I("Bot Sensor: Connected with ")..S(dest_pos).." / "..cmnd)
|
||||
M(pos):set_string("infotext", S("Bot Sensor: Connected with").." "..P2S(dest_pos).." / "..cmnd)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:bot_sensor", {
|
||||
description = I("Bot Sensor"),
|
||||
description = S("Bot Sensor"),
|
||||
inventory_image = "signs_bot_sensor_bot_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -49,7 +46,7 @@ minetest.register_node("signs_bot:bot_sensor", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
meta:set_string("infotext", I("Bot Sensor: Not connected"))
|
||||
meta:set_string("infotext", S("Bot Sensor: Not connected"))
|
||||
end,
|
||||
|
||||
update_infotext = update_infotext,
|
||||
@ -64,7 +61,7 @@ minetest.register_node("signs_bot:bot_sensor", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:bot_sensor_on", {
|
||||
description = I("Bot Sensor"),
|
||||
description = S("Bot Sensor"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -120,13 +117,13 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "bot_sensor", {
|
||||
name = I("Bot Sensor"),
|
||||
name = S("Bot Sensor"),
|
||||
data = {
|
||||
item = "signs_bot:bot_sensor",
|
||||
text = table.concat({
|
||||
I("The Bot Sensor detects any bot and sends a signal, if a bot is nearby."),
|
||||
I("the sensor range is one node/meter."),
|
||||
I("The sensor direction does not care."),
|
||||
S("The Bot Sensor detects any bot and sends a signal, if a bot is nearby."),
|
||||
S("the sensor range is one node/meter."),
|
||||
S("The sensor direction does not care."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,20 +13,19 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local function update_infotext(pos, dest_pos, dest_idx)
|
||||
M(pos):set_string("infotext", I("Cart Sensor: Connected with ")..S(dest_pos).." / "..dest_idx)
|
||||
M(pos):set_string("infotext", S("Cart Sensor: Connected with").." "..P2S(dest_pos).." / "..dest_idx)
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
@ -62,7 +61,7 @@ local function node_timer(pos)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:cart_sensor", {
|
||||
description = I("Cart Sensor"),
|
||||
description = S("Cart Sensor"),
|
||||
inventory_image = "signs_bot_sensor_cart_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -83,7 +82,7 @@ minetest.register_node("signs_bot:cart_sensor", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
meta:set_string("infotext", "Cart Sensor: Not connected")
|
||||
meta:set_string("infotext", S("Cart Sensor: Not connected"))
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("param2", (node.param2 + 2) % 4)
|
||||
@ -102,7 +101,7 @@ minetest.register_node("signs_bot:cart_sensor", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:cart_sensor_on", {
|
||||
description = I("Cart Sensor"),
|
||||
description = S("Cart Sensor"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -158,13 +157,13 @@ minetest.register_lbm({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "cart_sensor", {
|
||||
name = I("Cart Sensor"),
|
||||
name = S("Cart Sensor"),
|
||||
data = {
|
||||
item = "signs_bot:cart_sensor",
|
||||
text = table.concat({
|
||||
I("The Cart Sensor detects and sends a signal, if a cart (Minecart) is nearby."),
|
||||
I("the sensor range is one node/meter."),
|
||||
I("The sensor has an active side (red) that must point to the rail/cart."),
|
||||
S("The Cart Sensor detects and sends a signal, if a cart (Minecart) is nearby."),
|
||||
S("the sensor range is one node/meter."),
|
||||
S("The sensor has an active side (red) that must point to the rail/cart."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
27
changer.lua
27
changer.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -34,7 +31,7 @@ local formspec = "size[8,7]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[1,1.3;"..I("Signs:").."]"..
|
||||
"label[1,1.3;"..S("Signs:").."]"..
|
||||
"label[2.6,0.7;1]label[5.1,0.7;2]"..
|
||||
"list[context;sign;3,0.5;2,2;]"..
|
||||
"label[2.6,1.7;3]label[5.1,1.7;4]"..
|
||||
@ -108,7 +105,7 @@ end
|
||||
for idx = 1,4 do
|
||||
local not_in_inv = idx == 1 and 0 or 1
|
||||
minetest.register_node("signs_bot:changer"..idx, {
|
||||
description = I("Bot Control Unit"),
|
||||
description = S("Bot Control Unit"),
|
||||
inventory_image = "signs_bot_ctrl_unit_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -169,18 +166,18 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "changer", {
|
||||
name = I("Bot Control Unit"),
|
||||
name = S("Bot Control Unit"),
|
||||
data = {
|
||||
item = "signs_bot:changer1",
|
||||
text = table.concat({
|
||||
I("The Bot Control Unit is used to lead the bot by means of signs."),
|
||||
I("The unit can be loaded with up to 4 different signs and can be programmed by means of sensors."),
|
||||
S("The Bot Control Unit is used to lead the bot by means of signs."),
|
||||
S("The unit can be loaded with up to 4 different signs and can be programmed by means of sensors."),
|
||||
"",
|
||||
I("To load the unit, place a sign on the red side of the unit and click on the unit."),
|
||||
I("The sign disappears / is moved to the inventory of the unit."),
|
||||
I("This can be repeated 3 times."),
|
||||
S("To load the unit, place a sign on the red side of the unit and click on the unit."),
|
||||
S("The sign disappears / is moved to the inventory of the unit."),
|
||||
S("This can be repeated 3 times."),
|
||||
"",
|
||||
I("Use the connection tool to connect up to 4 sensors with the Bot Control Unit."),
|
||||
S("Use the connection tool to connect up to 4 sensors with the Bot Control Unit."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
31
chest.lua
31
chest.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-0221 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,12 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local NODE_IO = minetest.global_exists("node_io")
|
||||
|
||||
@ -50,7 +49,7 @@ end
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
local meta = M(pos)
|
||||
local state = get_inv_state(pos)
|
||||
meta:set_string("infotext", I("Bot Chest: Sends signal to ")..S(dest_pos).." / "..cmnd..", if "..state)
|
||||
meta:set_string("infotext", S("Bot Chest: Sends signal to").." "..P2S(dest_pos).." / "..cmnd..", if "..state)
|
||||
meta:set_string("state", state)
|
||||
|
||||
end
|
||||
@ -68,7 +67,7 @@ end
|
||||
|
||||
if NODE_IO then
|
||||
minetest.register_node("signs_bot:chest", {
|
||||
description = I("Signs Bot Chest"),
|
||||
description = S("Signs Bot Chest"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'signs_bot_chest_top.png',
|
||||
@ -91,7 +90,7 @@ if NODE_IO then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec(pos, mem))
|
||||
meta:set_string("infotext", "Bot Chest: Not connected")
|
||||
meta:set_string("infotext", S("Bot Chest: Not connected"))
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
@ -158,7 +157,7 @@ if NODE_IO then
|
||||
})
|
||||
else
|
||||
minetest.register_node("signs_bot:chest", {
|
||||
description = I("Signs Bot Chest"),
|
||||
description = S("Signs Bot Chest"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'signs_bot_chest_top.png',
|
||||
@ -181,7 +180,7 @@ else
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec(pos, mem))
|
||||
meta:set_string("infotext", "Bot Chest: Not connected")
|
||||
meta:set_string("infotext", S("Bot Chest: Not connected"))
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
@ -245,15 +244,15 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "chest", {
|
||||
name = I("Signs Bot Chest"),
|
||||
name = S("Signs Bot Chest"),
|
||||
data = {
|
||||
item = "signs_bot:chest",
|
||||
text = table.concat({
|
||||
I("The Signs Bot Chest is a special chest with sensor function."),
|
||||
I("It sends a signal depending on the chest state."),
|
||||
I("Possible states are 'empty', 'not empty', 'almost full'"),
|
||||
S("The Signs Bot Chest is a special chest with sensor function."),
|
||||
S("It sends a signal depending on the chest state."),
|
||||
S("Possible states are 'empty', 'not empty', 'almost full'"),
|
||||
"",
|
||||
I("A typical use case is to turn off the bot, when the chest is almost full or empty."),
|
||||
S("A typical use case is to turn off the bot, when the chest is almost full or empty."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -11,14 +11,8 @@
|
||||
Bot farming commands
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -65,7 +59,7 @@ signs_bot.register_botcommand("sow_seed", {
|
||||
mod = "farming",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Sow farming seeds\nin front of the robot"),
|
||||
description = S("Sow farming seeds\nin front of the robot"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot)
|
||||
return slot and slot > 0 and slot < 9
|
||||
@ -110,7 +104,7 @@ signs_bot.register_botcommand("harvest", {
|
||||
mod = "farming",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Harvest farming products\nin front of the robot\non a 3x3 field."),
|
||||
description = S("Harvest farming products\nin front of the robot\non a 3x3 field."),
|
||||
cmnd = function(base_pos, mem)
|
||||
if not mem.steps then
|
||||
mem.pos_tbl = signs_bot.lib.gen_position_table(mem.robot_pos, mem.robot_param2, 3, 3, 0)
|
||||
@ -148,7 +142,7 @@ signs_bot.register_botcommand("plant_sapling", {
|
||||
mod = "farming",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Plant a sapling\nin front of the robot"),
|
||||
description = S("Plant a sapling\nin front of the robot"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot)
|
||||
return slot and slot > 0 and slot < 9
|
||||
@ -171,7 +165,7 @@ turn_around]]
|
||||
|
||||
signs_bot.register_sign({
|
||||
name = "farming",
|
||||
description = I('Sign "farming"'),
|
||||
description = S('Sign "farming"'),
|
||||
commands = CMD,
|
||||
image = "signs_bot_sign_farming.png",
|
||||
})
|
||||
@ -187,14 +181,14 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "farming", {
|
||||
name = I("Sign 'farming'"),
|
||||
name = S("Sign 'farming'"),
|
||||
data = {
|
||||
item = "signs_bot:farming",
|
||||
text = table.concat({
|
||||
I("Used to harvest and seed a 3x3 field."),
|
||||
I("Place the sign in front of the field."),
|
||||
I("The seed to be placed has to be in the first inventory slot of the bot."),
|
||||
I("When finished, the bot turns."),
|
||||
S("Used to harvest and seed a 3x3 field."),
|
||||
S("Place the sign in front of the field."),
|
||||
S("The seed to be placed has to be in the first inventory slot of the bot."),
|
||||
S("When finished, the bot turns."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -11,14 +11,8 @@
|
||||
Bot flower cutting command
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -75,7 +69,7 @@ signs_bot.register_botcommand("cutting", {
|
||||
mod = "farming",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Cutting flowers and tree blocks\nin front of the robot\non a 3x3 field."),
|
||||
description = S("Cutting flowers and tree blocks\nin front of the robot\non a 3x3 field."),
|
||||
cmnd = function(base_pos, mem)
|
||||
if not mem.steps then
|
||||
mem.pos_tbl = signs_bot.lib.gen_position_table(mem.robot_pos, mem.robot_param2, 3, 3, 0)
|
||||
@ -100,7 +94,7 @@ turn_around]]
|
||||
|
||||
signs_bot.register_sign({
|
||||
name = "flowers",
|
||||
description = I('Sign "flowers"'),
|
||||
description = S('Sign "flowers"'),
|
||||
commands = CMD,
|
||||
image = "signs_bot_sign_flowers.png",
|
||||
})
|
||||
@ -116,13 +110,13 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "flowers", {
|
||||
name = I("Sign 'flowers'"),
|
||||
name = S("Sign 'flowers'"),
|
||||
data = {
|
||||
item = "signs_bot:flowers",
|
||||
text = table.concat({
|
||||
I("Used to cut flowers on a 3x3 field."),
|
||||
I("Place the sign in front of the field."),
|
||||
I("When finished, the bot turns."),
|
||||
S("Used to cut flowers on a 3x3 field."),
|
||||
S("Place the sign in front of the field."),
|
||||
S("When finished, the bot turns."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
25
cmd_item.lua
25
cmd_item.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -90,7 +87,7 @@ signs_bot.register_botcommand("take_item", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("Take <num> items from a chest like node\nand put it into the item inventory.\n"..
|
||||
description = S("Take <num> items from a chest like node\nand put it into the item inventory.\n"..
|
||||
"<slot> is the inventory slot (1..8) or 0 for any one"),
|
||||
check = function(num, slot)
|
||||
num = tonumber(num) or 1
|
||||
@ -115,7 +112,7 @@ signs_bot.register_botcommand("add_item", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("Add <num> items to a chest like node\ntaken from the item inventory.\n"..
|
||||
description = S("Add <num> items to a chest like node\ntaken from the item inventory.\n"..
|
||||
"<slot> is the inventory slot (1..8) or 0 for any one"),
|
||||
check = function(num, slot)
|
||||
num = tonumber(num) or 1
|
||||
@ -140,7 +137,7 @@ signs_bot.register_botcommand("add_fuel", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("Add <num> fuel to a furnace like node\ntaken from the item inventory.\n"..
|
||||
description = S("Add <num> fuel to a furnace like node\ntaken from the item inventory.\n"..
|
||||
"<slot> is the inventory slot (1..8) or 0 for any one"),
|
||||
check = function(num, slot)
|
||||
num = tonumber(num) or 1
|
||||
@ -165,7 +162,7 @@ signs_bot.register_botcommand("cond_take_item", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("deprecated, use bot inventory configuration instead"),
|
||||
description = S("deprecated, use bot inventory configuration instead"),
|
||||
check = function(num, slot)
|
||||
return false
|
||||
end,
|
||||
@ -178,7 +175,7 @@ signs_bot.register_botcommand("cond_add_item", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("deprecated, use bot inventory configuration instead"),
|
||||
description = S("deprecated, use bot inventory configuration instead"),
|
||||
check = function(num, slot)
|
||||
return false
|
||||
end,
|
||||
@ -191,7 +188,7 @@ signs_bot.register_botcommand("pickup_items", {
|
||||
mod = "item",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Pick up all objects\n"..
|
||||
description = S("Pick up all objects\n"..
|
||||
"in a 3x3 field.\n"..
|
||||
"<slot> is the inventory slot (1..8) or 0 for any one"),
|
||||
check = function(slot)
|
||||
@ -219,7 +216,7 @@ signs_bot.register_botcommand("drop_items", {
|
||||
mod = "item",
|
||||
params = "<num> <slot>",
|
||||
num_param = 2,
|
||||
description = I("Drop items in front of the bot.\n"..
|
||||
description = S("Drop items in front of the bot.\n"..
|
||||
"<slot> is the inventory slot (1..8) or 0 for any one"),
|
||||
check = function(num, slot)
|
||||
num = tonumber(num) or 1
|
||||
@ -246,7 +243,7 @@ signs_bot.register_botcommand("punch_cart", {
|
||||
mod = "item",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Punch a rail cart to start it"),
|
||||
description = S("Punch a rail cart to start it"),
|
||||
cmnd = function(base_pos, mem)
|
||||
local pos = lib.dest_pos(mem.robot_pos, mem.robot_param2, {0})
|
||||
for _, object in pairs(minetest.get_objects_inside_radius(pos, 2)) do
|
||||
|
30
cmd_move.lua
30
cmd_move.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
local get_node_lvm = tubelib2.get_node_lvm
|
||||
@ -135,7 +129,7 @@ signs_bot.register_botcommand("backward", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Move the robot one step back"),
|
||||
description = S("Move the robot one step back"),
|
||||
cmnd = function(base_pos, mem)
|
||||
local new_pos = backward_robot(mem)
|
||||
if new_pos then -- not blocked?
|
||||
@ -160,7 +154,7 @@ signs_bot.register_botcommand("turn_left", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Turn the robot to the left"),
|
||||
description = S("Turn the robot to the left"),
|
||||
cmnd = function(base_pos, mem)
|
||||
mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "L")
|
||||
return signs_bot.DONE
|
||||
@ -171,7 +165,7 @@ signs_bot.register_botcommand("turn_right", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Turn the robot to the right"),
|
||||
description = S("Turn the robot to the right"),
|
||||
cmnd = function(base_pos, mem)
|
||||
mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "R")
|
||||
return signs_bot.DONE
|
||||
@ -182,7 +176,7 @@ signs_bot.register_botcommand("turn_around", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Turn the robot around"),
|
||||
description = S("Turn the robot around"),
|
||||
cmnd = function(base_pos, mem)
|
||||
mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "R")
|
||||
mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "R")
|
||||
@ -217,7 +211,7 @@ signs_bot.register_botcommand("move_up", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Move the robot upwards"),
|
||||
description = S("Move the robot upwards"),
|
||||
cmnd = function(base_pos, mem)
|
||||
local new_pos = robot_up(mem.robot_pos, mem.robot_param2)
|
||||
if new_pos then -- not blocked?
|
||||
@ -251,7 +245,7 @@ signs_bot.register_botcommand("move_down", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Move the robot down"),
|
||||
description = S("Move the robot down"),
|
||||
cmnd = function(base_pos, mem)
|
||||
local new_pos = robot_down(mem.robot_pos, mem.robot_param2)
|
||||
if new_pos then -- not blocked?
|
||||
@ -265,7 +259,7 @@ signs_bot.register_botcommand("pause", {
|
||||
mod = "move",
|
||||
params = "<sec>",
|
||||
num_param = 1,
|
||||
description = I("Stop the robot for <sec> seconds\n(1..9999)"),
|
||||
description = S("Stop the robot for <sec> seconds\n(1..9999)"),
|
||||
check = function(sec)
|
||||
sec = tonumber(sec) or 1
|
||||
return sec and sec > 0 and sec < 10000
|
||||
@ -290,7 +284,7 @@ signs_bot.register_botcommand("stop", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Stop the robot."),
|
||||
description = S("Stop the robot."),
|
||||
cmnd = function(base_pos, mem, slot)
|
||||
if mem.capa then
|
||||
mem.capa = mem.capa + 2
|
||||
@ -303,7 +297,7 @@ signs_bot.register_botcommand("turn_off", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Turn the robot off\n"..
|
||||
description = S("Turn the robot off\n"..
|
||||
"and put it back in the box."),
|
||||
cmnd = function(base_pos, mem)
|
||||
signs_bot.stop_robot(base_pos, mem)
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -117,7 +111,7 @@ signs_bot.register_botcommand("pattern", {
|
||||
mod = "copy",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I("Store pattern to be cloned."),
|
||||
description = S("Store pattern to be cloned."),
|
||||
cmnd = function(base_pos, mem)
|
||||
mem.pttrn_pos = lib.next_pos(mem.robot_pos, mem.robot_param2)
|
||||
mem.pttrn_param2 = mem.robot_param2
|
||||
@ -129,7 +123,7 @@ signs_bot.register_botcommand("copy", {
|
||||
mod = "copy",
|
||||
params = "<size> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Copy the nodes from\n"..
|
||||
description = S("Copy the nodes from\n"..
|
||||
"the stored pattern position\n"..
|
||||
"<size> is: 3x1, 3x2, 3x3,\n"..
|
||||
"5x1, 5x2, 5x3 (wide x deep)\n"..
|
||||
@ -178,7 +172,7 @@ minetest.register_node("signs_bot:missing", {
|
||||
|
||||
signs_bot.register_sign({
|
||||
name = "pattern",
|
||||
description = I('Sign "pattern"'),
|
||||
description = S('Sign "pattern"'),
|
||||
commands = "pattern\nturn_around",
|
||||
image = "signs_bot_sign_pattern.png",
|
||||
})
|
||||
@ -207,7 +201,7 @@ turn_around]]
|
||||
|
||||
signs_bot.register_sign({
|
||||
name = "copy3x3x3",
|
||||
description = I('Sign "copy 3x3x3"'),
|
||||
description = S('Sign "copy 3x3x3"'),
|
||||
commands = CMND,
|
||||
image = "signs_bot_sign_copy3x3x3.png",
|
||||
})
|
||||
@ -223,14 +217,14 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "pattern", {
|
||||
name = I("Sign 'pattern'"),
|
||||
name = S("Sign 'pattern'"),
|
||||
data = {
|
||||
item = "signs_bot:pattern",
|
||||
text = table.concat({
|
||||
I("Used to make a copy of a 3x3x3 cube."),
|
||||
I("Place the sign in front of the pattern to be copied."),
|
||||
I("Use the copy sign to make the copy of this pattern on a different location."),
|
||||
I("The bot must first reach the pattern sign, then the copy sign."),
|
||||
S("Used to make a copy of a 3x3x3 cube."),
|
||||
S("Place the sign in front of the pattern to be copied."),
|
||||
S("Use the copy sign to make the copy of this pattern on a different location."),
|
||||
S("The bot must first reach the pattern sign, then the copy sign."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
@ -238,13 +232,13 @@ end
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "copy3x3x3", {
|
||||
name = I("Sign 'copy3x3x3'"),
|
||||
name = S("Sign 'copy3x3x3'"),
|
||||
data = {
|
||||
item = "signs_bot:copy3x3x3",
|
||||
text = table.concat({
|
||||
I("Used to make a copy of a 3x3x3 cube."),
|
||||
I("Place the sign in front of the location, where the copy should be made."),
|
||||
I("Use the pattern sign to mark the pattern."),
|
||||
S("Used to make a copy of a 3x3x3 cube."),
|
||||
S("Place the sign in front of the location, where the copy should be made."),
|
||||
S("Use the pattern sign to mark the pattern."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
local bot_inv_take_item = signs_bot.bot_inv_take_item
|
||||
@ -46,7 +40,7 @@ local function place_item(base_pos, robot_pos, param2, slot, route, level)
|
||||
local pos1, p2 = lib.dest_pos(robot_pos, param2, route)
|
||||
pos1.y = pos1.y + level
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if lib.is_air_like(pos1) then
|
||||
local taken = signs_bot.bot_inv_take_item(base_pos, slot, 1)
|
||||
@ -74,7 +68,7 @@ signs_bot.register_botcommand("place_front", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Place a block in front of the robot\n"..
|
||||
description = S("Place a block in front of the robot\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -95,7 +89,7 @@ signs_bot.register_botcommand("place_left", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Place a block on the left side\n"..
|
||||
description = S("Place a block on the left side\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -116,7 +110,7 @@ signs_bot.register_botcommand("place_right", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Place a block on the right side\n"..
|
||||
description = S("Place a block on the right side\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -136,7 +130,7 @@ signs_bot.register_botcommand("place_right", {
|
||||
local function place_item_below(base_pos, robot_pos, param2, slot)
|
||||
local pos1 = {x=robot_pos.x,y=robot_pos.y-1,z=robot_pos.z}
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
if node.name == "signs_bot:robot_foot" then
|
||||
@ -155,7 +149,7 @@ signs_bot.register_botcommand("place_below", {
|
||||
mod = "place",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Place a block under the robot.\n"..
|
||||
description = S("Place a block under the robot.\n"..
|
||||
"Hint: use 'move_up' first.\n"..
|
||||
"<slot> is the inventory slot (1..8)"),
|
||||
check = function(slot)
|
||||
@ -171,7 +165,7 @@ signs_bot.register_botcommand("place_below", {
|
||||
local function place_item_above(base_pos, robot_pos, param2, slot)
|
||||
local pos1 = {x=robot_pos.x,y=robot_pos.y+1,z=robot_pos.z}
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if lib.is_air_like(pos1) then
|
||||
local taken = bot_inv_take_item(base_pos, slot, 1)
|
||||
@ -189,7 +183,7 @@ signs_bot.register_botcommand("place_above", {
|
||||
mod = "place",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Place a block above the robot.\n"..
|
||||
description = S("Place a block above the robot.\n"..
|
||||
"<slot> is the inventory slot (1..8)"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot) or 0
|
||||
@ -207,13 +201,13 @@ local function dig_item(base_pos, robot_pos, param2, slot, route, level)
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
local dug_name = lib.is_simple_node(node)
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if dug_name then
|
||||
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
|
||||
minetest.remove_node(pos1)
|
||||
else
|
||||
return signs_bot.ERROR, I("Error: No free inventory space")
|
||||
return signs_bot.ERROR, S("Error: No free inventory space")
|
||||
end
|
||||
end
|
||||
return signs_bot.DONE
|
||||
@ -223,7 +217,7 @@ signs_bot.register_botcommand("dig_front", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Dig the block in front of the robot\n"..
|
||||
description = S("Dig the block in front of the robot\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -245,7 +239,7 @@ signs_bot.register_botcommand("dig_left", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Dig the block on the left side\n"..
|
||||
description = S("Dig the block on the left side\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -267,7 +261,7 @@ signs_bot.register_botcommand("dig_right", {
|
||||
mod = "place",
|
||||
params = "<slot> <lvl>",
|
||||
num_param = 2,
|
||||
description = I("Dig the block on the right side\n"..
|
||||
description = S("Dig the block on the right side\n"..
|
||||
"<slot> is the inventory slot (1..8)\n"..
|
||||
"<lvl> is one of: -1 0 +1"),
|
||||
check = function(slot, lvl)
|
||||
@ -290,13 +284,13 @@ local function dig_item_below(base_pos, robot_pos, param2, slot)
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
local dug_name = lib.is_simple_node(node)
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if dug_name then
|
||||
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
|
||||
minetest.set_node(pos1, {name="signs_bot:robot_foot"})
|
||||
else
|
||||
return signs_bot.ERROR, I("Error: No free inventory space")
|
||||
return signs_bot.ERROR, S("Error: No free inventory space")
|
||||
end
|
||||
end
|
||||
return signs_bot.DONE
|
||||
@ -306,7 +300,7 @@ signs_bot.register_botcommand("dig_below", {
|
||||
mod = "place",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Dig the block under the robot.\n"..
|
||||
description = S("Dig the block under the robot.\n"..
|
||||
"<slot> is the inventory slot (1..8)"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot) or 0
|
||||
@ -324,13 +318,13 @@ local function dig_item_above(base_pos, robot_pos, param2, slot)
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
local dug_name = lib.is_simple_node(node)
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if dug_name then
|
||||
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
|
||||
minetest.remove_node(pos1)
|
||||
else
|
||||
return signs_bot.ERROR, I("Error: No free inventory space")
|
||||
return signs_bot.ERROR, S("Error: No free inventory space")
|
||||
end
|
||||
end
|
||||
return signs_bot.DONE
|
||||
@ -340,7 +334,7 @@ signs_bot.register_botcommand("dig_above", {
|
||||
mod = "place",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Dig the block above the robot.\n"..
|
||||
description = S("Dig the block above the robot.\n"..
|
||||
"<slot> is the inventory slot (1..8)"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot) or 0
|
||||
@ -358,7 +352,7 @@ local function rotate_item(base_pos, robot_pos, param2, route, level, steps)
|
||||
pos1.y = pos1.y + level
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
if not lib.not_protected(base_pos, pos1) then
|
||||
return signs_bot.ERROR, I("Error: Position protected")
|
||||
return signs_bot.ERROR, S("Error: Position protected")
|
||||
end
|
||||
if lib.is_simple_node(node) then
|
||||
local p2 = tRotations[node.param2] and tRotations[node.param2][steps]
|
||||
@ -372,7 +366,7 @@ end
|
||||
signs_bot.register_botcommand("rotate_item", {
|
||||
mod = "place",
|
||||
params = "<lvl> <steps>",
|
||||
description = I("Rotate the block in front of the robot\n"..
|
||||
description = S("Rotate the block in front of the robot\n"..
|
||||
"<lvl> is one of: -1 0 +1\n"..
|
||||
"<steps> is one of: 1 2 3"),
|
||||
check = function(lvl, steps)
|
||||
@ -391,7 +385,7 @@ signs_bot.register_botcommand("rotate_item", {
|
||||
|
||||
-- Simplified torch which can be placed w/o a fake player
|
||||
minetest.register_node("signs_bot:torch", {
|
||||
description = "Bot torch",
|
||||
description = S("Bot torch"),
|
||||
inventory_image = "default_torch_on_floor.png",
|
||||
wield_image = "default_torch_on_floor.png",
|
||||
drawtype = "nodebox",
|
||||
|
67
cmd_sign.lua
67
cmd_sign.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -48,12 +45,12 @@ local function formspec1(meta)
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea,table;font=mono]"..
|
||||
"tabheader[0,0;tab;"..I("Commands,Help")..";1;;true]"..
|
||||
"field[0.3,0.5;9,1;name;"..I("Sign name:")..";"..name.."]"..
|
||||
"tabheader[0,0;tab;"..S("Commands,Help")..";1;;true]"..
|
||||
"field[0.3,0.5;9,1;name;"..S("Sign name:")..";"..name.."]"..
|
||||
"textarea[0.3,1.2;9,7.2;cmnd;;"..cmnd.."]"..
|
||||
"label[0.3,7.5;"..err_msg.."]"..
|
||||
"button_exit[5,7.5;2,1;cancel;"..I("Cancel").."]"..
|
||||
"button[7,7.5;2,1;check;"..I("Check").."]"
|
||||
"button_exit[5,7.5;2,1;cancel;"..S("Cancel").."]"..
|
||||
"button[7,7.5;2,1;check;"..S("Check").."]"
|
||||
end
|
||||
|
||||
local function formspec2(pos, text)
|
||||
@ -62,10 +59,10 @@ local function formspec2(pos, text)
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea,table;font=mono]"..
|
||||
"tabheader[0,0;tab;"..I("Commands,Help")..";2;;true]"..
|
||||
"tabheader[0,0;tab;"..S("Commands,Help")..";2;;true]"..
|
||||
"table[0.1,0;8.6,4;command;"..sCmnds..";"..pos.."]"..
|
||||
"textarea[0.3,4.5;9,3.5;help;Help:;"..text.."]"..
|
||||
"button[3,7.5;3,1;copy;"..I("Copy Cmnd").."]"
|
||||
"textarea[0.3,4.5;9,3.5;help;"..S("Help")..":;"..text.."]"..
|
||||
"button[3,7.5;3,1;copy;"..S("Copy Cmnd").."]"
|
||||
end
|
||||
|
||||
local function add_arrow(text, line_num)
|
||||
@ -94,7 +91,7 @@ local function append_line(pos, meta, line)
|
||||
local text = meta:get_string("signs_bot_cmnd").."\n"..line
|
||||
meta:set_string("signs_bot_cmnd", text)
|
||||
meta:set_int("err_code", 1) -- zero means OK
|
||||
meta:set_string("err_msg", "please check the added line(s)")
|
||||
meta:set_string("err_msg", S("please check the added line(s)"))
|
||||
end
|
||||
|
||||
local function check_and_store(pos, meta, fields)
|
||||
@ -106,7 +103,7 @@ local function check_and_store(pos, meta, fields)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:sign_cmnd", {
|
||||
description = I('Sign "command"'),
|
||||
description = S('Sign "command"'),
|
||||
drawtype = "nodebox",
|
||||
inventory_image = "signs_bot_sign_cmnd.png",
|
||||
node_box = {
|
||||
@ -134,8 +131,8 @@ minetest.register_node("signs_bot:sign_cmnd", {
|
||||
nmeta:set_string("err_msg", imeta:get_string("err_msg"))
|
||||
nmeta:set_int("err_code", imeta:get_int("err_code"))
|
||||
else
|
||||
nmeta:set_string("sign_name", I('Sign "command"'))
|
||||
nmeta:set_string("signs_bot_cmnd", I("-- enter or copy commands from help page"))
|
||||
nmeta:set_string("sign_name", S('Sign "command"'))
|
||||
nmeta:set_string("signs_bot_cmnd", S("-- enter or copy commands from help page"))
|
||||
nmeta:set_int("err_code", 0)
|
||||
end
|
||||
nmeta:set_string("infotext", nmeta:get_string("sign_name"))
|
||||
@ -216,18 +213,18 @@ local function place_sign(base_pos, robot_pos, param2, slot)
|
||||
lib.place_sign(pos1, sign, param2)
|
||||
return signs_bot.DONE
|
||||
else
|
||||
return signs_bot.ERROR, I("Error: Signs inventory empty")
|
||||
return signs_bot.ERROR, S("Error: Signs inventory empty")
|
||||
end
|
||||
end
|
||||
end
|
||||
return signs_bot.ERROR, I("Error: Position protected or occupied")
|
||||
return signs_bot.ERROR, S("Error: Position protected or occupied")
|
||||
end
|
||||
|
||||
signs_bot.register_botcommand("place_sign", {
|
||||
mod = "sign",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Place a sign in front of the robot\ntaken from the signs inventory\n"..
|
||||
description = S("Place a sign in front of the robot\ntaken from the signs inventory\n"..
|
||||
"<slot> is the inventory slot (1..6)"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot) or 1
|
||||
@ -248,18 +245,18 @@ local function place_sign_behind(base_pos, robot_pos, param2, slot)
|
||||
lib.place_sign(pos1, sign, param2)
|
||||
return signs_bot.DONE
|
||||
else
|
||||
return signs_bot.ERROR, I("Error: Signs inventory empty")
|
||||
return signs_bot.ERROR, S("Error: Signs inventory empty")
|
||||
end
|
||||
end
|
||||
end
|
||||
return signs_bot.ERROR, I("Error: Position protected or occupied")
|
||||
return signs_bot.ERROR, S("Error: Position protected or occupied")
|
||||
end
|
||||
|
||||
signs_bot.register_botcommand("place_sign_behind", {
|
||||
mod = "sign",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Place a sign behind the robot\ntaken from the signs inventory\n"..
|
||||
description = S("Place a sign behind the robot\ntaken from the signs inventory\n"..
|
||||
"<slot> is the inventory slot (1..6)"),
|
||||
check = function(slot)
|
||||
slot = tonumber(slot) or 1
|
||||
@ -278,7 +275,7 @@ local function dig_sign(base_pos, robot_pos, param2, slot)
|
||||
local err_code = meta:get_int("err_code")
|
||||
local name = meta:get_string("sign_name")
|
||||
if cmnd == "" then
|
||||
return signs_bot.ERROR, I("Error: No sign available")
|
||||
return signs_bot.ERROR, S("Error: No sign available")
|
||||
end
|
||||
if lib.not_protected(base_pos, pos1) then
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
@ -290,18 +287,18 @@ local function dig_sign(base_pos, robot_pos, param2, slot)
|
||||
minetest.remove_node(pos1)
|
||||
if not put_inv_sign(base_pos, slot, sign) then
|
||||
signs_bot.lib.drop_items(robot_pos, sign)
|
||||
return signs_bot.ERROR, I("Error: Signs inventory slot is occupied")
|
||||
return signs_bot.ERROR, S("Error: Signs inventory slot is occupied")
|
||||
end
|
||||
return signs_bot.DONE
|
||||
end
|
||||
return signs_bot.ERROR, I("Error: Position is protected")
|
||||
return signs_bot.ERROR, S("Error: Position is protected")
|
||||
end
|
||||
|
||||
signs_bot.register_botcommand("dig_sign", {
|
||||
mod = "sign",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Dig the sign in front of the robot\n"..
|
||||
description = S("Dig the sign in front of the robot\n"..
|
||||
"and add it to the signs inventory.\n"..
|
||||
"<slot> is the inventory slot (1..6)"),
|
||||
check = function(slot)
|
||||
@ -318,7 +315,7 @@ local function trash_sign(base_pos, robot_pos, param2, slot)
|
||||
local pos1 = lib.dest_pos(robot_pos, param2, {0})
|
||||
local cmnd = M(pos1):get_string("signs_bot_cmnd")
|
||||
if cmnd == "" then
|
||||
return signs_bot.ERROR, I("Error: No sign available")
|
||||
return signs_bot.ERROR, S("Error: No sign available")
|
||||
end
|
||||
if lib.not_protected(base_pos, pos1) then
|
||||
local node = tubelib2.get_node_lvm(pos1)
|
||||
@ -330,14 +327,14 @@ local function trash_sign(base_pos, robot_pos, param2, slot)
|
||||
end
|
||||
return signs_bot.DONE
|
||||
end
|
||||
return signs_bot.ERROR, I("Error: Position is protected")
|
||||
return signs_bot.ERROR, S("Error: Position is protected")
|
||||
end
|
||||
|
||||
signs_bot.register_botcommand("trash_sign", {
|
||||
mod = "sign",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Dig the sign in front of the robot\n"..
|
||||
description = S("Dig the sign in front of the robot\n"..
|
||||
"and add the cleared sign to\nthe item iventory.\n"..
|
||||
"<slot> is the inventory slot (1..8)"),
|
||||
check = function(slot)
|
||||
@ -362,14 +359,14 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "sign_cmnd", {
|
||||
name = I("Sign 'command'"),
|
||||
name = S("Sign 'command'"),
|
||||
data = {
|
||||
item = "signs_bot:sign_cmnd",
|
||||
text = table.concat({
|
||||
I("The 'command' sign can be programmed by the player."),
|
||||
I("Place the sign in front of you and use the node menu to program your sequence of bot commands."),
|
||||
I("The menu has an edit field for your commands and a help page with all available commands."),
|
||||
I("The help page has a copy button to simplify the programming."),
|
||||
S("The 'command' sign can be programmed by the player."),
|
||||
S("Place the sign in front of you and use the node menu to program your sequence of bot commands."),
|
||||
S("The menu has an edit field for your commands and a help page with all available commands."),
|
||||
S("The help page has a copy button to simplify the programming."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
27
commands.lua
27
commands.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,12 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
local ci = dofile(MP.."/interpreter.lua")
|
||||
|
||||
local lib = signs_bot.lib
|
||||
@ -73,7 +72,7 @@ end
|
||||
function signs_bot.get_commands()
|
||||
local tbl = {}
|
||||
for _,mod in ipairs(SortedMods) do
|
||||
tbl[#tbl+1] = mod.." "..I("commands:")
|
||||
tbl[#tbl+1] = mod.." "..S("commands:")
|
||||
for _,cmnd in ipairs(SortedKeys[mod]) do
|
||||
local item = tCommands[cmnd]
|
||||
tbl[#tbl+1] = " "..item.name.." "..item.params
|
||||
@ -90,7 +89,7 @@ function signs_bot.get_help_text(cmnd)
|
||||
return item.description
|
||||
end
|
||||
end
|
||||
return I("unknown command")
|
||||
return S("unknown command")
|
||||
end
|
||||
|
||||
function signs_bot.check_commands(pos, text)
|
||||
@ -197,31 +196,31 @@ end
|
||||
signs_bot.register_botcommand("repeat", {
|
||||
mod = "core",
|
||||
params = "<num>",
|
||||
description = I("start of a 'repeat..end' block"),
|
||||
description = S("start of a 'repeat..end' block"),
|
||||
})
|
||||
|
||||
signs_bot.register_botcommand("end", {
|
||||
mod = "core",
|
||||
params = "",
|
||||
description = I("end command of a 'repeat..end' block"),
|
||||
description = S("end command of a 'repeat..end' block"),
|
||||
})
|
||||
|
||||
signs_bot.register_botcommand("call", {
|
||||
mod = "core",
|
||||
params = "<label>",
|
||||
description = I("call a subroutine (with 'return' statement)"),
|
||||
description = S("call a subroutine (with 'return' statement)"),
|
||||
})
|
||||
|
||||
signs_bot.register_botcommand("return", {
|
||||
mod = "core",
|
||||
params = "",
|
||||
description = I("return from a subroutine"),
|
||||
description = S("return from a subroutine"),
|
||||
})
|
||||
|
||||
signs_bot.register_botcommand("jump", {
|
||||
mod = "core",
|
||||
params = "<label>",
|
||||
description = I("jump to a label"),
|
||||
description = S("jump to a label"),
|
||||
})
|
||||
|
||||
local function move(mem, any_sensor)
|
||||
@ -241,7 +240,7 @@ signs_bot.register_botcommand("move", {
|
||||
mod = "move",
|
||||
params = "<steps>",
|
||||
num_param = 1,
|
||||
description = I([[Move the robot 1..999 steps forward
|
||||
description = S([[Move the robot 1..999 steps forward
|
||||
without paying attention to any signs.
|
||||
Up and down movements also become
|
||||
counted as steps.]]),
|
||||
@ -261,7 +260,7 @@ signs_bot.register_botcommand("cond_move", {
|
||||
mod = "move",
|
||||
params = "",
|
||||
num_param = 0,
|
||||
description = I([[Walk until a sign or obstacle is
|
||||
description = S([[Walk until a sign or obstacle is
|
||||
reached. Then continue with the next command.
|
||||
When a sign has been reached,
|
||||
the current program is ended
|
||||
|
23
compost.lua
23
compost.lua
@ -1,6 +1,19 @@
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
--[[
|
||||
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Signs Bot: Commands for the compost mod
|
||||
|
||||
]]--
|
||||
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local NUM_LEAVES = 2
|
||||
|
||||
@ -46,7 +59,7 @@ if minetest.global_exists("signs_bot") then
|
||||
mod = "compost",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Put 2 leaves into the compost barrel\n"..
|
||||
description = S("Put 2 leaves into the compost barrel\n"..
|
||||
"<slot> is the bot inventory slot (1..8)\n"..
|
||||
"with the leaves."),
|
||||
check = function(slot)
|
||||
@ -68,7 +81,7 @@ if minetest.global_exists("signs_bot") then
|
||||
mod = "compost",
|
||||
params = "<slot>",
|
||||
num_param = 1,
|
||||
description = I("Take a compost item from the barrel.\n"..
|
||||
description = S("Take a compost item from the barrel.\n"..
|
||||
"<slot> (1..8 or 0 for the first free slot) is the bot\n"..
|
||||
"slot for the compost item."),
|
||||
check = function(num, slot)
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,20 +13,18 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
|
||||
local function update_infotext(pos, dest_pos, dest_idx)
|
||||
M(pos):set_string("infotext", I("Crop Sensor: Connected with ")..S(dest_pos).." / "..dest_idx)
|
||||
M(pos):set_string("infotext", S("Crop Sensor: Connected with").." "..P2S(dest_pos).." / "..dest_idx)
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
@ -56,7 +54,7 @@ local function node_timer(pos)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:crop_sensor", {
|
||||
description = I("Crop Sensor"),
|
||||
description = S("Crop Sensor"),
|
||||
inventory_image = "signs_bot_sensor_crop_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -77,7 +75,7 @@ minetest.register_node("signs_bot:crop_sensor", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
meta:set_string("infotext", "Crop Sensor: Not connected")
|
||||
meta:set_string("infotext", S("Crop Sensor: Not connected"))
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("param2", (node.param2 + 2) % 4)
|
||||
@ -96,7 +94,7 @@ minetest.register_node("signs_bot:crop_sensor", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:crop_sensor_on", {
|
||||
description = I("Crop Sensor"),
|
||||
description = S("Crop Sensor"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -152,13 +150,13 @@ minetest.register_lbm({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "crop_sensor", {
|
||||
name = I("Crop Sensor"),
|
||||
name = S("Crop Sensor"),
|
||||
data = {
|
||||
item = "signs_bot:crop_sensor",
|
||||
text = table.concat({
|
||||
I("The Crop Sensor sends cyclical signals when, for example, wheat is fully grown."),
|
||||
I("The sensor range is one node/meter."),
|
||||
I("The sensor has an active side (red) that must point to the crop/field."),
|
||||
S("The Crop Sensor sends cyclical signals when, for example, wheat is fully grown."),
|
||||
S("The sensor range is one node/meter."),
|
||||
S("The sensor has an active side (red) that must point to the crop/field."),
|
||||
|
||||
}, "\n")
|
||||
},
|
||||
|
33
delayer.lua
33
delayer.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,20 +13,17 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
M(pos):set_string("infotext", I("Signal Delayer: Connected with ")..S(dest_pos).." / "..cmnd)
|
||||
M(pos):set_string("infotext", S("Signal Delayer: Connected with").." "..P2S(dest_pos).." / "..cmnd)
|
||||
end
|
||||
|
||||
local function infotext(pos)
|
||||
@ -34,19 +31,19 @@ local function infotext(pos)
|
||||
local dest_pos = meta:get_string("signal_pos")
|
||||
local signal = meta:get_string("signal_data")
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
update_infotext(pos, P(dest_pos), signal)
|
||||
update_infotext(pos, S2P(dest_pos), signal)
|
||||
end
|
||||
end
|
||||
|
||||
local function formspec(meta)
|
||||
local label = minetest.formspec_escape(I("Delay time [sec]:"))
|
||||
local label = minetest.formspec_escape(S("Delay time [sec]:"))
|
||||
local value = minetest.formspec_escape(meta:get_int("time"))
|
||||
return "size[4,3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"field[0.3,1;4,1;time;"..label..";"..value.."]"..
|
||||
"button_exit[1,2.2;2,1;start;"..I("Start").."]"
|
||||
"button_exit[1,2.2;2,1;start;"..S("Start").."]"
|
||||
end
|
||||
|
||||
-- Used by the pairing tool
|
||||
@ -141,7 +138,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:delayer", {
|
||||
description = I("Signal Delayer"),
|
||||
description = S("Signal Delayer"),
|
||||
inventory_image = "signs_bot_delayer_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -181,7 +178,7 @@ minetest.register_node("signs_bot:delayer", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:delayer_loaded", {
|
||||
description = I("Signal Delayer"),
|
||||
description = S("Signal Delayer"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -212,7 +209,7 @@ minetest.register_node("signs_bot:delayer_loaded", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:delayer_on", {
|
||||
description = I("Signal Delayer"),
|
||||
description = S("Signal Delayer"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -264,12 +261,12 @@ minetest.register_lbm({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "delayer", {
|
||||
name = I("Signal Delayer"),
|
||||
name = S("Signal Delayer"),
|
||||
data = {
|
||||
item = "signs_bot:delayer",
|
||||
text = table.concat({
|
||||
I("Signals are forwarded delayed. Subsequent signals are queued."),
|
||||
I("The delay time can be configured."),
|
||||
S("Signals are forwarded delayed. Subsequent signals are queued."),
|
||||
S("The delay time can be configured."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
179
doc.lua
179
doc.lua
@ -1,13 +1,26 @@
|
||||
--[[
|
||||
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPLv3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Signs Bot: Bot Flap
|
||||
|
||||
]]--
|
||||
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
signs_bot.doc = {}
|
||||
|
||||
if not minetest.get_modpath("doc") then
|
||||
return
|
||||
end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local function formspec(data)
|
||||
if data.image then
|
||||
local image = "image["..(doc.FORMSPEC.ENTRY_WIDTH - 3)..",0;3,2;"..data.image.."]"
|
||||
@ -24,113 +37,113 @@ local function formspec(data)
|
||||
end
|
||||
|
||||
local start_doc = table.concat({
|
||||
I("After you have placed the Signs Bot Box, you can start the bot by means of the 'On' button in the box menu."),
|
||||
I("If the bot returns to its box right away, you will likely need to charge it with electrical energy (techage) first."),
|
||||
I("The bot then runs straight up until it reaches an obstacle (a step with two or more blocks up or down or a sign.)"),
|
||||
I("If the bot first reaches a sign it will execute the commands on the sign."),
|
||||
I("If the command(s) on the sign is e.g. 'turn_around', the bot turns and goes back."),
|
||||
I("In this case, the bot reaches his box again and turns off."),
|
||||
S("After you have placed the Signs Bot Box, you can start the bot by means of the 'On' button in the box menu."),
|
||||
S("If the bot returns to its box right away, you will likely need to charge it with electrical energy (techage) first."),
|
||||
S("The bot then runs straight up until it reaches an obstacle (a step with two or more blocks up or down or a sign.)"),
|
||||
S("If the bot first reaches a sign it will execute the commands on the sign."),
|
||||
S("If the command(s) on the sign is e.g. 'turn_around', the bot turns and goes back."),
|
||||
S("In this case, the bot reaches his box again and turns off."),
|
||||
"",
|
||||
I("The Signs Bot Box has an inventory with 6 stacks for signs and 8 stacks for other items (to be placed/dug by the bot)."),
|
||||
I("This inventory simulates the bot internal inventory."),
|
||||
I("That means you will only have access to the inventory if the bot is turned off ('sitting' in his box)."),
|
||||
S("The Signs Bot Box has an inventory with 6 stacks for signs and 8 stacks for other items (to be placed/dug by the bot)."),
|
||||
S("This inventory simulates the bot internal inventory."),
|
||||
S("That means you will only have access to the inventory if the bot is turned off ('sitting' in his box)."),
|
||||
}, "\n")
|
||||
|
||||
local control_doc = table.concat({
|
||||
I("You simply control the direction of the bot by means of the 'turn left' and 'turn right' signs (signs with the arrow)."),
|
||||
I("The bot can run over steps (one block up/down). But there are also commands to move the bot up and down."),
|
||||
S("You simply control the direction of the bot by means of the 'turn left' and 'turn right' signs (signs with the arrow)."),
|
||||
S("The bot can run over steps (one block up/down). But there are also commands to move the bot up and down."),
|
||||
"",
|
||||
I("It is not necessary to mark a way back to the box."),
|
||||
I("With the command 'turn_off' the bot will turn off and be back in his box from every position."),
|
||||
I("The same applies if you turn off the bot by the box menu."),
|
||||
I("If the bot reaches a sign from the wrong direction (from back or sides) the sign will be ignored."),
|
||||
I("The bot will walk over."),
|
||||
S("It is not necessary to mark a way back to the box."),
|
||||
S("With the command 'turn_off' the bot will turn off and be back in his box from every position."),
|
||||
S("The same applies if you turn off the bot by the box menu."),
|
||||
S("If the bot reaches a sign from the wrong direction (from back or sides) the sign will be ignored."),
|
||||
S("The bot will walk over."),
|
||||
"",
|
||||
I("All predefined signs have a menu with a list of the bot commands."),
|
||||
I("These signs can't be changed, but you can craft and program your own signs."),
|
||||
I("For this you have to use the 'command' sign."),
|
||||
I("This sign has an edit field for your commands and a help page with all available commands."),
|
||||
I("The help page has a copy button to simplify the programming."),
|
||||
S("All predefined signs have a menu with a list of the bot commands."),
|
||||
S("These signs can't be changed, but you can craft and program your own signs."),
|
||||
S("For this you have to use the 'command' sign."),
|
||||
S("This sign has an edit field for your commands and a help page with all available commands."),
|
||||
S("The help page has a copy button to simplify the programming."),
|
||||
"",
|
||||
I("Also for your own signs it is important to know:"),
|
||||
I("After the execution of the last command of the sign, the bot falls back into its default behaviour and runs in its taken direction."),
|
||||
S("Also for your own signs it is important to know:"),
|
||||
S("After the execution of the last command of the sign, the bot falls back into its default behaviour and runs in its taken direction."),
|
||||
"",
|
||||
I("A standard job for the bot is to move items from one chest to another"),
|
||||
I("(chest or node with a chest like inventory)."),
|
||||
I("This can be done by means of the two signs 'take item' and 'add item'."),
|
||||
I("These signs have to be placed on top of chest nodes."),
|
||||
S("A standard job for the bot is to move items from one chest to another"),
|
||||
S("(chest or node with a chest like inventory)."),
|
||||
S("This can be done by means of the two signs 'take item' and 'add item'."),
|
||||
S("These signs have to be placed on top of chest nodes."),
|
||||
}, "\n")
|
||||
|
||||
local sensor_doc = table.concat({
|
||||
I("In addition to the signs the bot can be controlled by means of sensors."),
|
||||
I("Sensors like the Bot Sensor have two states: on and off."),
|
||||
I("If the Bot Sensor detects a bot it will switch to the state 'on' and"),
|
||||
I("sends a signal to a connected block, called an actuator."),
|
||||
S("In addition to the signs the bot can be controlled by means of sensors."),
|
||||
S("Sensors like the Bot Sensor have two states: on and off."),
|
||||
S("If the Bot Sensor detects a bot it will switch to the state 'on' and"),
|
||||
S("sends a signal to a connected block, called an actuator."),
|
||||
"",
|
||||
I("Sensors are:"),
|
||||
I("- Bot Sensor: Sends a signal when the robot passes by"),
|
||||
I("- Node Sensor: Sends a signal when it detects any node"),
|
||||
I("- Crop Sensor: Sends a signal when, for example wheat is fully grown"),
|
||||
I("- Bot Chest: Sends a signal depending on the chest state (empty, full)"),
|
||||
S("Sensors are:"),
|
||||
S("- Bot Sensor: Sends a signal when the robot passes by"),
|
||||
S("- Node Sensor: Sends a signal when it detects any node"),
|
||||
S("- Crop Sensor: Sends a signal when, for example wheat is fully grown"),
|
||||
S("- Bot Chest: Sends a signal depending on the chest state (empty, full)"),
|
||||
"",
|
||||
I("Actuators are:"),
|
||||
I("- Signs Bot Box: Can turn the bot off and on"),
|
||||
I("- Control Unit: Can be used to exchange the sign to lead the bot"),
|
||||
S("Actuators are:"),
|
||||
S("- Signs Bot Box: Can turn the bot off and on"),
|
||||
S("- Control Unit: Can be used to exchange the sign to lead the bot"),
|
||||
"",
|
||||
I("Additional sensors and actuator can be added by other mods."),
|
||||
S("Additional sensors and actuator can be added by other mods."),
|
||||
}, "\n")
|
||||
|
||||
|
||||
local tool_doc = table.concat({
|
||||
I("To send a signal from a sensor to an actuator, the sensor has to be connected (paired) with actuator."),
|
||||
I("To connect sensor and actuator, the Sensor Connection Tool has to be used."),
|
||||
I("Simply click with the tool on both blocks and the sensor will be connected with the actuator."),
|
||||
I("A successful connection is indicated by a ping/pong noise."),
|
||||
S("To send a signal from a sensor to an actuator, the sensor has to be connected (paired) with actuator."),
|
||||
S("To connect sensor and actuator, the Sensor Connection Tool has to be used."),
|
||||
S("Simply click with the tool on both blocks and the sensor will be connected with the actuator."),
|
||||
S("A successful connection is indicated by a ping/pong noise."),
|
||||
"",
|
||||
I("Before you connect sensor with actuator, take care that the actuator is in the requested state."),
|
||||
I("For example: If you want to start the Bot with a sensor, connect the sensor with the Bot Box,"),
|
||||
I("when the Bot is in the state 'on'. Otherwise the sensor signal will stop the Bot,"),
|
||||
I("instead of starting it."),
|
||||
S("Before you connect sensor with actuator, take care that the actuator is in the requested state."),
|
||||
S("For example: If you want to start the Bot with a sensor, connect the sensor with the Bot Box,"),
|
||||
S("when the Bot is in the state 'on'. Otherwise the sensor signal will stop the Bot,"),
|
||||
S("instead of starting it."),
|
||||
}, "\n")
|
||||
|
||||
|
||||
local inventory_doc = table.concat({
|
||||
I("The following applies to all commands that are used to place items in the bot inventory, like:"),
|
||||
S("The following applies to all commands that are used to place items in the bot inventory, like:"),
|
||||
"",
|
||||
I("- take_item <num> <slot>"),
|
||||
I("- pickup_items <slot>"),
|
||||
I("- trash_sign <slot>"),
|
||||
I("- harvest <slot>"),
|
||||
I("- dig_front <slot> <lvl>"),
|
||||
I("- dig_left <slot> <lvl>"),
|
||||
I("- dig_right <slot> <lvl>"),
|
||||
I("- dig_below <slot> <lvl>"),
|
||||
I("- dig_above <slot> <lvl>"),
|
||||
S("- take_item <num> <slot>"),
|
||||
S("- pickup_items <slot>"),
|
||||
S("- trash_sign <slot>"),
|
||||
S("- harvest <slot>"),
|
||||
S("- dig_front <slot> <lvl>"),
|
||||
S("- dig_left <slot> <lvl>"),
|
||||
S("- dig_right <slot> <lvl>"),
|
||||
S("- dig_below <slot> <lvl>"),
|
||||
S("- dig_above <slot> <lvl>"),
|
||||
"",
|
||||
I("If no slot or slot 0 was specified with the command (case A), all 8 slots of the bot inventory "),
|
||||
I("are checked one after the other. If a slot was specified (case B), only this slot is checked."),
|
||||
I("In both cases the following applies: If the slot is preconfigured and fits the item, "),
|
||||
I("or if the slot is not configured and empty, or is only partially filled with the item type "),
|
||||
I("(which should be added), then the items are added."),
|
||||
I("If not all items can be added, the remaining slots will be tried out in case A."),
|
||||
I("Anything that could not be added to your own inventory goes back."),
|
||||
S("If no slot or slot 0 was specified with the command (case A), all 8 slots of the bot inventory "),
|
||||
S("are checked one after the other. If a slot was specified (case B), only this slot is checked."),
|
||||
S("In both cases the following applies: If the slot is preconfigured and fits the item, "),
|
||||
S("or if the slot is not configured and empty, or is only partially filled with the item type "),
|
||||
S("(which should be added), then the items are added."),
|
||||
S("If not all items can be added, the remaining slots will be tried out in case A."),
|
||||
S("Anything that could not be added to your own inventory goes back."),
|
||||
"",
|
||||
I("The following applies to all commands that are used to take items from the bot inventory, like:"),
|
||||
S("The following applies to all commands that are used to take items from the bot inventory, like:"),
|
||||
"",
|
||||
I("- add_item <num> <slot>"),
|
||||
S("- add_item <num> <slot>"),
|
||||
"",
|
||||
I("It doesn't matter whether a slot is configured or not. The bot takes the first stack that "),
|
||||
I("it can find from its own inventory and tries to use it."),
|
||||
I("If a slot is specified, it only takes this, if no slot has been specified, it checks all of "),
|
||||
I("them one after the other, starting from slot 1 until it finds something."),
|
||||
I("If the number found is smaller than requested, he tries to take the rest out of any slot."),
|
||||
S("It doesn't matter whether a slot is configured or not. The bot takes the first stack that "),
|
||||
S("it can find from its own inventory and tries to use it."),
|
||||
S("If a slot is specified, it only takes this, if no slot has been specified, it checks all of "),
|
||||
S("them one after the other, starting from slot 1 until it finds something."),
|
||||
S("If the number found is smaller than requested, he tries to take the rest out of any slot."),
|
||||
}, "\n")
|
||||
|
||||
|
||||
doc.add_category("signs_bot",
|
||||
{
|
||||
name = I("Signs Bot"),
|
||||
description = I("A robot controlled by signs, used for automated work"),
|
||||
name = S("Signs Bot"),
|
||||
description = S("A robot controlled by signs, used for automated work"),
|
||||
sorting = "custom",
|
||||
sorting_data = {"start", "control", "sensor_doc", "tool",
|
||||
"box", "bot_flap", "duplicator",
|
||||
@ -142,26 +155,26 @@ doc.add_category("signs_bot",
|
||||
})
|
||||
|
||||
doc.add_entry("signs_bot", "start", {
|
||||
name = I("Start the Bot"),
|
||||
name = S("Start the Bot"),
|
||||
data = {text = start_doc, image = "signs_bot_doc_image.png"},
|
||||
})
|
||||
|
||||
doc.add_entry("signs_bot", "control", {
|
||||
name = I("Control the Bot"),
|
||||
name = S("Control the Bot"),
|
||||
data = {text = control_doc, image = "signs_bot_doc_image.png"},
|
||||
})
|
||||
|
||||
doc.add_entry("signs_bot", "sensor_doc", {
|
||||
name = I("Sensors and Actuators"),
|
||||
name = S("Sensors and Actuators"),
|
||||
data = {text = sensor_doc, image = "signs_bot_doc_image.png"},
|
||||
})
|
||||
|
||||
doc.add_entry("signs_bot", "tool", {
|
||||
name = I("Connecting sensors and actuator"),
|
||||
name = S("Connecting sensors and actuator"),
|
||||
data = {text = tool_doc, image = "signs_bot_doc_image.png"},
|
||||
})
|
||||
|
||||
doc.add_entry("signs_bot", "tool", {
|
||||
name = I("Bot inventory behavior"),
|
||||
name = S("Bot inventory behavior"),
|
||||
data = {text = inventory_doc, image = "signs_bot_doc_image.png"},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -27,15 +24,15 @@ local formspec = "size[8,7.3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[0.3,0;"..I("Input:").."]"..
|
||||
"list[context;inp;3,0;1,1;]"..
|
||||
"label[0.3,1;"..I("Template:").."]"..
|
||||
"list[context;temp;3,1;1,1;]"..
|
||||
"label[0.3,2;"..I("Output:").."]"..
|
||||
"list[context;outp;3,2;1,1;]"..
|
||||
"label[4,0;"..I("1. Place one 'cmnd' sign to be\n used as template.\n")..
|
||||
I("2. Add 'blank signs' to\n the input inventory.\n")..
|
||||
I("3. Take the copies\n from the output inventory.").."]"..
|
||||
"label[0.1,0.2;"..S("Template:").."]"..
|
||||
"list[context;temp;2,0;1,1;]"..
|
||||
"label[0.1,1.2;"..S("Input:").."]"..
|
||||
"list[context;inp;2,1;1,1;]"..
|
||||
"label[0.1,2.2;"..S("Output:").."]"..
|
||||
"list[context;outp;2,2;1,1;]"..
|
||||
"label[3,0.2;"..S("1. Place one 'cmnd' sign").."]"..
|
||||
"label[3,1.2;"..S("2. Add 'blank signs'").."]"..
|
||||
"label[3,2.2;"..S("3. Take the copies").."]"..
|
||||
"list[current_player;main;0,3.5;8,4;]"..
|
||||
"listring[context;inp]"..
|
||||
"listring[current_player;main]"..
|
||||
@ -108,7 +105,7 @@ local function on_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:duplicator", {
|
||||
description = I("Signs Duplicator"),
|
||||
description = S("Signs Duplicator"),
|
||||
stack_max = 1,
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
@ -167,7 +164,7 @@ local function formspec_user(cmnd)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:sign_user", {
|
||||
description = I('Sign "user"'),
|
||||
description = S('Sign "user"'),
|
||||
drawtype = "nodebox",
|
||||
inventory_image = "signs_bot_sign_user.png",
|
||||
node_box = {
|
||||
@ -210,7 +207,7 @@ minetest.register_node("signs_bot:sign_user", {
|
||||
|
||||
signs_bot.register_sign({
|
||||
name = "sign_blank",
|
||||
description = I('Sign "blank"'),
|
||||
description = S('Sign "blank"'),
|
||||
commands = "",
|
||||
image = "signs_bot_sign_blank.png",
|
||||
})
|
||||
@ -226,17 +223,17 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "duplicator", {
|
||||
name = I("Signs Duplicator"),
|
||||
name = S("Signs Duplicator"),
|
||||
data = {
|
||||
item = "signs_bot:duplicator",
|
||||
text = table.concat({
|
||||
I("The Duplicator can be used to make copies of signs."),
|
||||
I("1. Put one 'cmnd' sign to be used as template into the 'Template' inventory"),
|
||||
I("2. Add one or several 'blank signs' to the 'Input' inventory."),
|
||||
I("3. Take the copies from the 'Output' inventory."),
|
||||
S("The Duplicator can be used to make copies of signs."),
|
||||
S("1. Put one 'cmnd' sign to be used as template into the 'Template' inventory"),
|
||||
S("2. Add one or several 'blank signs' to the 'Input' inventory."),
|
||||
S("3. Take the copies from the 'Output' inventory."),
|
||||
"",
|
||||
I("Written books [default:book_written] can alternatively be used as template"),
|
||||
I("Already written signs can be used as input, too."),
|
||||
S("Written books [default:book_written] can alternatively be used as template"),
|
||||
S("Already written signs can be used as input, too."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
@ -244,10 +241,10 @@ end
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "sign_blank", {
|
||||
name = I('Sign "blank"'),
|
||||
name = S('Sign "blank"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_blank",
|
||||
text = I("Needed as input for the Duplicator.")
|
||||
text = S("Needed as input for the Duplicator.")
|
||||
},
|
||||
})
|
||||
end
|
||||
|
28
extender.lua
28
extender.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,22 +13,18 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local lib = signs_bot.lib
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
M(pos):set_string("infotext", I("Sensor Extender: Connected with ")..S(dest_pos).." / "..cmnd)
|
||||
M(pos):set_string("infotext", S("Sensor Extender: Connected with").." "..P2S(dest_pos).." / "..cmnd)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:sensor_extender", {
|
||||
description = I("Sensor Extender"),
|
||||
description = S("Sensor Extender"),
|
||||
inventory_image = "signs_bot_extender_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -54,7 +50,7 @@ minetest.register_node("signs_bot:sensor_extender", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
meta:set_string("infotext", I("Sensor Extender: Not connected"))
|
||||
meta:set_string("infotext", S("Sensor Extender: Not connected"))
|
||||
end,
|
||||
|
||||
update_infotext = update_infotext,
|
||||
@ -69,7 +65,7 @@ minetest.register_node("signs_bot:sensor_extender", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:sensor_extender_on", {
|
||||
description = I("Sensor Extender"),
|
||||
description = S("Sensor Extender"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
@ -129,13 +125,13 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "sensor_extender", {
|
||||
name = I("Sensor Extender"),
|
||||
name = S("Sensor Extender"),
|
||||
data = {
|
||||
item = "signs_bot:sensor_extender",
|
||||
text = table.concat({
|
||||
I("With the Sensor Extender, sensor signals can be sent to more than one actuator."),
|
||||
I("Place one or more extender nearby the sensor and connect each extender"),
|
||||
I("with one further actuator by means of the Connection Tool."),
|
||||
S("With the Sensor Extender, sensor signals can be sent to more than one actuator."),
|
||||
S("Place one or more extender nearby the sensor and connect each extender"),
|
||||
S("with one further actuator by means of the Connection Tool."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
7
init.lua
7
init.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -15,7 +15,7 @@
|
||||
signs_bot = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
signs_bot.version = 1.05
|
||||
signs_bot.version = 1.06
|
||||
|
||||
if minetest.global_exists("techage") and techage.version < 0.25 then
|
||||
error("[signs_bot] Signs Bot requires techage version 0.25 or newer!")
|
||||
@ -25,8 +25,11 @@ if tubelib2.version < 1.9 then
|
||||
error("[signs_bot] Signs Bot requires tubelib2 version 1.9 or newer!")
|
||||
end
|
||||
|
||||
-- Load support for I18n.
|
||||
signs_bot.S = minetest.get_translator("signs_bot")
|
||||
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
|
||||
dofile(MP.."/doc.lua")
|
||||
dofile(MP.."/random.lua")
|
||||
dofile(MP.."/lib.lua")
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,9 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local MAX_SIZE = 1000 -- max number of tokens
|
||||
|
||||
@ -235,29 +234,29 @@ function api.check_script(script)
|
||||
if tCmdDef[cmnd] then
|
||||
num_token = num_token + 1 + tCmdDef[cmnd].num_param
|
||||
if num_token > MAX_SIZE then
|
||||
return false, I("Maximum programm size exceeded"), idx
|
||||
return false, S("Maximum programm size exceeded"), idx
|
||||
end
|
||||
param1 = tonumber(param1) or param1
|
||||
param2 = tonumber(param2) or param2
|
||||
param3 = tonumber(param3) or param3
|
||||
local num_param = (param1 and 1 or 0) + (param2 and 1 or 0) + (param3 and 1 or 0)
|
||||
if tCmdDef[cmnd].num_param < num_param then
|
||||
return false, I("Too many parameters"), idx
|
||||
return false, S("Too many parameters"), idx
|
||||
end
|
||||
if tCmdDef[cmnd].num_param > 0 and not tCmdDef[cmnd].check(param1, param2, param3) then
|
||||
return false, I("Parameter error"), idx
|
||||
return false, S("Parameter error"), idx
|
||||
end
|
||||
elseif not cmnd:find("%w+:") then
|
||||
return false, I("Command error"), idx
|
||||
return false, S("Command error"), idx
|
||||
end
|
||||
tbl[cmnd] = (tbl[cmnd] or 0) + 1
|
||||
end
|
||||
if (tbl["end"] or 0) > (tbl["repeat"] or 0) then
|
||||
return false, I("'repeat' missing"), 0
|
||||
return false, S("'repeat' missing"), 0
|
||||
elseif (tbl["end"] or 0) < (tbl["repeat"] or 0) then
|
||||
return false, I("'end' missing"), 0
|
||||
return false, S("'end' missing"), 0
|
||||
end
|
||||
return true, I("Checked and approved"), 0
|
||||
return true, S("Checked and approved"), 0
|
||||
end
|
||||
|
||||
-- function returns: true/false, error-string
|
||||
|
45
intllib.lua
45
intllib.lua
@ -1,45 +0,0 @@
|
||||
|
||||
-- Fallback functions for when `intllib` is not installed.
|
||||
-- Code released under Unlicense <http://unlicense.org>.
|
||||
|
||||
-- Get the latest version of this file at:
|
||||
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||
|
||||
local function format(str, ...)
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
end
|
||||
|
||||
local gettext, ngettext
|
||||
if minetest.get_modpath("intllib") then
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
end
|
||||
|
||||
-- Fill in missing functions.
|
||||
|
||||
gettext = gettext or function(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
end
|
||||
|
||||
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
end
|
||||
|
||||
return gettext, ngettext
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,8 +13,6 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
signs_bot.register_inventory({"default:chest", "default:chest_open"}, {
|
||||
|
4
lib.lua
4
lib.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,8 +13,6 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
signs_bot.lib = {}
|
||||
|
BIN
locale/de.mo
BIN
locale/de.mo
Binary file not shown.
1705
locale/de.po
1705
locale/de.po
File diff suppressed because it is too large
Load Diff
1704
locale/de.po~
1704
locale/de.po~
File diff suppressed because it is too large
Load Diff
1376
locale/template.pot
1376
locale/template.pot
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,13 +13,12 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -38,12 +37,12 @@ end
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local text = table.concat({
|
||||
I("Signal AND with"),
|
||||
S("Signal AND with"),
|
||||
#mem.inputs or 0,
|
||||
I("inputs"),
|
||||
S("inputs"),
|
||||
":",
|
||||
I("Connected with"),
|
||||
S(dest_pos),
|
||||
S("Connected with"),
|
||||
P2S(dest_pos),
|
||||
"/",
|
||||
cmnd,
|
||||
":",
|
||||
@ -80,7 +79,7 @@ local function infotext(pos)
|
||||
local dest_pos = meta:get_string("signal_pos")
|
||||
local signal = meta:get_string("signal_data")
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
update_infotext(pos, P(dest_pos), signal)
|
||||
update_infotext(pos, S2P(dest_pos), signal)
|
||||
end
|
||||
end
|
||||
|
||||
@ -143,7 +142,7 @@ local function signs_bot_on_signal(pos, node, signal)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:and1", {
|
||||
description = I("Signal AND"),
|
||||
description = S("Signal AND"),
|
||||
inventory_image = "signs_bot_and_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -179,7 +178,7 @@ minetest.register_node("signs_bot:and1", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:and2", {
|
||||
description = I("Signal AND"),
|
||||
description = S("Signal AND"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -208,7 +207,7 @@ minetest.register_node("signs_bot:and2", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:and3", {
|
||||
description = I("Signal AND"),
|
||||
description = S("Signal AND"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -245,11 +244,11 @@ minetest.register_craft({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "and", {
|
||||
name = I("Signal AND"),
|
||||
name = S("Signal AND"),
|
||||
data = {
|
||||
item = "signs_bot:and1",
|
||||
text = table.concat({
|
||||
I("Signal is sent, if all input signals are received."),
|
||||
S("Signal is sent, if all input signals are received."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,20 +13,18 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
M(pos):set_string("infotext", I("Node Sensor: Connected with ")..S(dest_pos).." / "..cmnd)
|
||||
M(pos):set_string("infotext", S("Node Sensor: Connected with ")..P2S(dest_pos).." / "..cmnd)
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
@ -44,20 +42,20 @@ end
|
||||
|
||||
|
||||
local DropdownValues = {
|
||||
[I("added")] = 1,
|
||||
[I("removed")] = 2,
|
||||
[I("added or removed")] = 3,
|
||||
[S("added")] = 1,
|
||||
[S("removed")] = 2,
|
||||
[S("added or removed")] = 3,
|
||||
}
|
||||
|
||||
local function formspec(mem)
|
||||
local label = I("added")..","..I("removed")..","..I("added or removed")
|
||||
local label = S("added")..","..S("removed")..","..S("added or removed")
|
||||
return "size[6,3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[0.2,0.4;"..I("Send signal if nodes have been:").."]"..
|
||||
"label[0.2,0.4;"..S("Send signal if nodes have been:").."]"..
|
||||
"dropdown[0.2,1;6,1;mode;"..label..";"..(mem.mode or 3).."]"..
|
||||
"button_exit[1.5,2.2;3,1;accept;"..I("accept").."]"
|
||||
"button_exit[1.5,2.2;3,1;accept;"..S("accept").."]"
|
||||
end
|
||||
|
||||
local function any_node_changed(pos)
|
||||
@ -115,7 +113,7 @@ local function node_timer(pos)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:node_sensor", {
|
||||
description = I("Node Sensor"),
|
||||
description = S("Node Sensor"),
|
||||
inventory_image = "signs_bot_sensor_node_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -137,7 +135,7 @@ minetest.register_node("signs_bot:node_sensor", {
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
meta:set_string("infotext", "Node Sensor: Not connected")
|
||||
meta:set_string("infotext", S("Node Sensor: Not connected"))
|
||||
mem.mode = 3 -- default legacy mode
|
||||
meta:set_string("formspec", formspec(mem))
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
@ -158,7 +156,7 @@ minetest.register_node("signs_bot:node_sensor", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:node_sensor_on", {
|
||||
description = I("Node Sensor"),
|
||||
description = S("Node Sensor"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -215,15 +213,15 @@ minetest.register_lbm({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "node_sensor", {
|
||||
name = I("Node Sensor"),
|
||||
name = S("Node Sensor"),
|
||||
data = {
|
||||
item = "signs_bot:node_sensor",
|
||||
text = table.concat({
|
||||
I("The node sensor sends cyclical signals when it detects that nodes have appeared or disappeared,"),
|
||||
I("but has to be configured accordingly."),
|
||||
I("Valid nodes are all kind of blocks and plants."),
|
||||
I("The sensor range is 3 nodes/meters in one direction."),
|
||||
I("The sensor has an active side (red) that must point to the observed area."),
|
||||
S("The node sensor sends cyclical signals when it detects that nodes have appeared or disappeared,"),
|
||||
S("but has to be configured accordingly."),
|
||||
S("Valid nodes are all kind of blocks and plants."),
|
||||
S("The sensor range is 3 nodes/meters in one direction."),
|
||||
S("The sensor has an active side (red) that must point to the observed area."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,11 +12,6 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
-- Called when robot is started
|
||||
|
12
signal.lua
12
signal.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,12 +13,10 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
-- Used by the pairing tool
|
||||
function signs_bot.get_node_type(pos)
|
||||
local node = tubelib2.get_node_lvm(pos)
|
||||
@ -50,7 +48,7 @@ end
|
||||
function signs_bot.store_signal(sensor_pos, dest_pos, signal)
|
||||
local meta = sensor_pos and M(sensor_pos)
|
||||
if meta then
|
||||
meta:set_string("signal_pos", S(dest_pos))
|
||||
meta:set_string("signal_pos", P2S(dest_pos))
|
||||
meta:set_string("signal_data", signal)
|
||||
end
|
||||
end
|
||||
@ -64,7 +62,7 @@ function signs_bot.send_signal(sensor_pos)
|
||||
local dest_pos = meta:get_string("signal_pos")
|
||||
local signal = meta:get_string("signal_data")
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
local pos = P(dest_pos)
|
||||
local pos = S2P(dest_pos)
|
||||
local node = tubelib2.get_node_lvm(pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if ndef and ndef.signs_bot_on_signal then
|
||||
|
62
signs.lua
62
signs.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local function formspec(cmnd)
|
||||
cmnd = minetest.formspec_escape(cmnd)
|
||||
@ -73,7 +67,7 @@ signs_bot.register_sign = register_sign
|
||||
|
||||
register_sign({
|
||||
name = "sign_right",
|
||||
description = I('Sign "turn right"'),
|
||||
description = S('Sign "turn right"'),
|
||||
commands = "turn_right",
|
||||
image = "signs_bot_sign_right.png",
|
||||
})
|
||||
@ -89,7 +83,7 @@ minetest.register_craft({
|
||||
|
||||
register_sign({
|
||||
name = "sign_left",
|
||||
description = I('Sign "turn left"'),
|
||||
description = S('Sign "turn left"'),
|
||||
commands = "turn_left",
|
||||
image = "signs_bot_sign_left.png",
|
||||
})
|
||||
@ -105,7 +99,7 @@ minetest.register_craft({
|
||||
|
||||
register_sign({
|
||||
name = "sign_take",
|
||||
description = I('Sign "take item"'),
|
||||
description = S('Sign "take item"'),
|
||||
commands = "take_item 99\nturn_around",
|
||||
image = "signs_bot_sign_take.png",
|
||||
})
|
||||
@ -121,7 +115,7 @@ minetest.register_craft({
|
||||
|
||||
register_sign({
|
||||
name = "sign_add",
|
||||
description = I('Sign "add item"'),
|
||||
description = S('Sign "add item"'),
|
||||
commands = "add_item 99\nturn_around",
|
||||
image = "signs_bot_sign_add.png",
|
||||
})
|
||||
@ -137,7 +131,7 @@ minetest.register_craft({
|
||||
|
||||
register_sign({
|
||||
name = "sign_stop",
|
||||
description = I('Sign "stop"'),
|
||||
description = S('Sign "stop"'),
|
||||
commands = "stop",
|
||||
image = "signs_bot_sign_stop.png",
|
||||
})
|
||||
@ -154,7 +148,7 @@ minetest.register_craft({
|
||||
if minetest.get_modpath("minecart") then
|
||||
register_sign({
|
||||
name = "sign_add_cart",
|
||||
description = I('Sign "add to cart"'),
|
||||
description = S('Sign "add to cart"'),
|
||||
commands = "drop_items 99 1\npunch_cart\nturn_around",
|
||||
image = "signs_bot_sign_add_cart.png",
|
||||
})
|
||||
@ -170,7 +164,7 @@ if minetest.get_modpath("minecart") then
|
||||
|
||||
register_sign({
|
||||
name = "sign_take_cart",
|
||||
description = I('Sign "take from cart"'),
|
||||
description = S('Sign "take from cart"'),
|
||||
commands = "pickup_items 1\npunch_cart\nturn_around",
|
||||
image = "signs_bot_sign_take_cart.png",
|
||||
})
|
||||
@ -187,66 +181,66 @@ end
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "sign_right", {
|
||||
name = I('Sign "turn right"'),
|
||||
name = S('Sign "turn right"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_right",
|
||||
text = I("The Bot turns right when it detects this sign in front of it.")
|
||||
text = S("The Bot turns right when it detects this sign in front of it.")
|
||||
},
|
||||
})
|
||||
doc.add_entry("signs_bot", "sign_left", {
|
||||
name = I('Sign "turn left"'),
|
||||
name = S('Sign "turn left"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_left",
|
||||
text = I("The Bot turns left when it detects this sign in front of it.")
|
||||
text = S("The Bot turns left when it detects this sign in front of it.")
|
||||
},
|
||||
})
|
||||
doc.add_entry("signs_bot", "sign_take", {
|
||||
name = I('Sign "take item"'),
|
||||
name = S('Sign "take item"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_take",
|
||||
text = table.concat({
|
||||
I("The Bot takes items out of a chest in front of it and then turns around."),
|
||||
I("This sign has to be placed on top of the chest."),
|
||||
S("The Bot takes items out of a chest in front of it and then turns around."),
|
||||
S("This sign has to be placed on top of the chest."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
doc.add_entry("signs_bot", "sign_add", {
|
||||
name = I('Sign "add item"'),
|
||||
name = S('Sign "add item"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_add",
|
||||
text = table.concat({
|
||||
I("The Bot puts items into a chest in front of it and then turns around."),
|
||||
I("This sign has to be placed on top of the chest."),
|
||||
S("The Bot puts items into a chest in front of it and then turns around."),
|
||||
S("This sign has to be placed on top of the chest."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
doc.add_entry("signs_bot", "sign_stop", {
|
||||
name = I('Sign "stop"'),
|
||||
name = S('Sign "stop"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_stop",
|
||||
text = I("The Bot will stop in front of this sign until the sign is removed or the bot is turned off.")
|
||||
text = S("The Bot will stop in front of this sign until the sign is removed or the bot is turned off.")
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("doc") and minetest.get_modpath("minecart") then
|
||||
doc.add_entry("signs_bot", "sign_add_cart", {
|
||||
name = I('Sign "add to cart"'),
|
||||
name = S('Sign "add to cart"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_add_cart",
|
||||
text = table.concat({
|
||||
I("The Bot puts items into a minecart in front of it, pushes the cart and then turns around."),
|
||||
I("This sign has to be placed on top of the rail at the cart end position."),
|
||||
S("The Bot puts items into a minecart in front of it, pushes the cart and then turns around."),
|
||||
S("This sign has to be placed on top of the rail at the cart end position."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
doc.add_entry("signs_bot", "sign_take_cart", {
|
||||
name = I('Sign "take from cart"'),
|
||||
name = S('Sign "take from cart"'),
|
||||
data = {
|
||||
item = "signs_bot:sign_take_cart",
|
||||
text = table.concat({
|
||||
I("The Bot takes items out of a minecart in front of it, pushes the cart and then turns around."),
|
||||
I("This sign has to be placed on top of the rail at the cart end position."),
|
||||
S("The Bot takes items out of a minecart in front of it, pushes the cart and then turns around."),
|
||||
S("This sign has to be placed on top of the rail at the cart end position."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
19
techage.lua
19
techage.lua
@ -1,6 +1,19 @@
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
--[[
|
||||
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPLv3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Signs Bot: Bot Flap
|
||||
|
||||
]]--
|
||||
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
|
||||
|
43
timer.lua
43
timer.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -13,18 +13,15 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local S2P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
local function update_infotext(pos, dest_pos, cmnd)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
@ -32,11 +29,11 @@ local function update_infotext(pos, dest_pos, cmnd)
|
||||
local cycle_time = meta:get_int("cycle_time")
|
||||
local text
|
||||
if cycle_time > 0 then
|
||||
text = I("Bot Timer").." ("..rest.."/"..cycle_time.." min): "..I("Connected with")
|
||||
text = S("Bot Timer").." ("..rest.."/"..cycle_time.." min): "..S("Connected with")
|
||||
else
|
||||
text = I("Bot Timer").." (-- min): "..I("Connected with")
|
||||
text = S("Bot Timer").." (-- min): "..S("Connected with")
|
||||
end
|
||||
meta:set_string("infotext", text.." "..S(dest_pos).." / "..(cmnd or "none").." ")
|
||||
meta:set_string("infotext", text.." "..P2S(dest_pos).." / "..(cmnd or "none").." ")
|
||||
end
|
||||
|
||||
local function update_infotext_local(pos)
|
||||
@ -50,7 +47,7 @@ local function update_infotext_local(pos)
|
||||
local text2 = "Not connected"
|
||||
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
text2 = I("Connected with").." "..dest_pos.." / "..signal
|
||||
text2 = S("Connected with").." "..dest_pos.." / "..signal
|
||||
end
|
||||
if cycle_time > 0 then
|
||||
text1 = " ("..rest.."/"..cycle_time.." min): "
|
||||
@ -59,19 +56,19 @@ local function update_infotext_local(pos)
|
||||
mem.running = true
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
meta:set_string("infotext", I("Bot Timer")..text1..text2.." ")
|
||||
meta:set_string("infotext", S("Bot Timer")..text1..text2.." ")
|
||||
end
|
||||
|
||||
|
||||
local function formspec(meta)
|
||||
local label = minetest.formspec_escape(I("Cycle time [min]:"))
|
||||
local label = minetest.formspec_escape(S("Cycle time [min]:"))
|
||||
local value = minetest.formspec_escape(meta:get_int("cycle_time"))
|
||||
return "size[4,3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"field[0.3,1;4,1;time;"..label..";"..value.."]"..
|
||||
"button_exit[1,2.2;2,1;start;"..I("Start").."]"
|
||||
"button_exit[1,2.2;2,1;start;"..S("Start").."]"
|
||||
end
|
||||
|
||||
-- switch to normal texture
|
||||
@ -91,7 +88,7 @@ local function node_timer(pos)
|
||||
local dest_pos = meta:get_string("signal_pos")
|
||||
local signal = meta:get_string("signal_data")
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
update_infotext(pos, P(dest_pos), signal)
|
||||
update_infotext(pos, S2P(dest_pos), signal)
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -106,7 +103,7 @@ local function node_timer(pos)
|
||||
local dest_pos = meta:get_string("signal_pos")
|
||||
local signal = meta:get_string("signal_data")
|
||||
if dest_pos ~= "" and signal ~= "" then
|
||||
update_infotext(pos, P(dest_pos), signal)
|
||||
update_infotext(pos, S2P(dest_pos), signal)
|
||||
end
|
||||
end
|
||||
return mem.time > 0
|
||||
@ -134,7 +131,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
|
||||
minetest.register_node("signs_bot:timer", {
|
||||
description = I("Bot Timer"),
|
||||
description = S("Bot Timer"),
|
||||
inventory_image = "signs_bot_timer_inv.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -151,7 +148,7 @@ minetest.register_node("signs_bot:timer", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
meta:set_string("infotext", "Bot Timer: Not connected")
|
||||
meta:set_string("infotext", S("Bot Timer: Not connected"))
|
||||
meta:set_string("formspec", formspec(meta))
|
||||
end,
|
||||
|
||||
@ -169,7 +166,7 @@ minetest.register_node("signs_bot:timer", {
|
||||
})
|
||||
|
||||
minetest.register_node("signs_bot:timer_on", {
|
||||
description = I("Bot Timer"),
|
||||
description = S("Bot Timer"),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -220,12 +217,12 @@ minetest.register_lbm({
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry("signs_bot", "timer", {
|
||||
name = I("Bot Timer"),
|
||||
name = S("Bot Timer"),
|
||||
data = {
|
||||
item = "signs_bot:timer",
|
||||
text = table.concat({
|
||||
I("Special kind of sensor."),
|
||||
I("Can be programmed with a time in seconds, e.g. to start the bot cyclically."),
|
||||
S("Special kind of sensor."),
|
||||
S("Can be programmed with a time in seconds, e.g. to start the bot cyclically."),
|
||||
}, "\n")
|
||||
},
|
||||
})
|
||||
|
14
tool.lua
14
tool.lua
@ -3,7 +3,7 @@
|
||||
Signs Bot
|
||||
=========
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
@ -12,14 +12,8 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("signs_bot")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
-- Load support for I18n.
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
|
||||
@ -97,7 +91,7 @@ end
|
||||
|
||||
|
||||
minetest.register_node("signs_bot:connector", {
|
||||
description = I("Sensor Connection Tool"),
|
||||
description = S("Sensor Connection Tool"),
|
||||
inventory_image = "signs_bot_tool.png",
|
||||
wield_image = "signs_bot_tool.png",
|
||||
groups = {cracky=1, book=1},
|
||||
|
Loading…
x
Reference in New Issue
Block a user