diff --git a/basic_machines/autocrafter.lua b/basic_machines/autocrafter.lua index 0723b69..18e940a 100644 --- a/basic_machines/autocrafter.lua +++ b/basic_machines/autocrafter.lua @@ -355,7 +355,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) return CRD(pos).State:on_receive_message(pos, topic, payload) end, on_node_load = function(pos) diff --git a/basic_machines/chest.lua b/basic_machines/chest.lua index 3d60697..34772c3 100644 --- a/basic_machines/chest.lua +++ b/basic_machines/chest.lua @@ -33,7 +33,7 @@ local function send_off_command(pos) local numbers = meta:get_string("numbers") or "" if numbers ~= "" then local own_num = meta:get_string("node_number") - techage.send_multi(numbers, "off", own_num) + techage.send_multi(own_num, numbers, "off") end end @@ -43,7 +43,7 @@ local function send_command(pos) local numbers = meta:get_string("numbers") or "" if numbers ~= "" then local own_num = meta:get_string("node_number") - techage.send_multi(numbers, "on", own_num) + techage.send_multi(own_num, numbers, "on") minetest.after(1, send_off_command, pos) end end @@ -254,7 +254,7 @@ techage.register_node({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ return techage.put_items(inv, "main", stack) end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) if topic == "state" then local meta = minetest.get_meta(pos) local inv = meta:get_inventory() diff --git a/basic_machines/distributor.lua b/basic_machines/distributor.lua index 2390099..b1e7668 100644 --- a/basic_machines/distributor.lua +++ b/basic_machines/distributor.lua @@ -326,7 +326,7 @@ local tubing = { local inv = M(pos):get_inventory() return techage.put_items(inv, "src", stack) end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) if topic == "info" then return INFO elseif topic == "port" then diff --git a/basic_machines/electronic_fab.lua b/basic_machines/electronic_fab.lua index f635e33..c512fbd 100644 --- a/basic_machines/electronic_fab.lua +++ b/basic_machines/electronic_fab.lua @@ -216,7 +216,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/basic_machines/gravelrinser.lua b/basic_machines/gravelrinser.lua index 05623f7..05720e5 100644 --- a/basic_machines/gravelrinser.lua +++ b/basic_machines/gravelrinser.lua @@ -234,7 +234,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/basic_machines/gravelsieve.lua b/basic_machines/gravelsieve.lua index 4682ab7..4e52816 100644 --- a/basic_machines/gravelsieve.lua +++ b/basic_machines/gravelsieve.lua @@ -171,7 +171,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/basic_machines/grinder.lua b/basic_machines/grinder.lua index 102de92..09e8d2a 100644 --- a/basic_machines/grinder.lua +++ b/basic_machines/grinder.lua @@ -182,7 +182,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) return CRD(pos).State:on_receive_message(pos, topic, payload) end, on_node_load = function(pos) diff --git a/basic_machines/pusher.lua b/basic_machines/pusher.lua index 7a27276..4a6ed18 100644 --- a/basic_machines/pusher.lua +++ b/basic_machines/pusher.lua @@ -110,7 +110,7 @@ tiles.act = { local tubing = { is_pusher = true, -- is a pulling/pushing node - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/basis/command.lua b/basis/command.lua index b8f0e06..85ce9a2 100644 --- a/basis/command.lua +++ b/basis/command.lua @@ -247,7 +247,7 @@ end -- on_pull_item = func(pos, in_dir, num), -- on_push_item = func(pos, in_dir, item), -- on_unpull_item = func(pos, in_dir, item), --- on_recv_message = func(pos, topic, payload), +-- on_recv_message = func(pos, src, topic, payload), -- on_node_load = func(pos), -- LBM function -- on_transfer = func(pos, in_dir, topic, payload), -- } @@ -299,22 +299,22 @@ function techage.check_numbers(numbers, placer_name) return false end -function techage.send_multi(numbers, topic, payload) +function techage.send_multi(src, numbers, topic, payload) for _,num in ipairs(string_split(numbers, " ")) do if Number2Pos[num] and Number2Pos[num].name then local data = Number2Pos[num] if data.pos and NodeDef[data.name] and NodeDef[data.name].on_recv_message then - NodeDef[data.name].on_recv_message(data.pos, topic, payload) + NodeDef[data.name].on_recv_message(data.pos, src, topic, payload) end end end end -function techage.send_single(number, topic, payload) +function techage.send_single(src, number, topic, payload) if Number2Pos[number] and Number2Pos[number].name then local data = Number2Pos[number] if data.pos and NodeDef[data.name] and NodeDef[data.name].on_recv_message then - return NodeDef[data.name].on_recv_message(data.pos, topic, payload) + return NodeDef[data.name].on_recv_message(data.pos, src, topic, payload) end end return false diff --git a/basis/consumer.lua b/basis/consumer.lua index 209b08c..d960439 100644 --- a/basis/consumer.lua +++ b/basis/consumer.lua @@ -99,7 +99,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState if validStates[stage] then local on_recv_message = tNode.tubing.on_recv_message if stage > 2 then - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) return "unsupported" end end diff --git a/basis/lib.lua b/basis/lib.lua index 5c0186f..e35075f 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -169,4 +169,18 @@ function mydbg(topic, text, ...) end print(t..text, unpack({...})) end -end \ No newline at end of file +end + +-- needed for windmill plants +local function determine_ocean_ids() + techage.OceanIdTbl = {} + for name, _ in pairs(minetest.registered_biomes) do + if string.find(name, "ocean") then + local id = minetest.get_biome_id(name) + print(id, name) + techage.OceanIdTbl[id] = true + end + end +end + +determine_ocean_ids() \ No newline at end of file diff --git a/coal_power_station/firebox.lua b/coal_power_station/firebox.lua index 00839fa..c560e13 100644 --- a/coal_power_station/firebox.lua +++ b/coal_power_station/firebox.lua @@ -204,7 +204,7 @@ techage.register_node({"techage:coalfirebox"}, { local inv = meta:get_inventory() return techage.put_items(inv, "fuel", stack) end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) if topic == "state" then if mem.running then diff --git a/coal_power_station/generator.lua b/coal_power_station/generator.lua index c4acede..65da03d 100644 --- a/coal_power_station/generator.lua +++ b/coal_power_station/generator.lua @@ -206,7 +206,7 @@ techage.register_node({"techage:generator", "techage:generator_on"}, { end end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) if topic == "load" then return techage.power.percent(PWR_CAPA, mem.provided) diff --git a/furnace/firebox.lua b/furnace/firebox.lua index 635c7ab..815fdc4 100644 --- a/furnace/firebox.lua +++ b/furnace/firebox.lua @@ -170,7 +170,7 @@ techage.register_node({"techage:furnace_firebox", "techage:furnace_firebox_on"}, local inv = meta:get_inventory() return techage.put_items(inv, "fuel", stack) end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) if topic == "state" then if mem.running then diff --git a/furnace/furnace_top.lua b/furnace/furnace_top.lua index 1214ab9..414be61 100644 --- a/furnace/furnace_top.lua +++ b/furnace/furnace_top.lua @@ -212,7 +212,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/logic/lib.lua b/logic/lib.lua index c7d317d..4d3fa18 100644 --- a/logic/lib.lua +++ b/logic/lib.lua @@ -41,13 +41,13 @@ function techage.logic.send_on(pos, meta, time) if time and time > 0 then minetest.get_node_timer(pos):start(time) end - techage.send_multi(numbers, "on", own_num) + techage.send_multi(own_num, numbers, "on") end function techage.logic.send_off(pos, meta) local own_num = meta:get_string("node_number") or "" local numbers = meta:get_string("numbers") or "" - techage.send_multi(numbers, "off", own_num) + techage.send_multi(own_num, numbers, "off") end function techage.logic.infotext(meta, descr, text) diff --git a/logic/repeater.lua b/logic/repeater.lua index 2b04c39..c76d175 100644 --- a/logic/repeater.lua +++ b/logic/repeater.lua @@ -92,7 +92,7 @@ minetest.register_craft({ }) techage.register_node({"techage:ta3_repeater"}, { - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) mem.overload_cnt = (mem.overload_cnt or 0) + 1 if mem.overload_cnt > OVER_LOAD_MAX then @@ -101,7 +101,7 @@ techage.register_node({"techage:ta3_repeater"}, { return false else local numbers = M(pos):get_string("numbers") or "" - techage.send_multi(numbers, topic, payload) + techage.send_multi(src, numbers, topic, payload) end end, on_node_load = function(pos) diff --git a/logic/sequencer.lua b/logic/sequencer.lua index 3c7c728..74fe3a2 100644 --- a/logic/sequencer.lua +++ b/logic/sequencer.lua @@ -107,7 +107,7 @@ local function check_rules(pos, elapsed) while true do -- process all rules as long as offs == 0 local rule = mem.rules[mem.index] local offs = tonumber(mem.rules[mem.index].offs or 1) - techage.send_multi(rule.num, tAction[rule.act], own_num) + techage.send_multi(own_num, rule.num, tAction[rule.act]) mem.index = get_next_slot(mem.index, mem.rules, mem.endless) if mem.index ~= nil and offs ~= nil and mem.running then -- after the last rule a pause with 1 or more sec is required @@ -251,7 +251,7 @@ minetest.register_craft({ }) techage.register_node({"techage:ta3_sequencer"}, { - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) if topic == "on" then start_the_sequencer(pos) elseif topic == "off" then diff --git a/logic/signallamp.lua b/logic/signallamp.lua index 4f33dbc..5f13ed5 100644 --- a/logic/signallamp.lua +++ b/logic/signallamp.lua @@ -112,8 +112,7 @@ minetest.register_node("techage:signal_lamp_on", { }) techage.register_node({"techage:signal_lamp_off", "techage:signal_lamp_on"}, { - on_recv_message = function(pos, topic, payload) - print("on_recv_message", topic) + on_recv_message = function(pos, src, topic, payload) if topic == "on" then local node = minetest.get_node(pos) switch_on(pos, node) diff --git a/logic/terminal.lua b/logic/terminal.lua index 83fd877..6e619f8 100644 --- a/logic/terminal.lua +++ b/logic/terminal.lua @@ -126,10 +126,11 @@ local function command(pos, command, player) output(pos, S("Switched to private use!")) elseif meta:get_int("public") == 1 or owner == player then output(pos, "$ "..command) + local own_num = meta:get_string("node_number") local num, cmnd, payload = command:match('^cmd%s+([0-9]+)%s+(%w+)%s*(.*)$') if num and cmnd then if techage.not_protected(num, owner, owner) then - local resp = techage.send_single(num, cmnd, payload) + local resp = techage.send_single(own_num, num, cmnd, payload) if type(resp) == "string" then output(pos, resp) else @@ -141,7 +142,7 @@ local function command(pos, command, player) num, cmnd = command:match('^turn%s+([0-9]+)%s+([onf]+)$') if num and (cmnd == "on" or cmnd == "off") then if techage.not_protected(num, owner, owner) then - local resp = techage.send_single(num, cmnd) + local resp = techage.send_single(own_num, num, cmnd) output(pos, dump(resp)) end return @@ -284,8 +285,8 @@ minetest.register_craft({ }) techage.register_node({"techage:terminal1", "techage:terminal2"}, { - on_recv_message = function(pos, topic, payload) - output(pos, "cmd="..dump(topic)..", data="..dump(payload)) + on_recv_message = function(pos, src, topic, payload) + output(pos, "src="..src..", cmd="..dump(topic)..", data="..dump(payload)) return true end, on_node_load = function(pos) diff --git a/logic/timer.lua b/logic/timer.lua index aac4505..96698ec 100644 --- a/logic/timer.lua +++ b/logic/timer.lua @@ -95,7 +95,7 @@ local function check_rules(pos,elapsed) local hr = (events[idx] - 1) * 2 if ((hour - hr) % 24) <= 4 then -- last 4 hours? if mem.done[idx] == false then -- not already executed? - techage.send_multi(numbers[idx], act, number) + techage.send_multi(number, numbers[idx], act) mem.done[idx] = true end else diff --git a/oil/drillbox.lua b/oil/drillbox.lua index cab2f00..b2efcbb 100644 --- a/oil/drillbox.lua +++ b/oil/drillbox.lua @@ -237,7 +237,7 @@ local tubing = { return techage.put_items(inv, "dst", stack) end end, - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/oil/generator.lua b/oil/generator.lua index c3afccc..d695b2b 100644 --- a/oil/generator.lua +++ b/oil/generator.lua @@ -225,7 +225,7 @@ techage.power.register_node({"techage:tiny_generator", "techage:tiny_generator_o }) techage.register_node({"techage:tiny_generator", "techage:tiny_generator_on"}, { - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) if topic == "load" then return power.percent(PWR_CAPA, mem.provided) diff --git a/oil/pumpjack.lua b/oil/pumpjack.lua index 95fc862..8b4cd90 100644 --- a/oil/pumpjack.lua +++ b/oil/pumpjack.lua @@ -141,7 +141,7 @@ tiles.act = { local tubing = { is_pusher = true, -- is a pulling/pushing node - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local resp = CRD(pos).State:on_receive_message(pos, topic, payload) if resp then return resp diff --git a/power/powerswitch.lua b/power/powerswitch.lua index 02dc4d5..f939888 100644 --- a/power/powerswitch.lua +++ b/power/powerswitch.lua @@ -194,7 +194,7 @@ techage.power.register_node({"techage:powerswitch_box"}, { }) techage.register_node({"techage:powerswitch", "techage:powerswitch_on"}, { - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local node = minetest.get_node(pos) if topic == "on" and node.name == "techage:powerswitch" then switch_on(pos, node) diff --git a/solar/minicell.lua b/solar/minicell.lua index fa9c6dc..49d96d7 100644 --- a/solar/minicell.lua +++ b/solar/minicell.lua @@ -108,7 +108,7 @@ techage.power.register_node({"techage:ta4_solar_minicell"}, { }) techage.register_node({"techage:ta4_solar_minicell"}, { - on_recv_message = function(pos, topic, payload) + on_recv_message = function(pos, src, topic, payload) local mem = tubelib2.get_mem(pos) if topic == "state" then if mem.providing then diff --git a/tools/repairkit.lua b/tools/repairkit.lua index 272642f..4db07c5 100644 --- a/tools/repairkit.lua +++ b/tools/repairkit.lua @@ -33,7 +33,11 @@ local function read_state(itemstack, user, pointed_thing) minetest.chat_send_player(user:get_player_name(), S("Time")..": "..hours..":"..mins.." ") local data = minetest.get_biome_data(pos) if data then - minetest.chat_send_player(user:get_player_name(), S("Biome")..": "..data.biome..", "..S("Position temperature")..": "..math.floor(data.heat).." ") + local name = minetest.get_biome_name(data.biome) + minetest.chat_send_player(user:get_player_name(), S("Biome")..": "..name..", "..S("Position temperature")..": "..math.floor(data.heat).." ") + if techage.OceanIdTbl[data.biome] then + minetest.chat_send_player(user:get_player_name(), "Suitable for windmills") + end end local number = techage.get_node_number(pos) local node = minetest.get_node(pos) @@ -48,27 +52,27 @@ local function read_state(itemstack, user, pointed_thing) local ndef = minetest.registered_nodes[node.name] if number then if ndef and ndef.description then - local info = techage.send_single(number, "info", nil) + local info = techage.send_single("0", number, "info", nil) if info and info ~= "" and info ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": Supported Commands:\n"..info.." ") end - local state = techage.send_single(number, "state", nil) + local state = techage.send_single("0", number, "state", nil) if state and state ~= "" and state ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": state = "..state.." ") end - local fuel = techage.send_single(number, "fuel", nil) + local fuel = techage.send_single("0", number, "fuel", nil) if fuel and fuel ~= "" and fuel ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": fuel = "..fuel.." ") end - local counter = techage.send_single(number, "counter", nil) + local counter = techage.send_single("0", number, "counter", nil) if counter and counter ~= "" and counter ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": counter = "..counter.." ") end - local load = techage.send_single(number, "load", nil) + local load = techage.send_single("0", number, "load", nil) if load and load ~= "" and load ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ") end - local power = techage.send_single(number, "power", nil) + local power = techage.send_single("0", number, "power", nil) if power and power ~= "" and power ~= "unsupported" then minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." % ") end @@ -134,4 +138,4 @@ techage.register_entry_page("ta", "end_wrench", S("The TechAge Info Tool is a tool to read any kind of status information from nodes providing a command interface.@n".. "Click on the node to read the status"), "techage:end_wrench") - + \ No newline at end of file