From 4af53a955986511b7ffec43b1be344c0bc78f2d1 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Thu, 2 Aug 2018 20:01:55 +0300 Subject: [PATCH] Some fixes --- elepower_wireless/machines/dialler.lua | 6 +++++ .../machines/matter_receiver.lua | 1 + .../machines/matter_transmitter.lua | 26 ++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/elepower_wireless/machines/dialler.lua b/elepower_wireless/machines/dialler.lua index 02acb64..4d35f10 100644 --- a/elepower_wireless/machines/dialler.lua +++ b/elepower_wireless/machines/dialler.lua @@ -42,6 +42,7 @@ local function get_formspec(power, player, transmitters, receivers) ele.formspec.power_meter(power).. "textlist[1,0;6.8,2.5;transmitter;" .. table.concat(list_tr, ",") .. tr_spc .. "]".. "textlist[1,3;6.8,2.5;receiver;" .. table.concat(list_re, ",") .. re_spc .. "]".. + "button[6,5.75;2,0.25;refresh;Refresh]".. "label[0,5.75;Owned by " .. player .. "]".. "list[current_player;main;0,6.25;8,1;]".. "list[current_player;main;0,7.5;8,3;8]".. @@ -158,6 +159,11 @@ ele.register_machine("elepower_wireless:dialler", { return end + if fields["refresh"] then + minetest.get_node_timer(pos):start(0.2) + return + end + if not fields["transmitter"] and not fields["receiver"] then return end diff --git a/elepower_wireless/machines/matter_receiver.lua b/elepower_wireless/machines/matter_receiver.lua index 3d02687..e50d046 100644 --- a/elepower_wireless/machines/matter_receiver.lua +++ b/elepower_wireless/machines/matter_receiver.lua @@ -106,6 +106,7 @@ ele.register_machine("elepower_wireless:matter_receiver", { local meta = minetest.get_meta(pos) if fields["name"] and fields["key_enter"] == "true" then meta:set_string("name", fields["name"]) + minetest.get_node_timer(pos):start(0.2) end end, after_destruct = function (pos) diff --git a/elepower_wireless/machines/matter_transmitter.lua b/elepower_wireless/machines/matter_transmitter.lua index ef79ded..5d0e81b 100644 --- a/elepower_wireless/machines/matter_transmitter.lua +++ b/elepower_wireless/machines/matter_transmitter.lua @@ -141,19 +141,25 @@ minetest.register_abm({ local tpos = minetest.string_to_pos(meta:get_string("target")) if tpos then - local storage = ele.helpers.get_node_property(meta, pos, "storage") - local usage = ele.helpers.get_node_property(meta, pos, "usage") + local tnode = minetest.get_node_or_nil(tpos) + if tnode and ele.helpers.get_item_group(tnode.name, "matter_receiver") then + local storage = ele.helpers.get_node_property(meta, pos, "storage") + local usage = ele.helpers.get_node_property(meta, pos, "usage") - if storage >= usage then - local top = vector.add(tpos, {x = 0, y = 1, z = 0}) - local topnode = minetest.get_node_or_nil(top) + if storage >= usage then + local top = vector.add(tpos, {x = 0, y = 1, z = 0}) + local topnode = minetest.get_node_or_nil(top) - if not topnode or topnode.name == "air" then - player:set_pos(top) - meta:set_int("storage", storage - usage) - -- TODO: Sound - break + if not topnode or topnode.name == "air" then + player:set_pos(top) + meta:set_int("storage", storage - usage) + -- TODO: Sound + break + end end + else + meta:set_string("target", "") + minetest.get_node_timer(pos):start(0.2) end end end