removed unneeded code
This commit is contained in:
parent
2a6d1519c9
commit
2905a45774
@ -16,44 +16,10 @@
|
|||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local PlayerActions = {}
|
|
||||||
local InventoryState = {}
|
|
||||||
|
|
||||||
|
|
||||||
local function store_action(pos, player, action, stack)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local name = player and player:get_player_name() or ""
|
|
||||||
local number = meta:get_string("node_number")
|
|
||||||
local item = stack:get_name().." "..stack:get_count()
|
|
||||||
PlayerActions[number] = {name, action, item}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function send_off_command(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local numbers = meta:get_string("numbers") or ""
|
|
||||||
if numbers ~= "" then
|
|
||||||
local own_num = meta:get_string("node_number")
|
|
||||||
techage.send_multi(own_num, numbers, "off")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function send_command(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local numbers = meta:get_string("numbers") or ""
|
|
||||||
if numbers ~= "" then
|
|
||||||
local own_num = meta:get_string("node_number")
|
|
||||||
techage.send_multi(own_num, numbers, "on")
|
|
||||||
minetest.after(1, send_off_command, pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
store_action(pos, player, "put", stack)
|
|
||||||
send_command(pos)
|
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,8 +27,6 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
store_action(pos, player, "take", stack)
|
|
||||||
send_command(pos)
|
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -109,11 +73,8 @@ minetest.register_node("techage:chest_ta2", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local number = techage.add_node(pos, "techage:chest_ta2")
|
|
||||||
meta:set_string("node_number", number)
|
|
||||||
meta:set_string("owner", placer:get_player_name())
|
meta:set_string("owner", placer:get_player_name())
|
||||||
meta:set_string("formspec", formspec2())
|
meta:set_string("formspec", formspec2())
|
||||||
meta:set_string("infotext", S("TA2 Protected Chest").." "..number)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
techage_set_numbers = function(pos, numbers, player_name)
|
techage_set_numbers = function(pos, numbers, player_name)
|
||||||
@ -259,17 +220,12 @@ techage.register_node({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return techage.get_inv_state(inv, "main")
|
return techage.get_inv_state(inv, "main")
|
||||||
elseif topic == "player_action" then
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local number = meta:get_string("node_number")
|
|
||||||
return PlayerActions[number]
|
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "techage:chest_ta2",
|
output = "techage:chest_ta2",
|
||||||
@ -279,6 +235,11 @@ minetest.register_craft({
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "techage:chest_ta3",
|
output = "techage:chest_ta3",
|
||||||
recipe = {"techage:chest_ta2", "techage:tubeS", "techage:vacuum_tube"}
|
recipe = {"techage:chest_ta2", "default:chest"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = "techage:chest_ta4",
|
||||||
|
recipe = {"techage:chest_ta3", "default:chest"}
|
||||||
|
})
|
||||||
|
@ -26,8 +26,7 @@ local COUNTDOWN_TICKS = 10
|
|||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
local INFO = [[- Turn port on/off: command = "port", payload = "red/green/blue/yellow=on/off"
|
local INFO = [[Turn port on/off: command = 'port', payload = red/green/blue/yellow=on/off]]
|
||||||
- Clear counter: command = "clear_counter"]]
|
|
||||||
|
|
||||||
|
|
||||||
--local Side2Color = {B="red", L="green", F="blue", R="yellow"}
|
--local Side2Color = {B="red", L="green", F="blue", R="yellow"}
|
||||||
@ -441,12 +440,7 @@ local tubing = {
|
|||||||
local slot, val = techage.ident_value(payload)
|
local slot, val = techage.ident_value(payload)
|
||||||
return change_filter_settings(pos, slot, val)
|
return change_filter_settings(pos, slot, val)
|
||||||
else
|
else
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -193,15 +193,7 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,15 +238,7 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +282,7 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
|
|||||||
num_items = {0,1,1,1},
|
num_items = {0,1,1,1},
|
||||||
power_consumption = {0,3,3,3},
|
power_consumption = {0,3,3,3},
|
||||||
},
|
},
|
||||||
{false, true, true, false}) -- TA2/A3
|
{false, true, true, false}) -- TA2/TA3
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = node_name_ta2,
|
output = node_name_ta2,
|
||||||
|
@ -171,15 +171,7 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,15 +184,7 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +173,6 @@ local tubing = {
|
|||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local node_name_ta2, node_name_ta3, _ =
|
local node_name_ta2, node_name_ta3, _ =
|
||||||
|
@ -115,15 +115,7 @@ local tubing = {
|
|||||||
is_pusher = true, -- is a pulling/pushing node
|
is_pusher = true, -- is a pulling/pushing node
|
||||||
|
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,15 +343,9 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos, node)
|
on_node_load = function(pos, node)
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if nvm.techage_state == techage.RUNNING then
|
if nvm.techage_state == techage.RUNNING then
|
||||||
play_sound(pos)
|
play_sound(pos)
|
||||||
|
@ -145,3 +145,10 @@ function techage.fuel.has_fuel(nvm)
|
|||||||
nvm.liquid.amount = nvm.liquid.amount or 0
|
nvm.liquid.amount = nvm.liquid.amount or 0
|
||||||
return nvm.liquid.amount > 0
|
return nvm.liquid.amount > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function techage.fuel.get_fuel_amount(nvm)
|
||||||
|
if nvm.liquid and nvm.liquid.amount then
|
||||||
|
return nvm.liquid.amount
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
@ -222,6 +222,13 @@ function techage.liquid.on_punch(pos, node, puncher, pointed_thing)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function techage.liquid.get_liquid_amount(nvm)
|
||||||
|
if nvm.liquid and nvm.liquid.amount then
|
||||||
|
return nvm.liquid.amount
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
techage.liquid.get_liquid_def = get_liquid_def
|
techage.liquid.get_liquid_def = get_liquid_def
|
||||||
techage.liquid.get_container_def = get_container_def
|
techage.liquid.get_container_def = get_container_def
|
||||||
techage.liquid.is_container_empty = is_container_empty
|
techage.liquid.is_container_empty = is_container_empty
|
||||||
|
@ -446,23 +446,15 @@ function NodeStates:on_receive_message(pos, topic, payload)
|
|||||||
self:stop(pos, techage.get_nvm(pos))
|
self:stop(pos, techage.get_nvm(pos))
|
||||||
return true
|
return true
|
||||||
elseif topic == "state" then
|
elseif topic == "state" then
|
||||||
local node = techage.get_node_lvm(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "ignore" then -- unloaded node?
|
if node.name == "ignore" then -- unloaded node?
|
||||||
return "unloaded"
|
return "unloaded"
|
||||||
end
|
end
|
||||||
return techage.get_state_string(techage.get_nvm(pos))
|
return techage.get_state_string(techage.get_nvm(pos))
|
||||||
elseif topic == "counter" then
|
|
||||||
return nvm.techage_item_meter or 1
|
|
||||||
elseif topic == "clear_counter" then
|
|
||||||
nvm.techage_item_meter = 0
|
|
||||||
return true
|
|
||||||
elseif topic == "fuel" then
|
elseif topic == "fuel" then
|
||||||
local inv = M(pos):get_inventory()
|
return techage.fuel.get_fuel_amount(nvm)
|
||||||
if inv:get_size("fuel") == 1 then
|
elseif topic == "load" then
|
||||||
local stack = inv:get_stack("fuel", 1)
|
return techage.liquid.get_liquid_amount(nvm)
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
return
|
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
|
@ -304,15 +304,7 @@ minetest.register_node("techage:ta4_doser_on", {
|
|||||||
|
|
||||||
techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
|
techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = State:on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -207,15 +207,9 @@ techage.register_node({"techage:coalfirebox"}, {
|
|||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
if nvm.running then
|
return nvm.running and "running" or "stopped"
|
||||||
return "running"
|
|
||||||
else
|
|
||||||
return "stopped"
|
|
||||||
end
|
|
||||||
elseif topic == "fuel" then
|
elseif topic == "fuel" then
|
||||||
local inv = M(pos):get_inventory()
|
return techage.fuel.get_fuel_amount(nvm)
|
||||||
local stack = inv:get_stack("fuel", 1)
|
|
||||||
return stack:get_count()
|
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
@ -230,17 +224,3 @@ minetest.register_craft({
|
|||||||
{'default:stone', 'default:stone', 'default:stone'},
|
{'default:stone', 'default:stone', 'default:stone'},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "[techage] Power Station firebox",
|
|
||||||
name = "techage:coalfirebox",
|
|
||||||
nodenames = {"techage:coalfirebox"},
|
|
||||||
run_at_every_load = true,
|
|
||||||
action = function(pos, node)
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
nvm.running = true
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ local Cable = techage.ElectricCable
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
local networks = techage.networks
|
local networks = techage.networks
|
||||||
|
|
||||||
|
local INFO = [[Command 'load' returns the current provided power in ku]]
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
return "size[4,4]"..
|
return "size[4,4]"..
|
||||||
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
|
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
|
||||||
@ -222,16 +224,14 @@ techage.register_node({"techage:generator", "techage:generator_on"}, {
|
|||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "load" then
|
if topic == "info" then
|
||||||
return techage.power.percent(PWR_CAPA, nvm.provided)
|
return INFO
|
||||||
|
elseif topic == "load" then
|
||||||
|
return math.floor((nvm.provided or 0) + 0.5)
|
||||||
else
|
else
|
||||||
return State:on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos)
|
|
||||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
|
||||||
State:on_node_load(pos)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -170,13 +170,9 @@ techage.register_node({"techage:oilfirebox"}, {
|
|||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
if nvm.running then
|
return nvm.running and "running" or "stopped"
|
||||||
return "running"
|
|
||||||
else
|
|
||||||
return "stopped"
|
|
||||||
end
|
|
||||||
elseif topic == "fuel" then
|
elseif topic == "fuel" then
|
||||||
return nvm.liquid and nvm.liquid.amount and nvm.liquid.amount
|
return techage.fuel.get_fuel_amount(nvm)
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
@ -192,16 +188,4 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "[techage] Power Station firebox",
|
|
||||||
name = "techage:steam_engine",
|
|
||||||
nodenames = {"techage:oilfirebox"},
|
|
||||||
run_at_every_load = true,
|
|
||||||
action = function(pos, node)
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
nvm.running = true
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +166,6 @@ techage.register_node({"techage:turbine", "techage:turbine_on"}, {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos, node)
|
on_node_load = function(pos, node)
|
||||||
--print("on_node_load", node.name)
|
|
||||||
if node.name == "techage:turbine_on" then
|
if node.name == "techage:turbine_on" then
|
||||||
play_sound(pos)
|
play_sound(pos)
|
||||||
end
|
end
|
||||||
|
@ -25,6 +25,8 @@ local Cable = techage.ElectricCable
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
local networks = techage.networks
|
local networks = techage.networks
|
||||||
|
|
||||||
|
local INFO = [[Command 'load' returns the current provided power in ku]]
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
return "size[4,4]"..
|
return "size[4,4]"..
|
||||||
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
|
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
|
||||||
@ -223,16 +225,14 @@ techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
|
|||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "load" then
|
if topic == "info" then
|
||||||
return techage.power.percent(PWR_CAPA, nvm.provided)
|
return INFO
|
||||||
|
elseif topic == "load" then
|
||||||
|
return math.floor((nvm.provided or 0) + 0.5)
|
||||||
else
|
else
|
||||||
return State:on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos)
|
|
||||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
|
||||||
State:on_node_load(pos)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -32,6 +32,8 @@ local Pipe = techage.LiquidPipe
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
local in_range = techage.in_range
|
local in_range = techage.in_range
|
||||||
|
|
||||||
|
local INFO = [[- Command 'load' returns the storage load in percent]]
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = techage.get_node_lvm(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
@ -115,6 +117,9 @@ local function after_place_node(pos, placer, itemstack)
|
|||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
nvm.capa = 0
|
nvm.capa = 0
|
||||||
M(pos):set_string("owner", placer:get_player_name())
|
M(pos):set_string("owner", placer:get_player_name())
|
||||||
|
local number = techage.add_node(pos, "techage:heatexchanger1")
|
||||||
|
M(pos):set_string("node_number", number)
|
||||||
|
M(pos):set_string("infotext", S("TA4 Heat Exchanger 1").." "..number)
|
||||||
Cable:after_place_node(pos)
|
Cable:after_place_node(pos)
|
||||||
Pipe:after_place_node(pos)
|
Pipe:after_place_node(pos)
|
||||||
end
|
end
|
||||||
@ -250,10 +255,24 @@ techage.register_node({"techage:heatexchanger1"}, {
|
|||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "load" then
|
if topic == "state" then
|
||||||
|
if nvm.charging then
|
||||||
|
return "running"
|
||||||
|
elseif nvm.running then
|
||||||
|
return "standby"
|
||||||
|
else
|
||||||
|
return "stopped"
|
||||||
|
end
|
||||||
|
elseif topic == "load" then
|
||||||
return techage.power.percent(nvm.capa_max, nvm.capa)
|
return techage.power.percent(nvm.capa_max, nvm.capa)
|
||||||
elseif topic == "size" then
|
elseif topic == "on" then
|
||||||
return (nvm.capa_max or 0) / GRVL_CAPA
|
start_node(pos, techage.get_nvm(pos))
|
||||||
|
return true
|
||||||
|
elseif topic == "off" then
|
||||||
|
stop_node(pos, techage.get_nvm(pos))
|
||||||
|
return true
|
||||||
|
elseif topic == "info" then
|
||||||
|
return INFO
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
|
@ -215,13 +215,9 @@ techage.register_node({"techage:furnace_firebox", "techage:furnace_firebox_on"},
|
|||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
if nvm.running then
|
return nvm.running and "running" or "stopped"
|
||||||
return "running"
|
|
||||||
else
|
|
||||||
return "stopped"
|
|
||||||
end
|
|
||||||
elseif topic == "fuel" then
|
elseif topic == "fuel" then
|
||||||
return nvm.liquid and nvm.liquid.amount and nvm.liquid.amount
|
return techage.fuel.get_fuel_amount(nvm)
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
@ -244,15 +240,3 @@ techage.register_node({"techage:furnace_firebox", "techage:furnace_firebox_on"},
|
|||||||
})
|
})
|
||||||
|
|
||||||
Pipe:add_secondary_node_names({"techage:furnace_firebox", "techage:furnace_firebox_on"})
|
Pipe:add_secondary_node_names({"techage:furnace_firebox", "techage:furnace_firebox_on"})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "[techage] Furnace firebox",
|
|
||||||
name = "techage:furnace",
|
|
||||||
nodenames = {"techage:furnace_firebox_on"},
|
|
||||||
run_at_every_load = true,
|
|
||||||
action = function(pos, node)
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
@ -234,15 +234,7 @@ local tubing = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
if resp then
|
|
||||||
return resp
|
|
||||||
else
|
|
||||||
return "unsupported"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_node_load = function(pos)
|
|
||||||
CRD(pos).State:on_node_load(pos)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,21 +234,11 @@ local function read_state(itemstack, user, pointed_thing)
|
|||||||
fuel = dump(fuel)
|
fuel = dump(fuel)
|
||||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": fuel = "..fuel.." ")
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": fuel = "..fuel.." ")
|
||||||
end
|
end
|
||||||
local counter = techage.send_single("0", number, "counter", nil)
|
|
||||||
if counter and counter ~= "" and counter ~= "unsupported" then
|
|
||||||
counter = dump(counter)
|
|
||||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": counter = "..counter.." ")
|
|
||||||
end
|
|
||||||
local load = techage.send_single("0", number, "load", nil)
|
local load = techage.send_single("0", number, "load", nil)
|
||||||
if load and load ~= "" and load ~= "unsupported" then
|
if load and load ~= "" and load ~= "unsupported" then
|
||||||
load = dump(load)
|
load = dump(load)
|
||||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
|
||||||
end
|
end
|
||||||
local size = techage.send_single("0", number, "size", nil)
|
|
||||||
if size and size ~= "" and size ~= "unsupported" then
|
|
||||||
size = dump(size)
|
|
||||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": size = "..size.." units ")
|
|
||||||
end
|
|
||||||
local owner = M(pos):get_string("owner") or ""
|
local owner = M(pos):get_string("owner") or ""
|
||||||
if owner ~= "" then
|
if owner ~= "" then
|
||||||
minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ")
|
minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ")
|
||||||
|
Loading…
Reference in New Issue
Block a user