Add compost mod support and further improvements

master
Joachim Stolberg 2021-03-08 19:46:27 +01:00
parent cf97fa78ca
commit 0c53889091
10 changed files with 223 additions and 31 deletions

94
compost.lua Normal file
View File

@ -0,0 +1,94 @@
-- Load support for intllib.
local MP = minetest.get_modpath("signs_bot")
local I,_ = dofile(MP.."/intllib.lua")
local NUM_LEAVES = 4
-- we reuse the minecart hopper API here
local function additem(mem, stack)
local pos = signs_bot.lib.next_pos(mem.robot_pos, mem.robot_param2)
local node = minetest.get_node(pos)
local ndef = minetest.registered_nodes[node.name]
print(2, dump(ndef))
if ndef.minecart_hopper_additem then
return ndef.minecart_hopper_additem(pos, stack)
end
pos = {x = pos.x, y = pos.y - 1, z = pos.z}
node = minetest.get_node(pos)
ndef = minetest.registered_nodes[node.name]
print(3, dump(ndef))
if ndef.minecart_hopper_additem then
return ndef.minecart_hopper_additem(pos, stack)
end
return stack
end
local function takeitem(mem)
local pos = signs_bot.lib.next_pos(mem.robot_pos, mem.robot_param2)
local node = minetest.get_node(pos)
local ndef = minetest.registered_nodes[node.name]
print(4, dump(ndef))
if ndef.minecart_hopper_takeitem then
return ndef.minecart_hopper_takeitem(pos, 1)
end
pos = {x = pos.x, y = pos.y - 1, z = pos.z}
node = minetest.get_node(pos)
ndef = minetest.registered_nodes[node.name]
print(5, dump(ndef))
if ndef.minecart_hopper_takeitem then
return ndef.minecart_hopper_takeitem(pos, 1)
end
end
if minetest.global_exists("signs_bot") then
signs_bot.register_botcommand("add_compost", {
mod = "compost",
params = "<slot>",
num_param = 1,
description = I("Put 4 leaves into the compost barrel\n"..
"<slot> is the bot inventory slot (1..8)\n"..
"with the leaves."),
check = function(slot)
slot = tonumber(slot) or 0
return slot > 0 and slot < 9
end,
cmnd = function(base_pos, mem, slot)
print(1)
slot = tonumber(slot) or 0
local taken = signs_bot.bot_inv_take_item(base_pos, slot, NUM_LEAVES)
local leftover = additem(mem, taken)
if leftover and leftover:get_count() > 0 then
print(4)
signs_bot.bot_inv_put_item(base_pos, slot, leftover)
end
return signs_bot.DONE
end,
})
signs_bot.register_botcommand("take_compost", {
mod = "compost",
params = "<slot>",
num_param = 1,
description = I("Take a compost item from the barrel.\n"..
"<slot> (1..8 or 0 for the first free slot) is the bot\n"..
"slot for the compost item."),
check = function(num, slot)
slot = tonumber(slot) or 0
return slot >= 0 and slot < 9
end,
cmnd = function(base_pos, mem, num, slot)
slot = tonumber(slot) or 0
local taken = takeitem(mem)
local leftover = signs_bot.bot_inv_put_item(base_pos, slot, taken)
if leftover and leftover:get_count() > 0 then
signs_bot.lib.drop_items(mem.robot_pos, leftover)
end
return signs_bot.DONE
end,
})
end

View File

