diff --git a/README.md b/README.md index c8c0eb3..b2c1813 100644 --- a/README.md +++ b/README.md @@ -110,3 +110,4 @@ optional: farming redo - 2019-04-14 v0.05 * timer added, user signs added, bug fixes - 2019-04-15 v0.06 * nodes remove bugfix, punch_cart command added, cart sensor added - 2019-04-18 v0.07 * node_io is now optional, support for MTG chests and furnace added +- 2019-05-22 v0.08 * recipe bug fixes and prepared for techage diff --git a/basis.lua b/basis.lua index 4b7b1a0..7083e91 100644 --- a/basis.lua +++ b/basis.lua @@ -24,18 +24,21 @@ local I,_ = dofile(MP.."/intllib.lua") local lib = signs_bot.lib local CYCLE_TIME = 1 +local MAX_CAPA = 100 local function formspec(pos, mem) mem.running = mem.running or false local cmnd = mem.running and "stop;"..I("Off") or "start;"..I("On") - local bot = not mem.running and "image[0.5,1;1,1;signs_bot_bot_inv.png]" or "" + local bot = not mem.running and "image[0.6,1;1,1;signs_bot_bot_inv.png]" or "" + local current_capa = mem.capa or 95 return "size[9,7.6]".. default.gui_bg.. default.gui_bg_img.. default.gui_slots.. "label[2.1,0;"..I("Signs").."]label[5.3,0;"..I("Other items").."]".. - "image[0.5,1;1,1;signs_bot_form_mask.png]".. + "image[0.6,1;1,1;signs_bot_form_mask.png]".. bot.. + signs_bot.formspec_battery_capa(MAX_CAPA, current_capa).. "label[2.1,0.5;1]label[3.1,0.5;2]label[4.1,0.5;3]".. "list[context;sign;1.8,1;3,2;]".. "label[2.1,3;4]label[3.1,3;5]label[4.1,3;6]".. @@ -244,12 +247,52 @@ minetest.register_node("signs_bot:box", { }) -minetest.register_craft({ - output = "signs_bot:box", - recipe = { - {"default:steel_ingot", "group:wood", "default:steel_ingot"}, - {"basic_materials:motor", "default:mese_crystal", "basic_materials:gear_steel"}, - {"default:tin_ingot", "", "default:tin_ingot"} - } -}) +if minetest.global_exists("techage") then + minetest.register_craft({ + output = "signs_bot:box", + recipe = { + {"default:steel_ingot", "group:wood", "default:steel_ingot"}, + {"basic_materials:motor", "techage:wlanchip", "basic_materials:gear_steel"}, + {"default:tin_ingot", "", "default:tin_ingot"} + } + }) +else + minetest.register_craft({ + output = "signs_bot:box", + recipe = { + {"default:steel_ingot", "group:wood", "default:steel_ingot"}, + {"basic_materials:motor", "default:mese_crystal", "basic_materials:gear_steel"}, + {"default:tin_ingot", "", "default:tin_ingot"} + } + }) +end +if minetest.global_exists("techage") then + techage.register_node("signs_bot:box", {}, { + on_pull_item = function(pos, in_dir, num) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.get_items(inv, "main", num) + end, + on_push_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_items(inv, "main", stack) + end, + on_unpull_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_items(inv, "main", stack) + end, + + on_recv_message = function(pos, topic, payload) + if topic == "state" then + local meta = minetest.get_meta(pos) + return techage.get_inv_state(meta, "main") + else + return "unsupported" + end + end, + }) + +end diff --git a/cmd_sign.lua b/cmd_sign.lua index 402950e..44d2c55 100644 --- a/cmd_sign.lua +++ b/cmd_sign.lua @@ -347,6 +347,6 @@ minetest.register_craft({ recipe = { {"group:wood", "default:stick", "group:wood"}, {"dye:yellow", "default:stick", "dye:yellow"}, - {"", "", ""} + {"", "dye:black", ""} } }) diff --git a/init.lua b/init.lua index e223db3..1ccd97a 100644 --- a/init.lua +++ b/init.lua @@ -42,6 +42,7 @@ dofile(MP.."/crop_sensor.lua") dofile(MP.."/cart_sensor.lua") dofile(MP.."/chest.lua") dofile(MP.."/legacy.lua") +dofile(MP.."/techage.lua") dofile(MP.."/timer.lua") dofile(MP.."/tool.lua") diff --git a/locale/de.mo b/locale/de.mo index 7073724..3e1b3d8 100644 Binary files a/locale/de.mo and b/locale/de.mo differ diff --git a/locale/de.po b/locale/de.po index b3c4f48..9b12c1a 100644 --- a/locale/de.po +++ b/locale/de.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2019-04-15 20:53+0200\n" -"PO-Revision-Date: 2019-04-15 20:56+0200\n" +"PO-Revision-Date: 2019-05-22 15:05+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: de\n" @@ -187,13 +187,13 @@ msgstr "" msgid "Move the robot upwards" msgstr "" "Bewege den Roboter\n" -"nach unten" +"nach oben" #: cmd_move.lua msgid "Move the robot down" msgstr "" "Bewege den Roboter\n" -"nach oben." +"nach unten." #: cmd_move.lua msgid "" diff --git a/mod.conf b/mod.conf index f5750b6..0f6fe02 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name=signs_bot depends = default,farming,basic_materials,tubelib2 -optional_depends = node_io +optional_depends = node_io,techage description = A robot controlled by signs \ No newline at end of file diff --git a/techage.lua b/techage.lua new file mode 100644 index 0000000..be9fe3d --- /dev/null +++ b/techage.lua @@ -0,0 +1,44 @@ +if minetest.global_exists("techage") then + signs_bot.register_inventory({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4"}, { + allow_inventory_put = function(pos, stack, player_name) + return not minetest.is_protected(pos, player_name) + end, + allow_inventory_take = function(pos, stack, player_name) + return not minetest.is_protected(pos, player_name) + end, + put = { + listname = "main", + }, + take = { + listname = "main", + }, + }) + signs_bot.register_inventory({"techage:meltingpot", "techage:meltingpot_active"}, { + allow_inventory_put = function(pos, stack, player_name) + return not minetest.is_protected(pos, player_name) + end, + allow_inventory_take = function(pos, stack, player_name) + return not minetest.is_protected(pos, player_name) + end, + put = { + listname = "src", + }, + take = { + listname = "dst", + }, + }) + + local function percent_value(max_val, curr_val) + return math.min(math.ceil(((curr_val or 0) * 100.0) / (max_val or 1.0)), 100) + end + + function signs_bot.formspec_battery_capa(max_capa, current_capa) + local percent = percent_value(max_capa, current_capa) + return "image[0.1,1;0.5,1;signs_bot_form_level_bg.png^[lowpart:".. + percent..":signs_bot_form_level_fg.png]" + end +else + function signs_bot.formspec_battery_capa(max_capa, current_capa) + return "" + end +end \ No newline at end of file diff --git a/textures/signs_bot_form_level_bg.png b/textures/signs_bot_form_level_bg.png new file mode 100644 index 0000000..052698a Binary files /dev/null and b/textures/signs_bot_form_level_bg.png differ diff --git a/textures/signs_bot_form_level_fg.png b/textures/signs_bot_form_level_fg.png new file mode 100644 index 0000000..1620ceb Binary files /dev/null and b/textures/signs_bot_form_level_fg.png differ diff --git a/timer.lua b/timer.lua index e22a165..e12e822 100644 --- a/timer.lua +++ b/timer.lua @@ -165,7 +165,7 @@ minetest.register_craft({ output = "signs_bot:timer", recipe = { {"", "", ""}, - {"dye:black", "group:stone", "dye:yellow"}, + {"dye:yellow", "group:stone", "dye:black"}, {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"} } })