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
|
return true
|
||||||
end
|
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)
|
function NodeStates:new(attr)
|
||||||
local o = {
|
local o = {
|
||||||
-- mandatory
|
-- mandatory
|
||||||
@ -160,9 +169,7 @@ function NodeStates:stop(pos, mem)
|
|||||||
end
|
end
|
||||||
mem.techage_state = STOPPED
|
mem.techage_state = STOPPED
|
||||||
if self.node_name_passive then
|
if self.node_name_passive then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_passive)
|
||||||
node.name = self.node_name_passive
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
local number = mem.techage_number
|
||||||
@ -196,9 +203,7 @@ function NodeStates:start(pos, mem, called_from_on_timer)
|
|||||||
self.stop_timer = true
|
self.stop_timer = true
|
||||||
end
|
end
|
||||||
if self.node_name_active then
|
if self.node_name_active then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_active)
|
||||||
node.name = self.node_name_active
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
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
|
-- timer has to be stopped once to be able to be restarted
|
||||||
self.stop_timer = true
|
self.stop_timer = true
|
||||||
if self.node_name_passive then
|
if self.node_name_passive then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_passive)
|
||||||
node.name = self.node_name_passive
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
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
|
-- timer has to be stopped once to be able to be restarted
|
||||||
self.stop_timer = true
|
self.stop_timer = true
|
||||||
if self.node_name_passive then
|
if self.node_name_passive then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_passive)
|
||||||
node.name = self.node_name_passive
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
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
|
if mem.techage_state == RUNNING or mem.techage_state == STOPPED then
|
||||||
mem.techage_state = FAULT
|
mem.techage_state = FAULT
|
||||||
if self.node_name_passive then
|
if self.node_name_passive then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_passive)
|
||||||
node.name = self.node_name_passive
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
local number = mem.techage_number
|
||||||
@ -286,9 +285,7 @@ end
|
|||||||
function NodeStates:defect(pos, mem)
|
function NodeStates:defect(pos, mem)
|
||||||
mem.techage_state = DEFECT
|
mem.techage_state = DEFECT
|
||||||
if self.node_name_defect then
|
if self.node_name_defect then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_defect)
|
||||||
node.name = self.node_name_defect
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.infotext_name then
|
if self.infotext_name then
|
||||||
local number = mem.techage_number
|
local number = mem.techage_number
|
||||||
@ -453,9 +450,7 @@ function NodeStates:on_node_repair(pos)
|
|||||||
if mem.techage_state == DEFECT then
|
if mem.techage_state == DEFECT then
|
||||||
mem.techage_state = STOPPED
|
mem.techage_state = STOPPED
|
||||||
if self.node_name_passive then
|
if self.node_name_passive then
|
||||||
local node = minetest.get_node(pos)
|
swap_node(pos, self.node_name_passive)
|
||||||
node.name = self.node_name_passive
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
end
|
end
|
||||||
if self.aging_level1 then
|
if self.aging_level1 then
|
||||||
mem.techage_aging = 0
|
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)
|
minetest.after(0.2, check_power_consumption, pos)
|
||||||
end
|
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)
|
function techage.consumer_after_dig_node(pos, oldnode)
|
||||||
TN(oldnode).power_network:after_dig_node(pos)
|
TN(oldnode).power_network:after_dig_node(pos)
|
||||||
tubelib2.del_mem(pos)
|
tubelib2.del_mem(pos)
|
||||||
|
@ -28,7 +28,8 @@ local Cable = tubelib2.Tube:new({
|
|||||||
show_infotext = false,
|
show_infotext = false,
|
||||||
force_to_use_tubes = true,
|
force_to_use_tubes = true,
|
||||||
primary_node_names = {"techage:electric_cableS", "techage:electric_cableA"},
|
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)
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32})
|
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32})
|
||||||
M(pos):set_int("tl2_param2", param2)
|
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;]"..
|
"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").."]"..
|
"button[5.5,1.2;1.8,1;update;"..I("Update").."]"..
|
||||||
"list[current_player;main;0,3;8,4;]"..
|
"list[current_player;main;0,3;8,4;]"..
|
||||||
"listring[current_name;water]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
default.get_hotbar_bg(0, 3)
|
default.get_hotbar_bg(0, 3)
|
||||||
end
|
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/steam_pipe.lua")
|
||||||
dofile(MP.."/steam_engine/firebox.lua")
|
dofile(MP.."/steam_engine/firebox.lua")
|
||||||
dofile(MP.."/steam_engine/boiler.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/flywheel.lua")
|
||||||
dofile(MP.."/steam_engine/gearbox.lua")
|
dofile(MP.."/steam_engine/gearbox.lua")
|
||||||
dofile(MP.."/steam_engine/consumer.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/electric_cable.lua")
|
||||||
dofile(MP.."/electric/test.lua")
|
dofile(MP.."/electric/test.lua")
|
||||||
dofile(MP.."/electric/generator.lua")
|
dofile(MP.."/electric/generator.lua")
|
||||||
|
dofile(MP.."/electric/consumer.lua")
|
||||||
|
|
||||||
|
|
||||||
--dofile(MP.."/fermenter/biogas_pipe.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},
|
dirs_to_check = {1,2,3,4,5,6},
|
||||||
max_tube_length = 6,
|
max_tube_length = 6,
|
||||||
show_infotext = false,
|
show_infotext = false,
|
||||||
|
force_to_use_tubes = true,
|
||||||
primary_node_names = {"techage:steam_pipeS", "techage:steam_pipeA"},
|
primary_node_names = {"techage:steam_pipeS", "techage:steam_pipeA"},
|
||||||
secondary_node_names = {"techage:cylinder", "techage:cylinder_on", "techage:boiler2"},
|
secondary_node_names = {"techage:cylinder", "techage:cylinder_on", "techage:boiler2"},
|
||||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
|
Loading…
Reference in New Issue
Block a user