@ -25,6 +25,7 @@ end
local start_doc = table.concat({
I("After you have placed the Signs Bot Box, you can start the bot by means of the 'On' button in the box menu."),
I("If the bot returns to its box right away, you will likely need to charge it with electrical energy (techage) first."),
I("The bot then runs straight up until it reaches an obstacle (a step with two or more blocks up or down or a sign.)"),
I("If the bot first reaches a sign it will execute the commands on the sign."),
I("If the command(s) on the sign is e.g. 'turn_around', the bot turns and goes back."),

View File

@ -60,5 +60,6 @@ dofile(MP.."/techage.lua")
dofile(MP.."/timer.lua")
dofile(MP.."/delayer.lua")
dofile(MP.."/logic_and.lua")
dofile(MP.."/compost.lua")
dofile(MP.."/tool.lua")

View File

@ -1,4 +1,4 @@
#!/bin/bash
../intllib/tools/xgettext.sh ./basis.lua ./bot_flap.lua ./bot_sensor.lua ./cart_sensor.lua ./changer.lua ./chest.lua ./cmd_farming.lua ./cmd_flowers.lua ./cmd_item.lua ./cmd_move.lua ./cmd_pattern.lua ./cmd_place.lua ./cmd_sign.lua ./commands.lua ./crop_sensor.lua ./doc.lua ./duplicator.lua ./extender.lua ./init.lua ./lib.lua ./node_sensor.lua ./nodes.lua ./robot.lua ./signal.lua ./signs.lua ./tool.lua ./timer.lua ./delayer.lua ./logic_and.lua ./interpreter.lua
../intllib/tools/xgettext.sh ./basis.lua ./bot_flap.lua ./bot_sensor.lua ./cart_sensor.lua ./changer.lua ./chest.lua ./cmd_farming.lua ./cmd_flowers.lua ./cmd_item.lua ./cmd_move.lua ./cmd_pattern.lua ./cmd_place.lua ./cmd_sign.lua ./commands.lua ./crop_sensor.lua ./doc.lua ./duplicator.lua ./extender.lua ./init.lua ./lib.lua ./node_sensor.lua ./nodes.lua ./robot.lua ./signal.lua ./signs.lua ./tool.lua ./timer.lua ./delayer.lua ./logic_and.lua ./interpreter.lua ./compost.lua

Binary file not shown.

View File

@ -7,15 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-23 17:16+0200\n"
"PO-Revision-Date: 2020-06-23 17:19+0200\n"
"POT-Creation-Date: 2021-03-08 19:24+0100\n"
"PO-Revision-Date: 2021-03-08 19:24+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"X-Generator: Poedit 2.3\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: basis.lua
@ -304,11 +304,11 @@ msgstr "Der Roboter dreht um, wenn er fertig ist."
#: cmd_flowers.lua
msgid ""
"Cutting flowers\n"
"Cutting flowers and tree blocks\n"
"in front of the robot\n"
"on a 3x3 field."
msgstr ""
"Schneide Blumen\n"
"Schneide Blumen und Baumblöcke\n"
"in einem 3x3 großem Feld\n"
"vor dem Roboter."
@ -844,6 +844,14 @@ msgstr ""
"Nachdem du die Roboter-Kiste platziert hast, kannst du den Roboter über den "
"\"An\" Button im Kistenmenü starten."
#: doc.lua
msgid ""
"If the bot returns to its box right away, you will likely need to charge it "
"with electrical energy (techage) first."
msgstr ""
"Wenn der Bot sofort in seine Box zurückkehrt, musst du ihn wahrscheinlich "
"zuerst mit elektrischer Energie (Techage) aufladen."
#: doc.lua
msgid ""
"The bot then runs straight up until it reaches an obstacle (a step with two "
@ -1627,6 +1635,29 @@ msgstr "Es fehlt ein 'end'"
msgid "Checked and approved"
msgstr "Geprüft und genehmigt"
#: compost.lua
#, fuzzy
msgid ""
"Put 4 leaves into the compost barrel\n"
"<slot> is the bot inventory slot (1..8)\n"
"with the leaves."
msgstr ""
"Lege 4 Blätter in den Kompostbehälter.\n"
"<slot> ist die Position im\n"
"Bot Inventar (1..8) mit den Blättern."
#: compost.lua
msgid ""
"Take a compost item from the barrel.\n"
"<slot> (1..8 or 0 for the first free slot) is the bot\n"
"slot for the compost item."
msgstr ""
"Nimm einen Kompostblock aus dem\n"
"Kompostbehälter. <slot> ist die Position im\n"
"Bot Inventar für den Block.\n"
"Werte für <slot>: 0..8, oder 0 für die erste\n"
"freie Inventarposition."
#~ msgid "'return' missing"
#~ msgstr "Es fehlt ein 'return'"

View File

@ -7,15 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-30 15:09+0200\n"
"PO-Revision-Date: 2020-05-30 15:14+0200\n"
"POT-Creation-Date: 2021-03-08 19:16+0100\n"
"PO-Revision-Date: 2021-03-08 19:24+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"X-Generator: Poedit 2.3\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: basis.lua
@ -304,11 +304,11 @@ msgstr "Der Roboter dreht um, wenn er fertig ist."
#: cmd_flowers.lua
msgid ""
"Cutting flowers\n"
"Cutting flowers and tree blocks\n"
"in front of the robot\n"
"on a 3x3 field."
msgstr ""
"Schneide Blumen\n"
"Schneide Blumen und Baumblöcke\n"
"in einem 3x3 großem Feld\n"
"vor dem Roboter."
@ -784,14 +784,13 @@ msgid "jump to a label"
msgstr "Sprung zu einer Marke"
#: commands.lua
#, fuzzy
msgid ""
"Move the robot 1..999 steps forward\n"
"without paying attention to any signs.\n"
"Up and down movements also become\n"
"counted as steps."
msgstr ""
"Bewege den Roboter 1..99 Schritte\n"
"Bewege den Roboter 1..999 Schritte\n"
"vorwärts ohne auf Zeichen zu achten.\n"
"Auf- und Ab-Bewegungen werden auch\n"
"als Schritte gezählt."
@ -821,10 +820,12 @@ msgid "Crop Sensor"
msgstr "Ernte Sensor"
#: crop_sensor.lua
msgid "The Crop Sensor sends a signal when, for example wheat is fully grown."
msgid ""
"The Crop Sensor sends cyclical signals when, for example, wheat is fully "
"grown."
msgstr ""
"Der Ernte Sensor sendet ein Signal, wenn bspw. der Weizen voll ausgewachsen "
"ist."
"Der Ernte Sensor sendet zyklisch ein Signal, wenn bspw. der Weizen voll "
"ausgewachsen ist."
#: crop_sensor.lua
msgid "The sensor range is one node/meter."
@ -843,6 +844,14 @@ msgstr ""
"Nachdem du die Roboter-Kiste platziert hast, kannst du den Roboter über den "
"\"An\" Button im Kistenmenü starten."
#: doc.lua
msgid ""
"If the bot returns to its box right away, you will likely need to charge it "
"with electrical energy (techage) first."
msgstr ""
"Wenn der Bot sofort in seine Box zurückkehrt, musst du ihn wahrscheinlich "
"zuerst mit elektrischer Energie (Techage) aufladen."
#: doc.lua
msgid ""
"The bot then runs straight up until it reaches an obstacle (a step with two "
@ -1425,10 +1434,10 @@ msgstr "Block Sensor"
#: node_sensor.lua
msgid ""
"The node sensor can send a signal when it detects that nodes appear or "
"disappear,"
"The node sensor sends cyclical signals when it detects that nodes have "
"appeared or disappeared,"
msgstr ""
"Der Block Sensor kann ein Signal senden, wenn er eine Veränderung von "
"Der Block Sensor sendet zyklisch ein Signal, wenn er eine Veränderung von "
"Blöcken vor sich entdeckt (ein Block erscheint oder verschwindet),"
#: node_sensor.lua
@ -1602,6 +1611,10 @@ msgstr "Signal wird gesendet, wenn all Eingangssignale empfangen wurden."
msgid "Maximum programm size exceeded"
msgstr "Maximale Programmlänge überschritten"
#: interpreter.lua
msgid "Too many parameters"
msgstr "Zu viele Parameter"
#: interpreter.lua
msgid "Parameter error"
msgstr "Parameter Fehler"
@ -1618,18 +1631,38 @@ msgstr "Es fehlt ein 'repeat'"
msgid "'end' missing"
msgstr "Es fehlt ein 'end'"
#: interpreter.lua
msgid "'return' missing"
msgstr "Es fehlt ein 'return'"
#: interpreter.lua
msgid "'call' missing"
msgstr "Es fehlt ein 'call'"
#: interpreter.lua
msgid "Checked and approved"
msgstr "Geprüft und genehmigt"
#: compost.lua
msgid ""
"Put leaves into the compost barrel\n"
"<slot> is the bot inventory slot (1..8)\n"
"with the leaves."
msgstr ""
"Lege 4 Blätter in den Kompostbehälter.\n"
"<slot> ist die Position im\n"
"Bot Inventar (1..8) mit den Blättern."
#: compost.lua
msgid ""
"Take a compost item from the barrel.\n"
"<slot> (1..8 or 0 for the first free slot) is the bot\n"
"slot for the compost item."
msgstr ""
"Nimm einen Kompostblock aus dem\n"
"Kompostbehälter. <slot> ist die Position im\n"
"Bot Inventar für den Block.\n"
"Werte für <slot>: 0..8, oder 0 für die erste\n"
"freie Inventarposition."
#~ msgid "'return' missing"
#~ msgstr "Es fehlt ein 'return'"
#~ msgid "'call' missing"
#~ msgstr "Es fehlt ein 'call'"
#~ msgid ""
#~ "Take <num> items from a chest like node\n"
#~ "and put it into the item inventory.\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-23 17:16+0200\n"
"POT-Creation-Date: 2021-03-08 19:24+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -274,7 +274,7 @@ msgstr ""
#: cmd_flowers.lua
msgid ""
"Cutting flowers\n"
"Cutting flowers and tree blocks\n"
"in front of the robot\n"
"on a 3x3 field."
msgstr ""
@ -684,6 +684,12 @@ msgid ""
"the 'On' button in the box menu."
msgstr ""
#: doc.lua
msgid ""
"If the bot returns to its box right away, you will likely need to charge it "
"with electrical energy (techage) first."
msgstr ""
#: doc.lua
msgid ""
"The bot then runs straight up until it reaches an obstacle (a step with two "
@ -1354,3 +1360,17 @@ msgstr ""
#: interpreter.lua
msgid "Checked and approved"
msgstr ""
#: compost.lua
msgid ""
"Put 4 leaves into the compost barrel\n"
"<slot> is the bot inventory slot (1..8)\n"
"with the leaves."
msgstr ""
#: compost.lua
msgid ""
"Take a compost item from the barrel.\n"
"<slot> (1..8 or 0 for the first free slot) is the bot\n"
"slot for the compost item."
msgstr ""

View File

@ -79,7 +79,9 @@ minetest.register_node("signs_bot:robot", {
sunlight_propagates = true,
is_ground_content = false,
drop = "",
groups = {cracky=1, not_in_creative_inventory = 1},
groups = {cracky=1, not_in_creative_inventory = 1,
plant = 1, -- prevents the transformation from wet soil to soil
},
sounds = default.node_sound_metal_defaults(),
})
@ -116,6 +118,8 @@ minetest.register_node("signs_bot:robot_foot", {
sunlight_propagates = true,
is_ground_content = false,
drop = "",
groups = {cracky=1, not_in_creative_inventory = 1},
groups = {cracky=1, not_in_creative_inventory = 1,
plant = 1, -- prevents the transformation from wet soil to soil
},
sounds = default.node_sound_metal_defaults(),
})

View File

@ -130,6 +130,10 @@ if minetest.get_modpath("techage") then
Cable:add_secondary_node_names({"signs_bot:box"})
techage.register_node({"signs_bot:box"}, {
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "main"
end,
on_pull_item = function(pos, in_dir, num)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -186,6 +190,10 @@ if minetest.get_modpath("techage") then
end,
})
techage.register_node({"signs_bot:chest"}, {
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "main"
end,
on_pull_item = function(pos, in_dir, num)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()