Switch translation from intllib to minetest.translator

This commit is contained in:
Joachim Stolberg 2021-03-14 13:32:48 +01:00
parent 249340d5fd
commit c5be40a10f
40 changed files with 529 additions and 5412 deletions

View File

@ -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-06-21 v1.03 * Interpreter bugfixes, node and crop sensors changed
- 2020-10-01 v1.04 * Many improvements and bugfixes (Thanks to Thomas-S) - 2020-10-01 v1.04 * Many improvements and bugfixes (Thanks to Thomas-S)
- 2021-01-30 v1.05 * Many improvements and bugfixes - 2021-01-30 v1.05 * Many improvements and bugfixes
- 2021-03-14 v1.06 * Switch translation from intllib to minetest.translator

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,10 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -117,24 +114,24 @@ local function status(mem)
return mem.error return mem.error
end end
if mem.running then if mem.running then
return I("running") return S("running")
end end
if mem.charging then if mem.charging then
return I("charging") return S("charging")
end end
return I("stopped") return S("stopped")
end end
local function formspec(pos, mem) local function formspec(pos, mem)
mem.running = mem.running or false 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 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) local current_capa = mem.capa or (signs_bot.MAX_CAPA * 0.9)
return "size[9,8.2]".. return "size[9,8.2]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. 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]".. "image[0.6,0;1,1;signs_bot_form_mask.png]"..
bot.. bot..
preassigned_slots(pos).. 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]".. "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;]".. "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]".. "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.."]".. "button[0.2,2;1.5,1;"..cmnd.."]"..
"label[1,3.6;"..status(mem).."]".. "label[1,3.6;"..status(mem).."]"..
"list[current_player;main;0.5,4.4;8,4;]".. "list[current_player;main;0.5,4.4;8,4;]"..
@ -153,16 +150,16 @@ local function formspec(pos, mem)
"listring[current_player;main]" "listring[current_player;main]"
end end
local function formspec_cfg(pos, mem) local function formspec_cfg()
return "size[9,8.2]".. return "size[9,8.2]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. 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]".. "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;]".. "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]".. "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;]".. "list[current_player;main;0.5,4.4;8,4;]"..
"listring[context;filter]".. "listring[context;filter]"..
"listring[current_player;main]" "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 = techage.power.percent(signs_bot.MAX_CAPA, capa)
capa = (math.floor((capa or 0) / 5)) * 5 capa = (math.floor((capa or 0) / 5)) * 5
meta:set_int("capa", capa) meta:set_int("capa", capa)
local text = I("Robot Box ").." ("..capa.." %)" local text = S("Robot Box").." ("..capa.." %)"
meta:set_string("description", text) meta:set_string("description", text)
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()}) local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
local left_over = inv:add_item("main", node) local left_over = inv:add_item("main", node)
@ -195,7 +192,7 @@ function signs_bot.infotext(pos, state)
local meta = M(pos) local meta = M(pos)
local number = meta:get_string("number") local number = meta:get_string("number")
state = state or "<unknown>" state = state or "<unknown>"
meta:set_string("infotext", I("Robot Box ")..number..": "..state) meta:set_string("infotext", S("Robot Box").." "..number..": "..state)
end end
local function reset_robot(pos, mem) local function reset_robot(pos, mem)
@ -221,7 +218,7 @@ function signs_bot.start_robot(base_pos)
mem.capa = nil mem.capa = nil
end end
meta:set_string("formspec", formspec(base_pos, mem)) 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) reset_robot(base_pos, mem)
minetest.get_node_timer(base_pos):start(CYCLE_TIME) minetest.get_node_timer(base_pos):start(CYCLE_TIME)
return true return true
@ -240,9 +237,9 @@ function signs_bot.stop_robot(base_pos, mem)
mem.charging = false mem.charging = false
end end
if mem.power_available then if mem.power_available then
signs_bot.infotext(base_pos, I("charging")) signs_bot.infotext(base_pos, S("charging"))
else else
signs_bot.infotext(base_pos, I("stopped")) signs_bot.infotext(base_pos, S("stopped"))
end end
meta:set_string("formspec", formspec(base_pos, mem)) meta:set_string("formspec", formspec(base_pos, mem))
signs_bot.remove_robot(mem) signs_bot.remove_robot(mem)
@ -301,7 +298,7 @@ local function on_receive_fields(pos, formname, fields, player)
if fields.update then if fields.update then
meta:set_string("formspec", formspec(pos, mem)) meta:set_string("formspec", formspec(pos, mem))
elseif fields.config then elseif fields.config then
meta:set_string("formspec", formspec_cfg(pos, mem)) meta:set_string("formspec", formspec_cfg())
elseif fields.back then elseif fields.back then
meta:set_string("formspec", formspec(pos, mem)) meta:set_string("formspec", formspec(pos, mem))
elseif fields.start then elseif fields.start then
@ -399,7 +396,7 @@ local function on_nopower(pos)
end end
minetest.register_node("signs_bot:box", { minetest.register_node("signs_bot:box", {
description = I("Signs Bot Box"), description = S("Signs Bot Box"),
stack_max = 1, stack_max = 1,
tiles = { tiles = {
-- up, down, right, left, back, front -- 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("formspec", formspec(pos, mem))
meta:set_string("signs_bot_cmnd", "turn_off") meta:set_string("signs_bot_cmnd", "turn_off")
meta:set_int("err_code", 0) meta:set_int("err_code", 0)
signs_bot.infotext(pos, I("stopped")) signs_bot.infotext(pos, S("stopped"))
if minetest.global_exists("techage") then if minetest.global_exists("techage") then
techage.ElectricCable:after_place_node(pos) techage.ElectricCable:after_place_node(pos)
mem.capa = get_capa(itemstack) mem.capa = get_capa(itemstack)
@ -489,12 +486,12 @@ minetest.register_node("signs_bot:box", {
on_power = function(pos) on_power = function(pos)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
mem.power_available = true mem.power_available = true
signs_bot.infotext(pos, I("charging")) signs_bot.infotext(pos, S("charging"))
end, end,
on_nopower = function(pos) on_nopower = function(pos)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
mem.power_available = false mem.power_available = false
signs_bot.infotext(pos, I("no power")) signs_bot.infotext(pos, S("no power"))
end, end,
nominal = PWR_NEEDED, nominal = PWR_NEEDED,
} }
@ -532,22 +529,22 @@ end
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "box", { doc.add_entry("signs_bot", "box", {
name = I("Signs Bot Box"), name = S("Signs Bot Box"),
data = { data = {
item = "signs_bot:box", item = "signs_bot:box",
text = table.concat({ text = table.concat({
I("The Box is the housing of the bot."), S("The Box is the housing of the bot."),
I("Place the box and start the bot by means of the 'On' button."), S("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("If the mod techage is installed, the bot needs electrical power."),
"", "",
I("The bot leaves the box on the right side."), S("The bot leaves the box on the right side."),
I("It will not start, if this position is blocked."), 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."), S("The box inventory simulates the inventory of the bot."),
I("You will not be able to access the inventory, if the bot is running."), S("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 bot can carry up to 8 stacks and 6 signs with it."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPLv3 GPLv3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local function formspec(cmnd) local function formspec(cmnd)
cmnd = minetest.formspec_escape(cmnd) cmnd = minetest.formspec_escape(cmnd)
@ -28,7 +22,7 @@ local function formspec(cmnd)
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"label[0.3,0.3;"..cmnd.."]".. "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 end
local commands = [[dig_sign 6 local commands = [[dig_sign 6
@ -37,7 +31,7 @@ place_sign_behind 6
]] ]]
minetest.register_node("signs_bot:bot_flap", { minetest.register_node("signs_bot:bot_flap", {
description = "Bot Flap", description = S("Bot Flap"),
paramtype2 = "facedir", paramtype2 = "facedir",
tiles = { tiles = {
"signs_bot_bot_flap_top.png", "signs_bot_bot_flap_top.png",
@ -69,13 +63,13 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "bot_flap", { doc.add_entry("signs_bot", "bot_flap", {
name = I("Bot Flap"), name = S("Bot Flap"),
data = { data = {
item = "signs_bot:bot_flap", item = "signs_bot:bot_flap",
text = table.concat({ text = table.concat({
I("The flap is a simple block used as door for the bot."), S("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"), S("Place the flap in any wall, and the bot will automatically open"),
I("and close the flap as it passes through it."), S("and close the flap as it passes through it."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,22 +13,19 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib
local function update_infotext(pos, dest_pos, cmnd) 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 end
minetest.register_node("signs_bot:bot_sensor", { minetest.register_node("signs_bot:bot_sensor", {
description = I("Bot Sensor"), description = S("Bot Sensor"),
inventory_image = "signs_bot_sensor_bot_inv.png", inventory_image = "signs_bot_sensor_bot_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -49,7 +46,7 @@ minetest.register_node("signs_bot:bot_sensor", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) local meta = M(pos)
meta:set_string("infotext", I("Bot Sensor: Not connected")) meta:set_string("infotext", S("Bot Sensor: Not connected"))
end, end,
update_infotext = update_infotext, update_infotext = update_infotext,
@ -64,7 +61,7 @@ minetest.register_node("signs_bot:bot_sensor", {
}) })
minetest.register_node("signs_bot:bot_sensor_on", { minetest.register_node("signs_bot:bot_sensor_on", {
description = I("Bot Sensor"), description = S("Bot Sensor"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -120,13 +117,13 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "bot_sensor", { doc.add_entry("signs_bot", "bot_sensor", {
name = I("Bot Sensor"), name = S("Bot Sensor"),
data = { data = {
item = "signs_bot:bot_sensor", item = "signs_bot:bot_sensor",
text = table.concat({ text = table.concat({
I("The Bot Sensor detects any bot and sends a signal, if a bot is nearby."), S("The Bot Sensor detects any bot and sends a signal, if a bot is nearby."),
I("the sensor range is one node/meter."), S("the sensor range is one node/meter."),
I("The sensor direction does not care."), S("The sensor direction does not care."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,20 +13,19 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local function update_infotext(pos, dest_pos, dest_idx) 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 end
local function swap_node(pos, name) local function swap_node(pos, name)
@ -62,7 +61,7 @@ local function node_timer(pos)
end end
minetest.register_node("signs_bot:cart_sensor", { minetest.register_node("signs_bot:cart_sensor", {
description = I("Cart Sensor"), description = S("Cart Sensor"),
inventory_image = "signs_bot_sensor_cart_inv.png", inventory_image = "signs_bot_sensor_cart_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -83,7 +82,7 @@ minetest.register_node("signs_bot:cart_sensor", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) 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) minetest.get_node_timer(pos):start(CYCLE_TIME)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
meta:set_int("param2", (node.param2 + 2) % 4) 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", { minetest.register_node("signs_bot:cart_sensor_on", {
description = I("Cart Sensor"), description = S("Cart Sensor"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -158,13 +157,13 @@ minetest.register_lbm({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "cart_sensor", { doc.add_entry("signs_bot", "cart_sensor", {
name = I("Cart Sensor"), name = S("Cart Sensor"),
data = { data = {
item = "signs_bot:cart_sensor", item = "signs_bot:cart_sensor",
text = table.concat({ text = table.concat({
I("The Cart Sensor detects and sends a signal, if a cart (Minecart) is nearby."), S("The Cart Sensor detects and sends a signal, if a cart (Minecart) is nearby."),
I("the sensor range is one node/meter."), S("the sensor range is one node/meter."),
I("The sensor has an active side (red) that must point to the rail/cart."), S("The sensor has an active side (red) that must point to the rail/cart."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,10 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -34,7 +31,7 @@ local formspec = "size[8,7]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. 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]".. "label[2.6,0.7;1]label[5.1,0.7;2]"..
"list[context;sign;3,0.5;2,2;]".. "list[context;sign;3,0.5;2,2;]"..
"label[2.6,1.7;3]label[5.1,1.7;4]".. "label[2.6,1.7;3]label[5.1,1.7;4]"..
@ -108,7 +105,7 @@ end
for idx = 1,4 do for idx = 1,4 do
local not_in_inv = idx == 1 and 0 or 1 local not_in_inv = idx == 1 and 0 or 1
minetest.register_node("signs_bot:changer"..idx, { 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", inventory_image = "signs_bot_ctrl_unit_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -169,18 +166,18 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "changer", { doc.add_entry("signs_bot", "changer", {
name = I("Bot Control Unit"), name = S("Bot Control Unit"),
data = { data = {
item = "signs_bot:changer1", item = "signs_bot:changer1",
text = table.concat({ text = table.concat({
I("The Bot Control Unit is used to lead the bot by means of signs."), S("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 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."), S("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."), S("The sign disappears / is moved to the inventory of the unit."),
I("This can be repeated 3 times."), 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") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-0221 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,12 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local NODE_IO = minetest.global_exists("node_io") local NODE_IO = minetest.global_exists("node_io")
@ -50,7 +49,7 @@ end
local function update_infotext(pos, dest_pos, cmnd) local function update_infotext(pos, dest_pos, cmnd)
local meta = M(pos) local meta = M(pos)
local state = get_inv_state(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) meta:set_string("state", state)
end end
@ -68,7 +67,7 @@ end
if NODE_IO then if NODE_IO then
minetest.register_node("signs_bot:chest", { minetest.register_node("signs_bot:chest", {
description = I("Signs Bot Chest"), description = S("Signs Bot Chest"),
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
'signs_bot_chest_top.png', 'signs_bot_chest_top.png',
@ -91,7 +90,7 @@ if NODE_IO then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
meta:set_string("formspec", formspec(pos, mem)) 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, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
@ -158,7 +157,7 @@ if NODE_IO then
}) })
else else
minetest.register_node("signs_bot:chest", { minetest.register_node("signs_bot:chest", {
description = I("Signs Bot Chest"), description = S("Signs Bot Chest"),
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
'signs_bot_chest_top.png', 'signs_bot_chest_top.png',
@ -181,7 +180,7 @@ else
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
meta:set_string("formspec", formspec(pos, mem)) 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, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
@ -245,15 +244,15 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "chest", { doc.add_entry("signs_bot", "chest", {
name = I("Signs Bot Chest"), name = S("Signs Bot Chest"),
data = { data = {
item = "signs_bot:chest", item = "signs_bot:chest",
text = table.concat({ text = table.concat({
I("The Signs Bot Chest is a special chest with sensor function."), S("The Signs Bot Chest is a special chest with sensor function."),
I("It sends a signal depending on the chest state."), S("It sends a signal depending on the chest state."),
I("Possible states are 'empty', 'not empty', 'almost full'"), 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") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -11,14 +11,8 @@
Bot farming commands Bot farming commands
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -65,7 +59,7 @@ signs_bot.register_botcommand("sow_seed", {
mod = "farming", mod = "farming",
params = "<slot>", params = "<slot>",
num_param = 1, 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) check = function(slot)
slot = tonumber(slot) slot = tonumber(slot)
return slot and slot > 0 and slot < 9 return slot and slot > 0 and slot < 9
@ -110,7 +104,7 @@ signs_bot.register_botcommand("harvest", {
mod = "farming", mod = "farming",
params = "", params = "",
num_param = 0, 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) cmnd = function(base_pos, mem)
if not mem.steps then if not mem.steps then
mem.pos_tbl = signs_bot.lib.gen_position_table(mem.robot_pos, mem.robot_param2, 3, 3, 0) 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", mod = "farming",
params = "<slot>", params = "<slot>",
num_param = 1, 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) check = function(slot)
slot = tonumber(slot) slot = tonumber(slot)
return slot and slot > 0 and slot < 9 return slot and slot > 0 and slot < 9
@ -171,7 +165,7 @@ turn_around]]
signs_bot.register_sign({ signs_bot.register_sign({
name = "farming", name = "farming",
description = I('Sign "farming"'), description = S('Sign "farming"'),
commands = CMD, commands = CMD,
image = "signs_bot_sign_farming.png", image = "signs_bot_sign_farming.png",
}) })
@ -187,14 +181,14 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "farming", { doc.add_entry("signs_bot", "farming", {
name = I("Sign 'farming'"), name = S("Sign 'farming'"),
data = { data = {
item = "signs_bot:farming", item = "signs_bot:farming",
text = table.concat({ text = table.concat({
I("Used to harvest and seed a 3x3 field."), S("Used to harvest and seed a 3x3 field."),
I("Place the sign in front of the field."), S("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."), S("The seed to be placed has to be in the first inventory slot of the bot."),
I("When finished, the bot turns."), S("When finished, the bot turns."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -11,14 +11,8 @@
Bot flower cutting command Bot flower cutting command
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -75,7 +69,7 @@ signs_bot.register_botcommand("cutting", {
mod = "farming", mod = "farming",
params = "", params = "",
num_param = 0, 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) cmnd = function(base_pos, mem)
if not mem.steps then if not mem.steps then
mem.pos_tbl = signs_bot.lib.gen_position_table(mem.robot_pos, mem.robot_param2, 3, 3, 0) 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({ signs_bot.register_sign({
name = "flowers", name = "flowers",
description = I('Sign "flowers"'), description = S('Sign "flowers"'),
commands = CMD, commands = CMD,
image = "signs_bot_sign_flowers.png", image = "signs_bot_sign_flowers.png",
}) })
@ -116,13 +110,13 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "flowers", { doc.add_entry("signs_bot", "flowers", {
name = I("Sign 'flowers'"), name = S("Sign 'flowers'"),
data = { data = {
item = "signs_bot:flowers", item = "signs_bot:flowers",
text = table.concat({ text = table.concat({
I("Used to cut flowers on a 3x3 field."), S("Used to cut flowers on a 3x3 field."),
I("Place the sign in front of the field."), S("Place the sign in front of the field."),
I("When finished, the bot turns."), S("When finished, the bot turns."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,10 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -90,7 +87,7 @@ signs_bot.register_botcommand("take_item", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, 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"), "<slot> is the inventory slot (1..8) or 0 for any one"),
check = function(num, slot) check = function(num, slot)
num = tonumber(num) or 1 num = tonumber(num) or 1
@ -115,7 +112,7 @@ signs_bot.register_botcommand("add_item", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, 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"), "<slot> is the inventory slot (1..8) or 0 for any one"),
check = function(num, slot) check = function(num, slot)
num = tonumber(num) or 1 num = tonumber(num) or 1
@ -140,7 +137,7 @@ signs_bot.register_botcommand("add_fuel", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, 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"), "<slot> is the inventory slot (1..8) or 0 for any one"),
check = function(num, slot) check = function(num, slot)
num = tonumber(num) or 1 num = tonumber(num) or 1
@ -165,7 +162,7 @@ signs_bot.register_botcommand("cond_take_item", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, num_param = 2,
description = I("deprecated, use bot inventory configuration instead"), description = S("deprecated, use bot inventory configuration instead"),
check = function(num, slot) check = function(num, slot)
return false return false
end, end,
@ -178,7 +175,7 @@ signs_bot.register_botcommand("cond_add_item", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, num_param = 2,
description = I("deprecated, use bot inventory configuration instead"), description = S("deprecated, use bot inventory configuration instead"),
check = function(num, slot) check = function(num, slot)
return false return false
end, end,
@ -191,7 +188,7 @@ signs_bot.register_botcommand("pickup_items", {
mod = "item", mod = "item",
params = "<slot>", params = "<slot>",
num_param = 1, num_param = 1,
description = I("Pick up all objects\n".. description = S("Pick up all objects\n"..
"in a 3x3 field.\n".. "in a 3x3 field.\n"..
"<slot> is the inventory slot (1..8) or 0 for any one"), "<slot> is the inventory slot (1..8) or 0 for any one"),
check = function(slot) check = function(slot)
@ -219,7 +216,7 @@ signs_bot.register_botcommand("drop_items", {
mod = "item", mod = "item",
params = "<num> <slot>", params = "<num> <slot>",
num_param = 2, 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"), "<slot> is the inventory slot (1..8) or 0 for any one"),
check = function(num, slot) check = function(num, slot)
num = tonumber(num) or 1 num = tonumber(num) or 1
@ -246,7 +243,7 @@ signs_bot.register_botcommand("punch_cart", {
mod = "item", mod = "item",
params = "", params = "",
num_param = 0, 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) cmnd = function(base_pos, mem)
local pos = lib.dest_pos(mem.robot_pos, mem.robot_param2, {0}) local pos = lib.dest_pos(mem.robot_pos, mem.robot_param2, {0})
for _, object in pairs(minetest.get_objects_inside_radius(pos, 2)) do for _, object in pairs(minetest.get_objects_inside_radius(pos, 2)) do

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
local get_node_lvm = tubelib2.get_node_lvm local get_node_lvm = tubelib2.get_node_lvm
@ -135,7 +129,7 @@ signs_bot.register_botcommand("backward", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Move the robot one step back"), description = S("Move the robot one step back"),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
local new_pos = backward_robot(mem) local new_pos = backward_robot(mem)
if new_pos then -- not blocked? if new_pos then -- not blocked?
@ -160,7 +154,7 @@ signs_bot.register_botcommand("turn_left", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Turn the robot to the left"), description = S("Turn the robot to the left"),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "L") mem.robot_param2 = turn_robot(mem.robot_pos, mem.robot_param2, "L")
return signs_bot.DONE return signs_bot.DONE
@ -171,7 +165,7 @@ signs_bot.register_botcommand("turn_right", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Turn the robot to the right"), description = S("Turn the robot to the right"),
cmnd = function(base_pos, mem) 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")
return signs_bot.DONE return signs_bot.DONE
@ -182,7 +176,7 @@ signs_bot.register_botcommand("turn_around", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Turn the robot around"), description = S("Turn the robot around"),
cmnd = function(base_pos, mem) 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")
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", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Move the robot upwards"), description = S("Move the robot upwards"),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
local new_pos = robot_up(mem.robot_pos, mem.robot_param2) local new_pos = robot_up(mem.robot_pos, mem.robot_param2)
if new_pos then -- not blocked? if new_pos then -- not blocked?
@ -251,7 +245,7 @@ signs_bot.register_botcommand("move_down", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Move the robot down"), description = S("Move the robot down"),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
local new_pos = robot_down(mem.robot_pos, mem.robot_param2) local new_pos = robot_down(mem.robot_pos, mem.robot_param2)
if new_pos then -- not blocked? if new_pos then -- not blocked?
@ -265,7 +259,7 @@ signs_bot.register_botcommand("pause", {
mod = "move", mod = "move",
params = "<sec>", params = "<sec>",
num_param = 1, 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) check = function(sec)
sec = tonumber(sec) or 1 sec = tonumber(sec) or 1
return sec and sec > 0 and sec < 10000 return sec and sec > 0 and sec < 10000
@ -290,7 +284,7 @@ signs_bot.register_botcommand("stop", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Stop the robot."), description = S("Stop the robot."),
cmnd = function(base_pos, mem, slot) cmnd = function(base_pos, mem, slot)
if mem.capa then if mem.capa then
mem.capa = mem.capa + 2 mem.capa = mem.capa + 2
@ -303,7 +297,7 @@ signs_bot.register_botcommand("turn_off", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Turn the robot off\n".. description = S("Turn the robot off\n"..
"and put it back in the box."), "and put it back in the box."),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
signs_bot.stop_robot(base_pos, mem) signs_bot.stop_robot(base_pos, mem)

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -117,7 +111,7 @@ signs_bot.register_botcommand("pattern", {
mod = "copy", mod = "copy",
params = "", params = "",
num_param = 0, num_param = 0,
description = I("Store pattern to be cloned."), description = S("Store pattern to be cloned."),
cmnd = function(base_pos, mem) cmnd = function(base_pos, mem)
mem.pttrn_pos = lib.next_pos(mem.robot_pos, mem.robot_param2) mem.pttrn_pos = lib.next_pos(mem.robot_pos, mem.robot_param2)
mem.pttrn_param2 = mem.robot_param2 mem.pttrn_param2 = mem.robot_param2
@ -129,7 +123,7 @@ signs_bot.register_botcommand("copy", {
mod = "copy", mod = "copy",
params = "<size> <lvl>", params = "<size> <lvl>",
num_param = 2, num_param = 2,
description = I("Copy the nodes from\n".. description = S("Copy the nodes from\n"..
"the stored pattern position\n".. "the stored pattern position\n"..
"<size> is: 3x1, 3x2, 3x3,\n".. "<size> is: 3x1, 3x2, 3x3,\n"..
"5x1, 5x2, 5x3 (wide x deep)\n".. "5x1, 5x2, 5x3 (wide x deep)\n"..
@ -178,7 +172,7 @@ minetest.register_node("signs_bot:missing", {
signs_bot.register_sign({ signs_bot.register_sign({
name = "pattern", name = "pattern",
description = I('Sign "pattern"'), description = S('Sign "pattern"'),
commands = "pattern\nturn_around", commands = "pattern\nturn_around",
image = "signs_bot_sign_pattern.png", image = "signs_bot_sign_pattern.png",
}) })
@ -207,7 +201,7 @@ turn_around]]
signs_bot.register_sign({ signs_bot.register_sign({
name = "copy3x3x3", name = "copy3x3x3",
description = I('Sign "copy 3x3x3"'), description = S('Sign "copy 3x3x3"'),
commands = CMND, commands = CMND,
image = "signs_bot_sign_copy3x3x3.png", image = "signs_bot_sign_copy3x3x3.png",
}) })
@ -223,14 +217,14 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "pattern", { doc.add_entry("signs_bot", "pattern", {
name = I("Sign 'pattern'"), name = S("Sign 'pattern'"),
data = { data = {
item = "signs_bot:pattern", item = "signs_bot:pattern",
text = table.concat({ text = table.concat({
I("Used to make a copy of a 3x3x3 cube."), S("Used to make a copy of a 3x3x3 cube."),
I("Place the sign in front of the pattern to be copied."), S("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."), S("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("The bot must first reach the pattern sign, then the copy sign."),
}, "\n") }, "\n")
}, },
}) })
@ -238,13 +232,13 @@ end
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "copy3x3x3", { doc.add_entry("signs_bot", "copy3x3x3", {
name = I("Sign 'copy3x3x3'"), name = S("Sign 'copy3x3x3'"),
data = { data = {
item = "signs_bot:copy3x3x3", item = "signs_bot:copy3x3x3",
text = table.concat({ text = table.concat({
I("Used to make a copy of a 3x3x3 cube."), S("Used to make a copy of a 3x3x3 cube."),
I("Place the sign in front of the location, where the copy should be made."), S("Place the sign in front of the location, where the copy should be made."),
I("Use the pattern sign to mark the pattern."), S("Use the pattern sign to mark the pattern."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
local bot_inv_take_item = signs_bot.bot_inv_take_item 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) local pos1, p2 = lib.dest_pos(robot_pos, param2, route)
pos1.y = pos1.y + level pos1.y = pos1.y + level
if not lib.not_protected(base_pos, pos1) then 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 end
if lib.is_air_like(pos1) then if lib.is_air_like(pos1) then
local taken = signs_bot.bot_inv_take_item(base_pos, slot, 1) local taken = signs_bot.bot_inv_take_item(base_pos, slot, 1)
@ -74,7 +68,7 @@ signs_bot.register_botcommand("place_front", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) check = function(slot, lvl)
@ -95,7 +89,7 @@ signs_bot.register_botcommand("place_left", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) check = function(slot, lvl)
@ -116,7 +110,7 @@ signs_bot.register_botcommand("place_right", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) 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 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} local pos1 = {x=robot_pos.x,y=robot_pos.y-1,z=robot_pos.z}
if not lib.not_protected(base_pos, pos1) then 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 end
local node = tubelib2.get_node_lvm(pos1) local node = tubelib2.get_node_lvm(pos1)
if node.name == "signs_bot:robot_foot" then if node.name == "signs_bot:robot_foot" then
@ -155,7 +149,7 @@ signs_bot.register_botcommand("place_below", {
mod = "place", mod = "place",
params = "<slot>", params = "<slot>",
num_param = 1, 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".. "Hint: use 'move_up' first.\n"..
"<slot> is the inventory slot (1..8)"), "<slot> is the inventory slot (1..8)"),
check = function(slot) 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 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} local pos1 = {x=robot_pos.x,y=robot_pos.y+1,z=robot_pos.z}
if not lib.not_protected(base_pos, pos1) then 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 end
if lib.is_air_like(pos1) then if lib.is_air_like(pos1) then
local taken = bot_inv_take_item(base_pos, slot, 1) local taken = bot_inv_take_item(base_pos, slot, 1)
@ -189,7 +183,7 @@ signs_bot.register_botcommand("place_above", {
mod = "place", mod = "place",
params = "<slot>", params = "<slot>",
num_param = 1, 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)"), "<slot> is the inventory slot (1..8)"),
check = function(slot) check = function(slot)
slot = tonumber(slot) or 0 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 node = tubelib2.get_node_lvm(pos1)
local dug_name = lib.is_simple_node(node) local dug_name = lib.is_simple_node(node)
if not lib.not_protected(base_pos, pos1) then 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 end
if dug_name then if dug_name then
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
minetest.remove_node(pos1) minetest.remove_node(pos1)
else else
return signs_bot.ERROR, I("Error: No free inventory space") return signs_bot.ERROR, S("Error: No free inventory space")
end end
end end
return signs_bot.DONE return signs_bot.DONE
@ -223,7 +217,7 @@ signs_bot.register_botcommand("dig_front", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) check = function(slot, lvl)
@ -245,7 +239,7 @@ signs_bot.register_botcommand("dig_left", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) check = function(slot, lvl)
@ -267,7 +261,7 @@ signs_bot.register_botcommand("dig_right", {
mod = "place", mod = "place",
params = "<slot> <lvl>", params = "<slot> <lvl>",
num_param = 2, 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".. "<slot> is the inventory slot (1..8)\n"..
"<lvl> is one of: -1 0 +1"), "<lvl> is one of: -1 0 +1"),
check = function(slot, lvl) 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 node = tubelib2.get_node_lvm(pos1)
local dug_name = lib.is_simple_node(node) local dug_name = lib.is_simple_node(node)
if not lib.not_protected(base_pos, pos1) then 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 end
if dug_name then if dug_name then
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
minetest.set_node(pos1, {name="signs_bot:robot_foot"}) minetest.set_node(pos1, {name="signs_bot:robot_foot"})
else else
return signs_bot.ERROR, I("Error: No free inventory space") return signs_bot.ERROR, S("Error: No free inventory space")
end end
end end
return signs_bot.DONE return signs_bot.DONE
@ -306,7 +300,7 @@ signs_bot.register_botcommand("dig_below", {
mod = "place", mod = "place",
params = "<slot>", params = "<slot>",
num_param = 1, 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)"), "<slot> is the inventory slot (1..8)"),
check = function(slot) check = function(slot)
slot = tonumber(slot) or 0 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 node = tubelib2.get_node_lvm(pos1)
local dug_name = lib.is_simple_node(node) local dug_name = lib.is_simple_node(node)
if not lib.not_protected(base_pos, pos1) then 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 end
if dug_name then if dug_name then
if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then if bot_inv_put_item(base_pos, slot, ItemStack(dug_name)) then
minetest.remove_node(pos1) minetest.remove_node(pos1)
else else
return signs_bot.ERROR, I("Error: No free inventory space") return signs_bot.ERROR, S("Error: No free inventory space")
end end
end end
return signs_bot.DONE return signs_bot.DONE
@ -340,7 +334,7 @@ signs_bot.register_botcommand("dig_above", {
mod = "place", mod = "place",
params = "<slot>", params = "<slot>",
num_param = 1, 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)"), "<slot> is the inventory slot (1..8)"),
check = function(slot) check = function(slot)
slot = tonumber(slot) or 0 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 pos1.y = pos1.y + level
local node = tubelib2.get_node_lvm(pos1) local node = tubelib2.get_node_lvm(pos1)
if not lib.not_protected(base_pos, pos1) then 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 end
if lib.is_simple_node(node) then if lib.is_simple_node(node) then
local p2 = tRotations[node.param2] and tRotations[node.param2][steps] local p2 = tRotations[node.param2] and tRotations[node.param2][steps]
@ -372,7 +366,7 @@ end
signs_bot.register_botcommand("rotate_item", { signs_bot.register_botcommand("rotate_item", {
mod = "place", mod = "place",
params = "<lvl> <steps>", 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".. "<lvl> is one of: -1 0 +1\n"..
"<steps> is one of: 1 2 3"), "<steps> is one of: 1 2 3"),
check = function(lvl, steps) 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 -- Simplified torch which can be placed w/o a fake player
minetest.register_node("signs_bot:torch", { minetest.register_node("signs_bot:torch", {
description = "Bot torch", description = S("Bot torch"),
inventory_image = "default_torch_on_floor.png", inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png", wield_image = "default_torch_on_floor.png",
drawtype = "nodebox", drawtype = "nodebox",

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,10 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -48,12 +45,12 @@ local function formspec1(meta)
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"style_type[textarea,table;font=mono]".. "style_type[textarea,table;font=mono]"..
"tabheader[0,0;tab;"..I("Commands,Help")..";1;;true]".. "tabheader[0,0;tab;"..S("Commands,Help")..";1;;true]"..
"field[0.3,0.5;9,1;name;"..I("Sign name:")..";"..name.."]".. "field[0.3,0.5;9,1;name;"..S("Sign name:")..";"..name.."]"..
"textarea[0.3,1.2;9,7.2;cmnd;;"..cmnd.."]".. "textarea[0.3,1.2;9,7.2;cmnd;;"..cmnd.."]"..
"label[0.3,7.5;"..err_msg.."]".. "label[0.3,7.5;"..err_msg.."]"..
"button_exit[5,7.5;2,1;cancel;"..I("Cancel").."]".. "button_exit[5,7.5;2,1;cancel;"..S("Cancel").."]"..
"button[7,7.5;2,1;check;"..I("Check").."]" "button[7,7.5;2,1;check;"..S("Check").."]"
end end
local function formspec2(pos, text) local function formspec2(pos, text)
@ -62,10 +59,10 @@ local function formspec2(pos, text)
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"style_type[textarea,table;font=mono]".. "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.."]".. "table[0.1,0;8.6,4;command;"..sCmnds..";"..pos.."]"..
"textarea[0.3,4.5;9,3.5;help;Help:;"..text.."]".. "textarea[0.3,4.5;9,3.5;help;"..S("Help")..":;"..text.."]"..
"button[3,7.5;3,1;copy;"..I("Copy Cmnd").."]" "button[3,7.5;3,1;copy;"..S("Copy Cmnd").."]"
end end
local function add_arrow(text, line_num) 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 local text = meta:get_string("signs_bot_cmnd").."\n"..line
meta:set_string("signs_bot_cmnd", text) meta:set_string("signs_bot_cmnd", text)
meta:set_int("err_code", 1) -- zero means OK 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 end
local function check_and_store(pos, meta, fields) local function check_and_store(pos, meta, fields)
@ -106,7 +103,7 @@ local function check_and_store(pos, meta, fields)
end end
minetest.register_node("signs_bot:sign_cmnd", { minetest.register_node("signs_bot:sign_cmnd", {
description = I('Sign "command"'), description = S('Sign "command"'),
drawtype = "nodebox", drawtype = "nodebox",
inventory_image = "signs_bot_sign_cmnd.png", inventory_image = "signs_bot_sign_cmnd.png",
node_box = { 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_string("err_msg", imeta:get_string("err_msg"))
nmeta:set_int("err_code", imeta:get_int("err_code")) nmeta:set_int("err_code", imeta:get_int("err_code"))
else else
nmeta:set_string("sign_name", I('Sign "command"')) nmeta:set_string("sign_name", S('Sign "command"'))
nmeta:set_string("signs_bot_cmnd", I("-- enter or copy commands from help page")) nmeta:set_string("signs_bot_cmnd", S("-- enter or copy commands from help page"))
nmeta:set_int("err_code", 0) nmeta:set_int("err_code", 0)
end end
nmeta:set_string("infotext", nmeta:get_string("sign_name")) 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) lib.place_sign(pos1, sign, param2)
return signs_bot.DONE return signs_bot.DONE
else else
return signs_bot.ERROR, I("Error: Signs inventory empty") return signs_bot.ERROR, S("Error: Signs inventory empty")
end end
end end
end end
return signs_bot.ERROR, I("Error: Position protected or occupied") return signs_bot.ERROR, S("Error: Position protected or occupied")
end end
signs_bot.register_botcommand("place_sign", { signs_bot.register_botcommand("place_sign", {
mod = "sign", mod = "sign",
params = "<slot>", params = "<slot>",
num_param = 1, 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)"), "<slot> is the inventory slot (1..6)"),
check = function(slot) check = function(slot)
slot = tonumber(slot) or 1 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) lib.place_sign(pos1, sign, param2)
return signs_bot.DONE return signs_bot.DONE
else else
return signs_bot.ERROR, I("Error: Signs inventory empty") return signs_bot.ERROR, S("Error: Signs inventory empty")
end end
end end
end end
return signs_bot.ERROR, I("Error: Position protected or occupied") return signs_bot.ERROR, S("Error: Position protected or occupied")
end end
signs_bot.register_botcommand("place_sign_behind", { signs_bot.register_botcommand("place_sign_behind", {
mod = "sign", mod = "sign",
params = "<slot>", params = "<slot>",
num_param = 1, 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)"), "<slot> is the inventory slot (1..6)"),
check = function(slot) check = function(slot)
slot = tonumber(slot) or 1 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 err_code = meta:get_int("err_code")
local name = meta:get_string("sign_name") local name = meta:get_string("sign_name")
if cmnd == "" then if cmnd == "" then
return signs_bot.ERROR, I("Error: No sign available") return signs_bot.ERROR, S("Error: No sign available")
end end
if lib.not_protected(base_pos, pos1) then if lib.not_protected(base_pos, pos1) then
local node = tubelib2.get_node_lvm(pos1) 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) minetest.remove_node(pos1)
if not put_inv_sign(base_pos, slot, sign) then if not put_inv_sign(base_pos, slot, sign) then
signs_bot.lib.drop_items(robot_pos, sign) 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 end
return signs_bot.DONE return signs_bot.DONE
end end
return signs_bot.ERROR, I("Error: Position is protected") return signs_bot.ERROR, S("Error: Position is protected")
end end
signs_bot.register_botcommand("dig_sign", { signs_bot.register_botcommand("dig_sign", {
mod = "sign", mod = "sign",
params = "<slot>", params = "<slot>",
num_param = 1, 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".. "and add it to the signs inventory.\n"..
"<slot> is the inventory slot (1..6)"), "<slot> is the inventory slot (1..6)"),
check = function(slot) 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 pos1 = lib.dest_pos(robot_pos, param2, {0})
local cmnd = M(pos1):get_string("signs_bot_cmnd") local cmnd = M(pos1):get_string("signs_bot_cmnd")
if cmnd == "" then if cmnd == "" then
return signs_bot.ERROR, I("Error: No sign available") return signs_bot.ERROR, S("Error: No sign available")
end end
if lib.not_protected(base_pos, pos1) then if lib.not_protected(base_pos, pos1) then
local node = tubelib2.get_node_lvm(pos1) local node = tubelib2.get_node_lvm(pos1)
@ -330,14 +327,14 @@ local function trash_sign(base_pos, robot_pos, param2, slot)
end end
return signs_bot.DONE return signs_bot.DONE
end end
return signs_bot.ERROR, I("Error: Position is protected") return signs_bot.ERROR, S("Error: Position is protected")
end end
signs_bot.register_botcommand("trash_sign", { signs_bot.register_botcommand("trash_sign", {
mod = "sign", mod = "sign",
params = "<slot>", params = "<slot>",
num_param = 1, 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".. "and add the cleared sign to\nthe item iventory.\n"..
"<slot> is the inventory slot (1..8)"), "<slot> is the inventory slot (1..8)"),
check = function(slot) check = function(slot)
@ -362,14 +359,14 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "sign_cmnd", { doc.add_entry("signs_bot", "sign_cmnd", {
name = I("Sign 'command'"), name = S("Sign 'command'"),
data = { data = {
item = "signs_bot:sign_cmnd", item = "signs_bot:sign_cmnd",
text = table.concat({ text = table.concat({
I("The 'command' sign can be programmed by the player."), S("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."), S("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."), S("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 help page has a copy button to simplify the programming."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,12 @@
]]-- ]]--
-- for lazy programmers -- 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 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 MP = minetest.get_modpath("signs_bot")
local I,_ = dofile(MP.."/intllib.lua")
local ci = dofile(MP.."/interpreter.lua") local ci = dofile(MP.."/interpreter.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -73,7 +72,7 @@ end
function signs_bot.get_commands() function signs_bot.get_commands()
local tbl = {} local tbl = {}
for _,mod in ipairs(SortedMods) do 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 for _,cmnd in ipairs(SortedKeys[mod]) do
local item = tCommands[cmnd] local item = tCommands[cmnd]
tbl[#tbl+1] = " "..item.name.." "..item.params tbl[#tbl+1] = " "..item.name.." "..item.params
@ -90,7 +89,7 @@ function signs_bot.get_help_text(cmnd)
return item.description return item.description
end end
end end
return I("unknown command") return S("unknown command")
end end
function signs_bot.check_commands(pos, text) function signs_bot.check_commands(pos, text)
@ -197,31 +196,31 @@ end
signs_bot.register_botcommand("repeat", { signs_bot.register_botcommand("repeat", {
mod = "core", mod = "core",
params = "<num>", params = "<num>",
description = I("start of a 'repeat..end' block"), description = S("start of a 'repeat..end' block"),
}) })
signs_bot.register_botcommand("end", { signs_bot.register_botcommand("end", {
mod = "core", mod = "core",
params = "", params = "",
description = I("end command of a 'repeat..end' block"), description = S("end command of a 'repeat..end' block"),
}) })
signs_bot.register_botcommand("call", { signs_bot.register_botcommand("call", {
mod = "core", mod = "core",
params = "<label>", params = "<label>",
description = I("call a subroutine (with 'return' statement)"), description = S("call a subroutine (with 'return' statement)"),
}) })
signs_bot.register_botcommand("return", { signs_bot.register_botcommand("return", {
mod = "core", mod = "core",
params = "", params = "",
description = I("return from a subroutine"), description = S("return from a subroutine"),
}) })
signs_bot.register_botcommand("jump", { signs_bot.register_botcommand("jump", {
mod = "core", mod = "core",
params = "<label>", params = "<label>",
description = I("jump to a label"), description = S("jump to a label"),
}) })
local function move(mem, any_sensor) local function move(mem, any_sensor)
@ -241,7 +240,7 @@ signs_bot.register_botcommand("move", {
mod = "move", mod = "move",
params = "<steps>", params = "<steps>",
num_param = 1, 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. without paying attention to any signs.
Up and down movements also become Up and down movements also become
counted as steps.]]), counted as steps.]]),
@ -261,7 +260,7 @@ signs_bot.register_botcommand("cond_move", {
mod = "move", mod = "move",
params = "", params = "",
num_param = 0, 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. reached. Then continue with the next command.
When a sign has been reached, When a sign has been reached,
the current program is ended the current program is ended

View File

@ -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 local NUM_LEAVES = 2
@ -46,7 +59,7 @@ if minetest.global_exists("signs_bot") then
mod = "compost", mod = "compost",
params = "<slot>", params = "<slot>",
num_param = 1, 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".. "<slot> is the bot inventory slot (1..8)\n"..
"with the leaves."), "with the leaves."),
check = function(slot) check = function(slot)
@ -68,7 +81,7 @@ if minetest.global_exists("signs_bot") then
mod = "compost", mod = "compost",
params = "<slot>", params = "<slot>",
num_param = 1, 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> (1..8 or 0 for the first free slot) is the bot\n"..
"slot for the compost item."), "slot for the compost item."),
check = function(num, slot) check = function(num, slot)

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,20 +13,18 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
local CYCLE_TIME = 4 local CYCLE_TIME = 4
local function update_infotext(pos, dest_pos, dest_idx) 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 end
local function swap_node(pos, name) local function swap_node(pos, name)
@ -56,7 +54,7 @@ local function node_timer(pos)
end end
minetest.register_node("signs_bot:crop_sensor", { minetest.register_node("signs_bot:crop_sensor", {
description = I("Crop Sensor"), description = S("Crop Sensor"),
inventory_image = "signs_bot_sensor_crop_inv.png", inventory_image = "signs_bot_sensor_crop_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -77,7 +75,7 @@ minetest.register_node("signs_bot:crop_sensor", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) 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) minetest.get_node_timer(pos):start(CYCLE_TIME)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
meta:set_int("param2", (node.param2 + 2) % 4) 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", { minetest.register_node("signs_bot:crop_sensor_on", {
description = I("Crop Sensor"), description = S("Crop Sensor"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -152,13 +150,13 @@ minetest.register_lbm({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "crop_sensor", { doc.add_entry("signs_bot", "crop_sensor", {
name = I("Crop Sensor"), name = S("Crop Sensor"),
data = { data = {
item = "signs_bot:crop_sensor", item = "signs_bot:crop_sensor",
text = table.concat({ text = table.concat({
I("The Crop Sensor sends cyclical signals when, for example, wheat is fully grown."), S("The Crop Sensor sends cyclical signals when, for example, wheat is fully grown."),
I("The sensor range is one node/meter."), S("The sensor range is one node/meter."),
I("The sensor has an active side (red) that must point to the crop/field."), S("The sensor has an active side (red) that must point to the crop/field."),
}, "\n") }, "\n")
}, },

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,20 +13,17 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local lib = signs_bot.lib
local function update_infotext(pos, dest_pos, cmnd) 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 end
local function infotext(pos) local function infotext(pos)
@ -34,19 +31,19 @@ local function infotext(pos)
local dest_pos = meta:get_string("signal_pos") local dest_pos = meta:get_string("signal_pos")
local signal = meta:get_string("signal_data") local signal = meta:get_string("signal_data")
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
update_infotext(pos, P(dest_pos), signal) update_infotext(pos, S2P(dest_pos), signal)
end end
end end
local function formspec(meta) 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")) local value = minetest.formspec_escape(meta:get_int("time"))
return "size[4,3]".. return "size[4,3]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"field[0.3,1;4,1;time;"..label..";"..value.."]".. "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 end
-- Used by the pairing tool -- Used by the pairing tool
@ -141,7 +138,7 @@ local function on_receive_fields(pos, formname, fields, player)
end end
minetest.register_node("signs_bot:delayer", { minetest.register_node("signs_bot:delayer", {
description = I("Signal Delayer"), description = S("Signal Delayer"),
inventory_image = "signs_bot_delayer_inv.png", inventory_image = "signs_bot_delayer_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -181,7 +178,7 @@ minetest.register_node("signs_bot:delayer", {
}) })
minetest.register_node("signs_bot:delayer_loaded", { minetest.register_node("signs_bot:delayer_loaded", {
description = I("Signal Delayer"), description = S("Signal Delayer"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -212,7 +209,7 @@ minetest.register_node("signs_bot:delayer_loaded", {
}) })
minetest.register_node("signs_bot:delayer_on", { minetest.register_node("signs_bot:delayer_on", {
description = I("Signal Delayer"), description = S("Signal Delayer"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -264,12 +261,12 @@ minetest.register_lbm({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "delayer", { doc.add_entry("signs_bot", "delayer", {
name = I("Signal Delayer"), name = S("Signal Delayer"),
data = { data = {
item = "signs_bot:delayer", item = "signs_bot:delayer",
text = table.concat({ text = table.concat({
I("Signals are forwarded delayed. Subsequent signals are queued."), S("Signals are forwarded delayed. Subsequent signals are queued."),
I("The delay time can be configured."), S("The delay time can be configured."),
}, "\n") }, "\n")
}, },
}) })

179
doc.lua
View File

@ -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 = {} signs_bot.doc = {}
if not minetest.get_modpath("doc") then if not minetest.get_modpath("doc") then
return return
end end
-- Load support for intllib.
local MP = minetest.get_modpath("signs_bot")
local I,_ = dofile(MP.."/intllib.lua")
local function formspec(data) local function formspec(data)
if data.image then if data.image then
local image = "image["..(doc.FORMSPEC.ENTRY_WIDTH - 3)..",0;3,2;"..data.image.."]" local image = "image["..(doc.FORMSPEC.ENTRY_WIDTH - 3)..",0;3,2;"..data.image.."]"
@ -24,113 +37,113 @@ local function formspec(data)
end end
local start_doc = table.concat({ 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."), S("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."), S("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.)"), 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.)"),
I("If the bot first reaches a sign it will execute the commands on the sign."), S("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."), S("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("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)."), 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)."),
I("This inventory simulates the bot internal inventory."), S("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("That means you will only have access to the inventory if the bot is turned off ('sitting' in his box)."),
}, "\n") }, "\n")
local control_doc = table.concat({ 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)."), S("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("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."), S("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."), S("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."), S("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."), S("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("The bot will walk over."),
"", "",
I("All predefined signs have a menu with a list of the bot commands."), S("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."), S("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."), S("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."), S("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("The help page has a copy button to simplify the programming."),
"", "",
I("Also for your own signs it is important to know:"), S("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("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"), S("A standard job for the bot is to move items from one chest to another"),
I("(chest or node with a chest like inventory)."), S("(chest or node with a chest like inventory)."),
I("This can be done by means of the two signs 'take item' and 'add item'."), S("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("These signs have to be placed on top of chest nodes."),
}, "\n") }, "\n")
local sensor_doc = table.concat({ local sensor_doc = table.concat({
I("In addition to the signs the bot can be controlled by means of sensors."), S("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."), S("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"), S("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("sends a signal to a connected block, called an actuator."),
"", "",
I("Sensors are:"), S("Sensors are:"),
I("- Bot Sensor: Sends a signal when the robot passes by"), S("- Bot Sensor: Sends a signal when the robot passes by"),
I("- Node Sensor: Sends a signal when it detects any node"), S("- Node Sensor: Sends a signal when it detects any node"),
I("- Crop Sensor: Sends a signal when, for example wheat is fully grown"), S("- 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("- Bot Chest: Sends a signal depending on the chest state (empty, full)"),
"", "",
I("Actuators are:"), S("Actuators are:"),
I("- Signs Bot Box: Can turn the bot off and on"), S("- 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("- 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") }, "\n")
local tool_doc = table.concat({ 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."), S("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."), S("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."), S("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("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."), S("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,"), S("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,"), S("when the Bot is in the state 'on'. Otherwise the sensor signal will stop the Bot,"),
I("instead of starting it."), S("instead of starting it."),
}, "\n") }, "\n")
local inventory_doc = table.concat({ 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>"), S("- take_item <num> <slot>"),
I("- pickup_items <slot>"), S("- pickup_items <slot>"),
I("- trash_sign <slot>"), S("- trash_sign <slot>"),
I("- harvest <slot>"), S("- harvest <slot>"),
I("- dig_front <slot> <lvl>"), S("- dig_front <slot> <lvl>"),
I("- dig_left <slot> <lvl>"), S("- dig_left <slot> <lvl>"),
I("- dig_right <slot> <lvl>"), S("- dig_right <slot> <lvl>"),
I("- dig_below <slot> <lvl>"), S("- dig_below <slot> <lvl>"),
I("- dig_above <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 "), S("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."), S("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, "), S("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 "), S("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."), S("(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."), S("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("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 "), S("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."), S("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 "), S("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."), S("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("If the number found is smaller than requested, he tries to take the rest out of any slot."),
}, "\n") }, "\n")
doc.add_category("signs_bot", doc.add_category("signs_bot",
{ {
name = I("Signs Bot"), name = S("Signs Bot"),
description = I("A robot controlled by signs, used for automated work"), description = S("A robot controlled by signs, used for automated work"),
sorting = "custom", sorting = "custom",
sorting_data = {"start", "control", "sensor_doc", "tool", sorting_data = {"start", "control", "sensor_doc", "tool",
"box", "bot_flap", "duplicator", "box", "bot_flap", "duplicator",
@ -142,26 +155,26 @@ doc.add_category("signs_bot",
}) })
doc.add_entry("signs_bot", "start", { 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"}, data = {text = start_doc, image = "signs_bot_doc_image.png"},
}) })
doc.add_entry("signs_bot", "control", { 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"}, data = {text = control_doc, image = "signs_bot_doc_image.png"},
}) })
doc.add_entry("signs_bot", "sensor_doc", { 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"}, data = {text = sensor_doc, image = "signs_bot_doc_image.png"},
}) })
doc.add_entry("signs_bot", "tool", { 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"}, data = {text = tool_doc, image = "signs_bot_doc_image.png"},
}) })
doc.add_entry("signs_bot", "tool", { 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"}, data = {text = inventory_doc, image = "signs_bot_doc_image.png"},
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,10 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -27,15 +24,15 @@ local formspec = "size[8,7.3]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"label[0.3,0;"..I("Input:").."]".. "label[0.1,0.2;"..S("Template:").."]"..
"list[context;inp;3,0;1,1;]".. "list[context;temp;2,0;1,1;]"..
"label[0.3,1;"..I("Template:").."]".. "label[0.1,1.2;"..S("Input:").."]"..
"list[context;temp;3,1;1,1;]".. "list[context;inp;2,1;1,1;]"..
"label[0.3,2;"..I("Output:").."]".. "label[0.1,2.2;"..S("Output:").."]"..
"list[context;outp;3,2;1,1;]".. "list[context;outp;2,2;1,1;]"..
"label[4,0;"..I("1. Place one 'cmnd' sign to be\n used as template.\n").. "label[3,0.2;"..S("1. Place one 'cmnd' sign").."]"..
I("2. Add 'blank signs' to\n the input inventory.\n").. "label[3,1.2;"..S("2. Add 'blank signs'").."]"..
I("3. Take the copies\n from the output inventory.").."]".. "label[3,2.2;"..S("3. Take the copies").."]"..
"list[current_player;main;0,3.5;8,4;]".. "list[current_player;main;0,3.5;8,4;]"..
"listring[context;inp]".. "listring[context;inp]"..
"listring[current_player;main]".. "listring[current_player;main]"..
@ -108,7 +105,7 @@ local function on_metadata_inventory_put(pos, listname, index, stack, player)
end end
minetest.register_node("signs_bot:duplicator", { minetest.register_node("signs_bot:duplicator", {
description = I("Signs Duplicator"), description = S("Signs Duplicator"),
stack_max = 1, stack_max = 1,
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
@ -167,7 +164,7 @@ local function formspec_user(cmnd)
end end
minetest.register_node("signs_bot:sign_user", { minetest.register_node("signs_bot:sign_user", {
description = I('Sign "user"'), description = S('Sign "user"'),
drawtype = "nodebox", drawtype = "nodebox",
inventory_image = "signs_bot_sign_user.png", inventory_image = "signs_bot_sign_user.png",
node_box = { node_box = {
@ -210,7 +207,7 @@ minetest.register_node("signs_bot:sign_user", {
signs_bot.register_sign({ signs_bot.register_sign({
name = "sign_blank", name = "sign_blank",
description = I('Sign "blank"'), description = S('Sign "blank"'),
commands = "", commands = "",
image = "signs_bot_sign_blank.png", image = "signs_bot_sign_blank.png",
}) })
@ -226,17 +223,17 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "duplicator", { doc.add_entry("signs_bot", "duplicator", {
name = I("Signs Duplicator"), name = S("Signs Duplicator"),
data = { data = {
item = "signs_bot:duplicator", item = "signs_bot:duplicator",
text = table.concat({ text = table.concat({
I("The Duplicator can be used to make copies of signs."), S("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"), S("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."), S("2. Add one or several 'blank signs' to the 'Input' inventory."),
I("3. Take the copies from the 'Output' inventory."), S("3. Take the copies from the 'Output' inventory."),
"", "",
I("Written books [default:book_written] can alternatively be used as template"), S("Written books [default:book_written] can alternatively be used as template"),
I("Already written signs can be used as input, too."), S("Already written signs can be used as input, too."),
}, "\n") }, "\n")
}, },
}) })
@ -244,10 +241,10 @@ end
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "sign_blank", { doc.add_entry("signs_bot", "sign_blank", {
name = I('Sign "blank"'), name = S('Sign "blank"'),
data = { data = {
item = "signs_bot:sign_blank", item = "signs_bot:sign_blank",
text = I("Needed as input for the Duplicator.") text = S("Needed as input for the Duplicator.")
}, },
}) })
end end

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,22 +13,18 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib
local function update_infotext(pos, dest_pos, cmnd) 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 end
minetest.register_node("signs_bot:sensor_extender", { minetest.register_node("signs_bot:sensor_extender", {
description = I("Sensor Extender"), description = S("Sensor Extender"),
inventory_image = "signs_bot_extender_inv.png", inventory_image = "signs_bot_extender_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -54,7 +50,7 @@ minetest.register_node("signs_bot:sensor_extender", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) local meta = M(pos)
meta:set_string("infotext", I("Sensor Extender: Not connected")) meta:set_string("infotext", S("Sensor Extender: Not connected"))
end, end,
update_infotext = update_infotext, update_infotext = update_infotext,
@ -69,7 +65,7 @@ minetest.register_node("signs_bot:sensor_extender", {
}) })
minetest.register_node("signs_bot:sensor_extender_on", { minetest.register_node("signs_bot:sensor_extender_on", {
description = I("Sensor Extender"), description = S("Sensor Extender"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "connected", type = "connected",
@ -129,13 +125,13 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "sensor_extender", { doc.add_entry("signs_bot", "sensor_extender", {
name = I("Sensor Extender"), name = S("Sensor Extender"),
data = { data = {
item = "signs_bot:sensor_extender", item = "signs_bot:sensor_extender",
text = table.concat({ text = table.concat({
I("With the Sensor Extender, sensor signals can be sent to more than one actuator."), S("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"), S("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 one further actuator by means of the Connection Tool."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -15,7 +15,7 @@
signs_bot = {} signs_bot = {}
-- Version for compatibility checks, see readme.md/history -- 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 if minetest.global_exists("techage") and techage.version < 0.25 then
error("[signs_bot] Signs Bot requires techage version 0.25 or newer!") 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!") error("[signs_bot] Signs Bot requires tubelib2 version 1.9 or newer!")
end end
-- Load support for I18n.
signs_bot.S = minetest.get_translator("signs_bot") signs_bot.S = minetest.get_translator("signs_bot")
local MP = minetest.get_modpath("signs_bot") local MP = minetest.get_modpath("signs_bot")
dofile(MP.."/doc.lua") dofile(MP.."/doc.lua")
dofile(MP.."/random.lua") dofile(MP.."/random.lua")
dofile(MP.."/lib.lua") dofile(MP.."/lib.lua")

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019-2020 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,9 +12,8 @@
]]-- ]]--
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local MAX_SIZE = 1000 -- max number of tokens local MAX_SIZE = 1000 -- max number of tokens
@ -235,29 +234,29 @@ function api.check_script(script)
if tCmdDef[cmnd] then if tCmdDef[cmnd] then
num_token = num_token + 1 + tCmdDef[cmnd].num_param num_token = num_token + 1 + tCmdDef[cmnd].num_param
if num_token > MAX_SIZE then if num_token > MAX_SIZE then
return false, I("Maximum programm size exceeded"), idx return false, S("Maximum programm size exceeded"), idx
end end
param1 = tonumber(param1) or param1 param1 = tonumber(param1) or param1
param2 = tonumber(param2) or param2 param2 = tonumber(param2) or param2
param3 = tonumber(param3) or param3 param3 = tonumber(param3) or param3
local num_param = (param1 and 1 or 0) + (param2 and 1 or 0) + (param3 and 1 or 0) 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 if tCmdDef[cmnd].num_param < num_param then
return false, I("Too many parameters"), idx return false, S("Too many parameters"), idx
end end
if tCmdDef[cmnd].num_param > 0 and not tCmdDef[cmnd].check(param1, param2, param3) then 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 end
elseif not cmnd:find("%w+:") then elseif not cmnd:find("%w+:") then
return false, I("Command error"), idx return false, S("Command error"), idx
end end
tbl[cmnd] = (tbl[cmnd] or 0) + 1 tbl[cmnd] = (tbl[cmnd] or 0) + 1
end end
if (tbl["end"] or 0) > (tbl["repeat"] or 0) then 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 elseif (tbl["end"] or 0) < (tbl["repeat"] or 0) then
return false, I("'end' missing"), 0 return false, S("'end' missing"), 0
end end
return true, I("Checked and approved"), 0 return true, S("Checked and approved"), 0
end end
-- function returns: true/false, error-string -- function returns: true/false, error-string

View File

@ -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

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,8 +13,6 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
signs_bot.register_inventory({"default:chest", "default:chest_open"}, { signs_bot.register_inventory({"default:chest", "default:chest_open"}, {

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,8 +13,6 @@
]]-- ]]--
-- for lazy programmers -- 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 M = minetest.get_meta
signs_bot.lib = {} signs_bot.lib = {}

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,13 +13,12 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -38,12 +37,12 @@ end
local function update_infotext(pos, dest_pos, cmnd) local function update_infotext(pos, dest_pos, cmnd)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
local text = table.concat({ local text = table.concat({
I("Signal AND with"), S("Signal AND with"),
#mem.inputs or 0, #mem.inputs or 0,
I("inputs"), S("inputs"),
":", ":",
I("Connected with"), S("Connected with"),
S(dest_pos), P2S(dest_pos),
"/", "/",
cmnd, cmnd,
":", ":",
@ -80,7 +79,7 @@ local function infotext(pos)
local dest_pos = meta:get_string("signal_pos") local dest_pos = meta:get_string("signal_pos")
local signal = meta:get_string("signal_data") local signal = meta:get_string("signal_data")
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
update_infotext(pos, P(dest_pos), signal) update_infotext(pos, S2P(dest_pos), signal)
end end
end end
@ -143,7 +142,7 @@ local function signs_bot_on_signal(pos, node, signal)
end end
minetest.register_node("signs_bot:and1", { minetest.register_node("signs_bot:and1", {
description = I("Signal AND"), description = S("Signal AND"),
inventory_image = "signs_bot_and_inv.png", inventory_image = "signs_bot_and_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -179,7 +178,7 @@ minetest.register_node("signs_bot:and1", {
}) })
minetest.register_node("signs_bot:and2", { minetest.register_node("signs_bot:and2", {
description = I("Signal AND"), description = S("Signal AND"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -208,7 +207,7 @@ minetest.register_node("signs_bot:and2", {
}) })
minetest.register_node("signs_bot:and3", { minetest.register_node("signs_bot:and3", {
description = I("Signal AND"), description = S("Signal AND"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -245,11 +244,11 @@ minetest.register_craft({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "and", { doc.add_entry("signs_bot", "and", {
name = I("Signal AND"), name = S("Signal AND"),
data = { data = {
item = "signs_bot:and1", item = "signs_bot:and1",
text = table.concat({ text = table.concat({
I("Signal is sent, if all input signals are received."), S("Signal is sent, if all input signals are received."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,20 +13,18 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = 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 M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local lib = signs_bot.lib local lib = signs_bot.lib
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local function update_infotext(pos, dest_pos, cmnd) 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 end
local function swap_node(pos, name) local function swap_node(pos, name)
@ -44,20 +42,20 @@ end
local DropdownValues = { local DropdownValues = {
[I("added")] = 1, [S("added")] = 1,
[I("removed")] = 2, [S("removed")] = 2,
[I("added or removed")] = 3, [S("added or removed")] = 3,
} }
local function formspec(mem) 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]".. return "size[6,3]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. 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).."]".. "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 end
local function any_node_changed(pos) local function any_node_changed(pos)
@ -115,7 +113,7 @@ local function node_timer(pos)
end end
minetest.register_node("signs_bot:node_sensor", { minetest.register_node("signs_bot:node_sensor", {
description = I("Node Sensor"), description = S("Node Sensor"),
inventory_image = "signs_bot_sensor_node_inv.png", inventory_image = "signs_bot_sensor_node_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -137,7 +135,7 @@ minetest.register_node("signs_bot:node_sensor", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) local meta = M(pos)
local mem = tubelib2.init_mem(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 mem.mode = 3 -- default legacy mode
meta:set_string("formspec", formspec(mem)) meta:set_string("formspec", formspec(mem))
minetest.get_node_timer(pos):start(CYCLE_TIME) 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", { minetest.register_node("signs_bot:node_sensor_on", {
description = I("Node Sensor"), description = S("Node Sensor"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -215,15 +213,15 @@ minetest.register_lbm({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "node_sensor", { doc.add_entry("signs_bot", "node_sensor", {
name = I("Node Sensor"), name = S("Node Sensor"),
data = { data = {
item = "signs_bot:node_sensor", item = "signs_bot:node_sensor",
text = table.concat({ text = table.concat({
I("The node sensor sends cyclical signals when it detects that nodes have appeared or disappeared,"), S("The node sensor sends cyclical signals when it detects that nodes have appeared or disappeared,"),
I("but has to be configured accordingly."), S("but has to be configured accordingly."),
I("Valid nodes are all kind of blocks and plants."), S("Valid nodes are all kind of blocks and plants."),
I("The sensor range is 3 nodes/meters in one direction."), S("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 sensor has an active side (red) that must point to the observed area."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information 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 local lib = signs_bot.lib
-- Called when robot is started -- Called when robot is started

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,12 +13,10 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
local lib = signs_bot.lib
-- Used by the pairing tool -- Used by the pairing tool
function signs_bot.get_node_type(pos) function signs_bot.get_node_type(pos)
local node = tubelib2.get_node_lvm(pos) local node = tubelib2.get_node_lvm(pos)
@ -50,7 +48,7 @@ end
function signs_bot.store_signal(sensor_pos, dest_pos, signal) function signs_bot.store_signal(sensor_pos, dest_pos, signal)
local meta = sensor_pos and M(sensor_pos) local meta = sensor_pos and M(sensor_pos)
if meta then 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) meta:set_string("signal_data", signal)
end end
end end
@ -64,7 +62,7 @@ function signs_bot.send_signal(sensor_pos)
local dest_pos = meta:get_string("signal_pos") local dest_pos = meta:get_string("signal_pos")
local signal = meta:get_string("signal_data") local signal = meta:get_string("signal_data")
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
local pos = P(dest_pos) local pos = S2P(dest_pos)
local node = tubelib2.get_node_lvm(pos) local node = tubelib2.get_node_lvm(pos)
local ndef = minetest.registered_nodes[node.name] local ndef = minetest.registered_nodes[node.name]
if ndef and ndef.signs_bot_on_signal then if ndef and ndef.signs_bot_on_signal then

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local function formspec(cmnd) local function formspec(cmnd)
cmnd = minetest.formspec_escape(cmnd) cmnd = minetest.formspec_escape(cmnd)
@ -73,7 +67,7 @@ signs_bot.register_sign = register_sign
register_sign({ register_sign({
name = "sign_right", name = "sign_right",
description = I('Sign "turn right"'), description = S('Sign "turn right"'),
commands = "turn_right", commands = "turn_right",
image = "signs_bot_sign_right.png", image = "signs_bot_sign_right.png",
}) })
@ -89,7 +83,7 @@ minetest.register_craft({
register_sign({ register_sign({
name = "sign_left", name = "sign_left",
description = I('Sign "turn left"'), description = S('Sign "turn left"'),
commands = "turn_left", commands = "turn_left",
image = "signs_bot_sign_left.png", image = "signs_bot_sign_left.png",
}) })
@ -105,7 +99,7 @@ minetest.register_craft({
register_sign({ register_sign({
name = "sign_take", name = "sign_take",
description = I('Sign "take item"'), description = S('Sign "take item"'),
commands = "take_item 99\nturn_around", commands = "take_item 99\nturn_around",
image = "signs_bot_sign_take.png", image = "signs_bot_sign_take.png",
}) })
@ -121,7 +115,7 @@ minetest.register_craft({
register_sign({ register_sign({
name = "sign_add", name = "sign_add",
description = I('Sign "add item"'), description = S('Sign "add item"'),
commands = "add_item 99\nturn_around", commands = "add_item 99\nturn_around",
image = "signs_bot_sign_add.png", image = "signs_bot_sign_add.png",
}) })
@ -137,7 +131,7 @@ minetest.register_craft({
register_sign({ register_sign({
name = "sign_stop", name = "sign_stop",
description = I('Sign "stop"'), description = S('Sign "stop"'),
commands = "stop", commands = "stop",
image = "signs_bot_sign_stop.png", image = "signs_bot_sign_stop.png",
}) })
@ -154,7 +148,7 @@ minetest.register_craft({
if minetest.get_modpath("minecart") then if minetest.get_modpath("minecart") then
register_sign({ register_sign({
name = "sign_add_cart", 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", commands = "drop_items 99 1\npunch_cart\nturn_around",
image = "signs_bot_sign_add_cart.png", image = "signs_bot_sign_add_cart.png",
}) })
@ -170,7 +164,7 @@ if minetest.get_modpath("minecart") then
register_sign({ register_sign({
name = "sign_take_cart", name = "sign_take_cart",
description = I('Sign "take from cart"'), description = S('Sign "take from cart"'),
commands = "pickup_items 1\npunch_cart\nturn_around", commands = "pickup_items 1\npunch_cart\nturn_around",
image = "signs_bot_sign_take_cart.png", image = "signs_bot_sign_take_cart.png",
}) })
@ -187,66 +181,66 @@ end
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "sign_right", { doc.add_entry("signs_bot", "sign_right", {
name = I('Sign "turn right"'), name = S('Sign "turn right"'),
data = { data = {
item = "signs_bot:sign_right", 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", { doc.add_entry("signs_bot", "sign_left", {
name = I('Sign "turn left"'), name = S('Sign "turn left"'),
data = { data = {
item = "signs_bot:sign_left", 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", { doc.add_entry("signs_bot", "sign_take", {
name = I('Sign "take item"'), name = S('Sign "take item"'),
data = { data = {
item = "signs_bot:sign_take", item = "signs_bot:sign_take",
text = table.concat({ text = table.concat({
I("The Bot takes items out of a chest in front of it and then turns around."), S("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("This sign has to be placed on top of the chest."),
}, "\n") }, "\n")
}, },
}) })
doc.add_entry("signs_bot", "sign_add", { doc.add_entry("signs_bot", "sign_add", {
name = I('Sign "add item"'), name = S('Sign "add item"'),
data = { data = {
item = "signs_bot:sign_add", item = "signs_bot:sign_add",
text = table.concat({ text = table.concat({
I("The Bot puts items into a chest in front of it and then turns around."), S("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("This sign has to be placed on top of the chest."),
}, "\n") }, "\n")
}, },
}) })
doc.add_entry("signs_bot", "sign_stop", { doc.add_entry("signs_bot", "sign_stop", {
name = I('Sign "stop"'), name = S('Sign "stop"'),
data = { data = {
item = "signs_bot:sign_stop", 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 end
if minetest.get_modpath("doc") and minetest.get_modpath("minecart") then if minetest.get_modpath("doc") and minetest.get_modpath("minecart") then
doc.add_entry("signs_bot", "sign_add_cart", { doc.add_entry("signs_bot", "sign_add_cart", {
name = I('Sign "add to cart"'), name = S('Sign "add to cart"'),
data = { data = {
item = "signs_bot:sign_add_cart", item = "signs_bot:sign_add_cart",
text = table.concat({ text = table.concat({
I("The Bot puts items into a minecart in front of it, pushes the cart and then turns around."), S("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("This sign has to be placed on top of the rail at the cart end position."),
}, "\n") }, "\n")
}, },
}) })
doc.add_entry("signs_bot", "sign_take_cart", { doc.add_entry("signs_bot", "sign_take_cart", {
name = I('Sign "take from cart"'), name = S('Sign "take from cart"'),
data = { data = {
item = "signs_bot:sign_take_cart", item = "signs_bot:sign_take_cart",
text = table.concat({ text = table.concat({
I("The Bot takes items out of a minecart in front of it, pushes the cart and then turns around."), S("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("This sign has to be placed on top of the rail at the cart end position."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -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 local CYCLE_TIME = 4

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -13,18 +13,15 @@
]]-- ]]--
-- for lazy programmers -- for lazy programmers
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos local S2P = minetest.string_to_pos
local M = minetest.get_meta local M = minetest.get_meta
-- Load support for intllib. -- Load support for I18n.
local MP = minetest.get_modpath("signs_bot") local S = signs_bot.S
local I,_ = dofile(MP.."/intllib.lua")
local CYCLE_TIME = 4 local CYCLE_TIME = 4
local lib = signs_bot.lib
local function update_infotext(pos, dest_pos, cmnd) local function update_infotext(pos, dest_pos, cmnd)
local meta = M(pos) local meta = M(pos)
local mem = tubelib2.get_mem(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 cycle_time = meta:get_int("cycle_time")
local text local text
if cycle_time > 0 then 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 else
text = I("Bot Timer").." (-- min): "..I("Connected with") text = S("Bot Timer").." (-- min): "..S("Connected with")
end end
meta:set_string("infotext", text.." "..S(dest_pos).." / "..(cmnd or "none").." ") meta:set_string("infotext", text.." "..P2S(dest_pos).." / "..(cmnd or "none").." ")
end end
local function update_infotext_local(pos) local function update_infotext_local(pos)
@ -50,7 +47,7 @@ local function update_infotext_local(pos)
local text2 = "Not connected" local text2 = "Not connected"
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
text2 = I("Connected with").." "..dest_pos.." / "..signal text2 = S("Connected with").." "..dest_pos.." / "..signal
end end
if cycle_time > 0 then if cycle_time > 0 then
text1 = " ("..rest.."/"..cycle_time.." min): " text1 = " ("..rest.."/"..cycle_time.." min): "
@ -59,19 +56,19 @@ local function update_infotext_local(pos)
mem.running = true mem.running = true
minetest.get_node_timer(pos):start(CYCLE_TIME) minetest.get_node_timer(pos):start(CYCLE_TIME)
end end
meta:set_string("infotext", I("Bot Timer")..text1..text2.." ") meta:set_string("infotext", S("Bot Timer")..text1..text2.." ")
end end
local function formspec(meta) 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")) local value = minetest.formspec_escape(meta:get_int("cycle_time"))
return "size[4,3]".. return "size[4,3]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"field[0.3,1;4,1;time;"..label..";"..value.."]".. "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 end
-- switch to normal texture -- switch to normal texture
@ -91,7 +88,7 @@ local function node_timer(pos)
local dest_pos = meta:get_string("signal_pos") local dest_pos = meta:get_string("signal_pos")
local signal = meta:get_string("signal_data") local signal = meta:get_string("signal_data")
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
update_infotext(pos, P(dest_pos), signal) update_infotext(pos, S2P(dest_pos), signal)
end end
end end
else else
@ -106,7 +103,7 @@ local function node_timer(pos)
local dest_pos = meta:get_string("signal_pos") local dest_pos = meta:get_string("signal_pos")
local signal = meta:get_string("signal_data") local signal = meta:get_string("signal_data")
if dest_pos ~= "" and signal ~= "" then if dest_pos ~= "" and signal ~= "" then
update_infotext(pos, P(dest_pos), signal) update_infotext(pos, S2P(dest_pos), signal)
end end
end end
return mem.time > 0 return mem.time > 0
@ -134,7 +131,7 @@ local function on_receive_fields(pos, formname, fields, player)
end end
minetest.register_node("signs_bot:timer", { minetest.register_node("signs_bot:timer", {
description = I("Bot Timer"), description = S("Bot Timer"),
inventory_image = "signs_bot_timer_inv.png", inventory_image = "signs_bot_timer_inv.png",
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
@ -151,7 +148,7 @@ minetest.register_node("signs_bot:timer", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = M(pos) 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)) meta:set_string("formspec", formspec(meta))
end, end,
@ -169,7 +166,7 @@ minetest.register_node("signs_bot:timer", {
}) })
minetest.register_node("signs_bot:timer_on", { minetest.register_node("signs_bot:timer_on", {
description = I("Bot Timer"), description = S("Bot Timer"),
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -220,12 +217,12 @@ minetest.register_lbm({
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "timer", { doc.add_entry("signs_bot", "timer", {
name = I("Bot Timer"), name = S("Bot Timer"),
data = { data = {
item = "signs_bot:timer", item = "signs_bot:timer",
text = table.concat({ text = table.concat({
I("Special kind of sensor."), S("Special kind of sensor."),
I("Can be programmed with a time in seconds, e.g. to start the bot cyclically."), S("Can be programmed with a time in seconds, e.g. to start the bot cyclically."),
}, "\n") }, "\n")
}, },
}) })

View File

@ -3,7 +3,7 @@
Signs Bot Signs Bot
========= =========
Copyright (C) 2019 Joachim Stolberg Copyright (C) 2019-2021 Joachim Stolberg
GPL v3 GPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -12,14 +12,8 @@
]]-- ]]--
-- for lazy programmers -- Load support for I18n.
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local S = signs_bot.S
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")
local lib = signs_bot.lib local lib = signs_bot.lib
@ -97,7 +91,7 @@ end
minetest.register_node("signs_bot:connector", { minetest.register_node("signs_bot:connector", {
description = I("Sensor Connection Tool"), description = S("Sensor Connection Tool"),
inventory_image = "signs_bot_tool.png", inventory_image = "signs_bot_tool.png",
wield_image = "signs_bot_tool.png", wield_image = "signs_bot_tool.png",
groups = {cracky=1, book=1}, groups = {cracky=1, book=1},