consumer with node_states added
This commit is contained in:
parent
ca4eb4c2c7
commit
6bfd108bf1
@ -110,6 +110,15 @@ local function can_start(pos, mem)
|
||||
return true
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
function NodeStates:new(attr)
|
||||
local o = {
|
||||
-- mandatory
|
||||
@ -160,9 +169,7 @@ function NodeStates:stop(pos, mem)
|
||||
end
|
||||
mem.techage_state = STOPPED
|
||||
if self.node_name_passive then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_passive
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_passive)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -196,9 +203,7 @@ function NodeStates:start(pos, mem, called_from_on_timer)
|
||||
self.stop_timer = true
|
||||
end
|
||||
if self.node_name_active then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_active
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_active)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -221,9 +226,7 @@ function NodeStates:standby(pos, mem)
|
||||
-- timer has to be stopped once to be able to be restarted
|
||||
self.stop_timer = true
|
||||
if self.node_name_passive then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_passive
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_passive)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -245,9 +248,7 @@ function NodeStates:blocked(pos, mem)
|
||||
-- timer has to be stopped once to be able to be restarted
|
||||
self.stop_timer = true
|
||||
if self.node_name_passive then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_passive
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_passive)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -266,9 +267,7 @@ function NodeStates:fault(pos, mem)
|
||||
if mem.techage_state == RUNNING or mem.techage_state == STOPPED then
|
||||
mem.techage_state = FAULT
|
||||
if self.node_name_passive then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_passive
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_passive)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -286,9 +285,7 @@ end
|
||||
function NodeStates:defect(pos, mem)
|
||||
mem.techage_state = DEFECT
|
||||
if self.node_name_defect then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_defect
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_defect)
|
||||
end
|
||||
if self.infotext_name then
|
||||
local number = mem.techage_number
|
||||
@ -453,9 +450,7 @@ function NodeStates:on_node_repair(pos)
|
||||
if mem.techage_state == DEFECT then
|
||||
mem.techage_state = STOPPED
|
||||
if self.node_name_passive then
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = self.node_name_passive
|
||||
minetest.swap_node(pos, node)
|
||||
swap_node(pos, self.node_name_passive)
|
||||
end
|
||||
if self.aging_level1 then
|
||||
mem.techage_aging = 0
|
||||
|
@ -267,6 +267,10 @@ function techage.consumer_after_tube_update(node, pos, out_dir, peer_pos, peer_i
|
||||
minetest.after(0.2, check_power_consumption, pos)
|
||||
end
|
||||
|
||||
function techage.consumer_check_power_consumption(pos)
|
||||
minetest.after(0.2, check_power_consumption, pos)
|
||||
end
|
||||
|
||||
function techage.consumer_after_dig_node(pos, oldnode)
|
||||
TN(oldnode).power_network:after_dig_node(pos)
|
||||
tubelib2.del_mem(pos)
|
||||
|
@ -28,7 +28,8 @@ local Cable = tubelib2.Tube:new({
|
||||
show_infotext = false,
|
||||
force_to_use_tubes = true,
|
||||
primary_node_names = {"techage:electric_cableS", "techage:electric_cableA"},
|
||||
secondary_node_names = {"techage:lamp", "techage:lamp_on", "techage:power"},
|
||||
secondary_node_names = {"techage:lamp", "techage:lamp_on", "techage:power",
|
||||
"techage:ele_consumer", "techage:ele_consumer_on"},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32})
|
||||
M(pos):set_int("tl2_param2", param2)
|
||||
|
@ -20,8 +20,6 @@ local function formspec(self, pos, mem)
|
||||
"image_button[3,1.2;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"button[5.5,1.2;1.8,1;update;"..I("Update").."]"..
|
||||
"list[current_player;main;0,3;8,4;]"..
|
||||
"listring[current_name;water]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 3)
|
||||
end
|
||||
|
||||
|
3
init.lua
3
init.lua
@ -23,7 +23,7 @@ dofile(MP.."/steam_engine/drive_axle.lua")
|
||||
dofile(MP.."/steam_engine/steam_pipe.lua")
|
||||
dofile(MP.."/steam_engine/firebox.lua")
|
||||
dofile(MP.."/steam_engine/boiler.lua")
|
||||
--dofile(MP.."/steam_engine/cylinder.lua")
|
||||
dofile(MP.."/steam_engine/cylinder.lua")
|
||||
--dofile(MP.."/steam_engine/flywheel.lua")
|
||||
dofile(MP.."/steam_engine/gearbox.lua")
|
||||
dofile(MP.."/steam_engine/consumer.lua")
|
||||
@ -31,6 +31,7 @@ dofile(MP.."/steam_engine/consumer.lua")
|
||||
dofile(MP.."/electric/electric_cable.lua")
|
||||
dofile(MP.."/electric/test.lua")
|
||||
dofile(MP.."/electric/generator.lua")
|
||||
dofile(MP.."/electric/consumer.lua")
|
||||
|
||||
|
||||
--dofile(MP.."/fermenter/biogas_pipe.lua")
|
||||
|
@ -26,6 +26,7 @@ local Pipe = tubelib2.Tube:new({
|
||||
dirs_to_check = {1,2,3,4,5,6},
|
||||
max_tube_length = 6,
|
||||
show_infotext = false,
|
||||
force_to_use_tubes = true,
|
||||
primary_node_names = {"techage:steam_pipeS", "techage:steam_pipeA"},
|
||||
secondary_node_names = {"techage:cylinder", "techage:cylinder_on", "techage:boiler2"},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
|
Loading…
Reference in New Issue
Block a user