turn-off logic added to generator
This commit is contained in:
parent
f7043f4e10
commit
ca4eb4c2c7
@ -171,7 +171,9 @@ function NodeStates:stop(pos, mem)
|
|||||||
if self.formspec_func then
|
if self.formspec_func then
|
||||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):stop()
|
if minetest.get_node_timer(pos):is_started() then
|
||||||
|
minetest.get_node_timer(pos):stop()
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -205,7 +207,9 @@ function NodeStates:start(pos, mem, called_from_on_timer)
|
|||||||
if self.formspec_func then
|
if self.formspec_func then
|
||||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(self.cycle_time)
|
if not minetest.get_node_timer(pos):is_started() then
|
||||||
|
minetest.get_node_timer(pos):start(self.cycle_time)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -331,7 +335,9 @@ function NodeStates:keep_running(pos, mem, val, num_items)
|
|||||||
-- set to RUNNING if not already done
|
-- set to RUNNING if not already done
|
||||||
self:start(pos, mem, true)
|
self:start(pos, mem, true)
|
||||||
mem.techage_countdown = val
|
mem.techage_countdown = val
|
||||||
mem.techage_item_meter = mem.techage_item_meter + (num_items or 1)
|
if self.has_item_meter then
|
||||||
|
mem.techage_item_meter = mem.techage_item_meter + (num_items or 1)
|
||||||
|
end
|
||||||
if self.aging_level1 then
|
if self.aging_level1 then
|
||||||
local cnt = mem.techage_aging + num_items
|
local cnt = mem.techage_aging + num_items
|
||||||
mem.techage_aging = cnt
|
mem.techage_aging = cnt
|
||||||
@ -471,9 +477,13 @@ function NodeStates:after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||||
local cnt = mem.techage_aging or 0
|
local cnt = mem.techage_aging or 0
|
||||||
local is_defect = cnt > self.aging_level1 and math.random(self.aging_level2 / cnt) == 1
|
if self.aging_level1 then
|
||||||
if self.node_name_defect and is_defect then
|
local is_defect = cnt > self.aging_level1 and math.random(self.aging_level2 / cnt) == 1
|
||||||
inv:add_item("main", ItemStack(self.node_name_defect))
|
if self.node_name_defect and is_defect then
|
||||||
|
inv:add_item("main", ItemStack(self.node_name_defect))
|
||||||
|
else
|
||||||
|
inv:add_item("main", ItemStack(self.node_name_passive))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
inv:add_item("main", ItemStack(self.node_name_passive))
|
inv:add_item("main", ItemStack(self.node_name_passive))
|
||||||
end
|
end
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
local P = minetest.string_to_pos
|
local P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local TP = function(pos) return minetest.registered_nodes[minetest.get_node(pos).name].techage end
|
local TP = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||||
local TN = function(node) return minetest.registered_nodes[node.name].techage end
|
local TN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
|
||||||
|
|
||||||
|
|
||||||
-- Table to register the different power distribution network instances for global use
|
-- Table to register the different power distribution network instances for global use
|
||||||
@ -63,6 +63,7 @@ end
|
|||||||
|
|
||||||
-- Calculate the power consumption on the given network
|
-- Calculate the power consumption on the given network
|
||||||
local function power_consumption(pos, dir)
|
local function power_consumption(pos, dir)
|
||||||
|
print("power_consumption")
|
||||||
if pos_already_reached(pos) then return 0 end
|
if pos_already_reached(pos) then return 0 end
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
local conn = mem.connections or {}
|
local conn = mem.connections or {}
|
||||||
|
@ -9,7 +9,7 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||||||
|
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 4
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 16
|
||||||
|
|
||||||
local function formspec(self, pos, mem)
|
local function formspec(self, pos, mem)
|
||||||
return "size[8,7]"..
|
return "size[8,7]"..
|
||||||
@ -43,7 +43,6 @@ local function stop_node(pos, mem, state)
|
|||||||
M(pos):set_string("infotext", "Off")
|
M(pos):set_string("infotext", "Off")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local State = techage.NodeStates:new({
|
local State = techage.NodeStates:new({
|
||||||
node_name_passive = "techage:power",
|
node_name_passive = "techage:power",
|
||||||
cycle_time = CYCLE_TIME,
|
cycle_time = CYCLE_TIME,
|
||||||
@ -74,6 +73,18 @@ local function node_timer(pos, elapsed)
|
|||||||
return State:is_active(mem)
|
return State:is_active(mem)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function valid_power_dir(pos, mem, in_dir)
|
||||||
|
return mem.power_dir == in_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
local function turn_power_on(pos, in_dir, on)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if State:is_active(mem) and not on then
|
||||||
|
State:fault(pos, mem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function on_receive_fields(pos, formname, fields, player)
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return
|
return
|
||||||
@ -111,6 +122,8 @@ minetest.register_node("techage:power", {
|
|||||||
power_consumption = techage.generator_power_consumption,
|
power_consumption = techage.generator_power_consumption,
|
||||||
power_network = techage.ElectricCable,
|
power_network = techage.ElectricCable,
|
||||||
power_consume = 0,
|
power_consume = 0,
|
||||||
|
valid_power_dir = valid_power_dir,
|
||||||
|
turn_on = turn_power_on,
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
|
12
init.lua
12
init.lua
@ -19,14 +19,14 @@ dofile(MP.."/basis/trowel.lua") -- hidden networks
|
|||||||
dofile(MP.."/basis/junction.lua") -- network junction box
|
dofile(MP.."/basis/junction.lua") -- network junction box
|
||||||
|
|
||||||
-- Steam Engine
|
-- Steam Engine
|
||||||
--dofile(MP.."/steam_engine/drive_axle.lua")
|
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")
|
||||||
|
|
||||||
dofile(MP.."/electric/electric_cable.lua")
|
dofile(MP.."/electric/electric_cable.lua")
|
||||||
dofile(MP.."/electric/test.lua")
|
dofile(MP.."/electric/test.lua")
|
||||||
|
@ -23,6 +23,8 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||||||
|
|
||||||
|
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
local STANDBY_TICKS = 2
|
||||||
|
local COUNTDOWN_TICKS = 2
|
||||||
local HEAT_STEP = 10
|
local HEAT_STEP = 10
|
||||||
local WATER_CONSUMPTION = 0.5
|
local WATER_CONSUMPTION = 0.5
|
||||||
local MAX_WATER = 10
|
local MAX_WATER = 10
|
||||||
@ -34,9 +36,8 @@ local Water = {
|
|||||||
["bucket:bucket_empty"] = true,
|
["bucket:bucket_empty"] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function formspec(mem)
|
local function formspec(self, pos, mem)
|
||||||
local temp = mem.temperature or 20
|
local temp = mem.temperature or 20
|
||||||
local button = mem.running and I("Stop") or I("Start")
|
|
||||||
return "size[8,7]"..
|
return "size[8,7]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
@ -47,17 +48,116 @@ local function formspec(mem)
|
|||||||
"list[context;input;1,1.6;1,1;]"..
|
"list[context;input;1,1.6;1,1;]"..
|
||||||
"image[1,1.6;1,1;bucket_water.png]"..
|
"image[1,1.6;1,1;bucket_water.png]"..
|
||||||
"image[1,1.6;1,1;techage_form_mask.png]"..
|
"image[1,1.6;1,1;techage_form_mask.png]"..
|
||||||
"image[3,0.5;1,2;techage_form_temp_bg.png^[lowpart:"..
|
"image[2,0.5;1,2;techage_form_temp_bg.png^[lowpart:"..
|
||||||
temp..":techage_form_temp_fg.png]"..
|
temp..":techage_form_temp_fg.png]"..
|
||||||
"image[4,0.5;1,2;"..techage.generator_formspec_level(mem)..
|
"image[7,0.5;1,2;"..techage.generator_formspec_level(mem)..
|
||||||
"button[6,0.5;2,1;start;"..button.."]"..
|
"image_button[6,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||||
"button[6,1.5;2,1;update;"..I("Update").."]"..
|
"button[3,1.5;2,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_name;water]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
default.get_hotbar_bg(0, 3)
|
default.get_hotbar_bg(0, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function can_start(pos, mem, state)
|
||||||
|
if mem.temperature >= 80 then
|
||||||
|
return techage.calc_power_consumption(pos, mem, POWER) > 0
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function start_node(pos, mem, state)
|
||||||
|
techage.generator_on(pos, mem)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function stop_node(pos, mem, state)
|
||||||
|
techage.generator_off(pos, mem)
|
||||||
|
end
|
||||||
|
|
||||||
|
local State = techage.NodeStates:new({
|
||||||
|
node_name_passive = "techage:boiler2",
|
||||||
|
cycle_time = CYCLE_TIME,
|
||||||
|
standby_ticks = STANDBY_TICKS,
|
||||||
|
has_item_meter = false,
|
||||||
|
formspec_func = formspec,
|
||||||
|
can_start = can_start,
|
||||||
|
start_node = start_node,
|
||||||
|
stop_node = stop_node,
|
||||||
|
})
|
||||||
|
|
||||||
|
local function get_water(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
local items = inv:get_stack("water", 1)
|
||||||
|
if items:get_count() > 0 then
|
||||||
|
local taken = items:take_item(1)
|
||||||
|
inv:set_stack("water", 1, items)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function water_temperature(pos, mem)
|
||||||
|
mem.temperature = mem.temperature or 20
|
||||||
|
if mem.fire_trigger then
|
||||||
|
mem.temperature = math.min(mem.temperature + HEAT_STEP, 100)
|
||||||
|
else
|
||||||
|
mem.temperature = math.max(mem.temperature - HEAT_STEP, 20)
|
||||||
|
end
|
||||||
|
mem.fire_trigger = false
|
||||||
|
|
||||||
|
if mem.water_level == 0 then
|
||||||
|
if get_water(pos) then
|
||||||
|
mem.water_level = 100
|
||||||
|
else
|
||||||
|
mem.temperature = 20
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return mem.temperature
|
||||||
|
end
|
||||||
|
|
||||||
|
local function steaming(pos, mem, temp)
|
||||||
|
print("steaming")
|
||||||
|
mem.water_level = math.max((mem.water_level or 0) - WATER_CONSUMPTION, 0)
|
||||||
|
if temp >= 80 then
|
||||||
|
local sum = techage.calc_power_consumption(pos, mem, 8)
|
||||||
|
if sum > 0 then
|
||||||
|
State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||||
|
else
|
||||||
|
State:fault(pos, mem)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
State:stop(pos, mem)
|
||||||
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function node_timer(pos, elapsed)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
local temp = water_temperature(pos, mem)
|
||||||
|
print("node_timer", temp)
|
||||||
|
if State:is_active(mem) then
|
||||||
|
steaming(pos, mem, temp)
|
||||||
|
end
|
||||||
|
return mem.temperature > 20
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
State:state_button_event(pos, mem, fields)
|
||||||
|
|
||||||
|
if fields.update then
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
|
||||||
local function can_dig(pos, player)
|
local function can_dig(pos, player)
|
||||||
local inv = M(pos):get_inventory()
|
local inv = M(pos):get_inventory()
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
@ -69,12 +169,14 @@ local function move_to_water(pos)
|
|||||||
local water_stack = inv:get_stack("water", 1)
|
local water_stack = inv:get_stack("water", 1)
|
||||||
local input_stack = inv:get_stack("input", 1)
|
local input_stack = inv:get_stack("input", 1)
|
||||||
|
|
||||||
if input_stack:get_name() == "bucket:bucket_empty" and input_stack:get_count() == 1 then
|
if input_stack:get_name() == "bucket:bucket_empty" then
|
||||||
if water_stack:get_count() > 0 then
|
if input_stack:get_count() == 1 then
|
||||||
water_stack:set_count(water_stack:get_count() - 1)
|
if water_stack:get_count() > 0 then
|
||||||
input_stack = ItemStack("bucket:bucket_water")
|
water_stack:set_count(water_stack:get_count() - 1)
|
||||||
inv:set_stack("water", 1, water_stack)
|
input_stack = ItemStack("bucket:bucket_water")
|
||||||
inv:set_stack("input", 1, input_stack)
|
inv:set_stack("water", 1, water_stack)
|
||||||
|
inv:set_stack("input", 1, input_stack)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif water_stack:get_count() < MAX_WATER then
|
elseif water_stack:get_count() < MAX_WATER then
|
||||||
if water_stack:get_count() == 0 then
|
if water_stack:get_count() == 0 then
|
||||||
@ -88,25 +190,12 @@ local function move_to_water(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_boiler(pos)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
mem.water_level = mem.water_level or 0
|
|
||||||
local inv = M(pos):get_inventory()
|
|
||||||
local water_stack = inv:get_stack("water", 1)
|
|
||||||
--print("trigger_boiler", mem.fire_trigger, mem.water_level, water_stack:get_count())
|
|
||||||
if mem.fire_trigger and (mem.water_level > 0 or water_stack:get_count() > 0) then
|
|
||||||
if not minetest.get_node_timer(pos):is_started() then
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
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
|
||||||
if listname == "input" and Water[stack:get_name()] then
|
if listname == "input" and Water[stack:get_name()] then
|
||||||
start_boiler(pos)
|
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -122,77 +211,8 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_receive_fields(pos, formname, fields, player)
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if fields.update then
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
M(pos):set_string("formspec", formspec(mem))
|
|
||||||
end
|
|
||||||
|
|
||||||
if fields.start then
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
mem.running = not (mem.running or false)
|
|
||||||
if mem.running then
|
|
||||||
techage.generator_on(pos, POWER)
|
|
||||||
else
|
|
||||||
techage.generator_off(pos)
|
|
||||||
end
|
|
||||||
M(pos):set_string("formspec", formspec(mem))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function on_rightclick(pos, node, clicker)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
M(pos):set_string("formspec", formspec(mem))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_water(pos)
|
|
||||||
local inv = M(pos):get_inventory()
|
|
||||||
local items = inv:get_stack("water", 1)
|
|
||||||
if items:get_count() > 0 then
|
|
||||||
local taken = items:take_item(1)
|
|
||||||
inv:set_stack("water", 1, items)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function node_timer(pos)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
mem.temperature = mem.temperature or 20
|
|
||||||
mem.water_level = math.max((mem.water_level or 0) - WATER_CONSUMPTION, 0)
|
|
||||||
|
|
||||||
print(mem.fire_trigger, mem.running, mem.temperature, mem.water_level)
|
|
||||||
|
|
||||||
if mem.fire_trigger then
|
|
||||||
mem.temperature = math.min(mem.temperature + HEAT_STEP, 100)
|
|
||||||
else
|
|
||||||
mem.temperature = math.max(mem.temperature - HEAT_STEP, 20)
|
|
||||||
end
|
|
||||||
|
|
||||||
if mem.water_level == 0 then
|
|
||||||
if get_water(pos) then
|
|
||||||
mem.water_level = 100
|
|
||||||
else
|
|
||||||
mem.temperature = 20
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if mem.temperature > 80 and mem.running then
|
|
||||||
techage.generator_on(pos, POWER)
|
|
||||||
else
|
|
||||||
techage.generator_off(pos)
|
|
||||||
end
|
|
||||||
mem.fire_trigger = false
|
|
||||||
return mem.temperature > 20
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("techage:boiler1", {
|
minetest.register_node("techage:boiler1", {
|
||||||
description = I("TA2 Boiler"),
|
description = I("TA2 Boiler Base"),
|
||||||
tiles = {"techage_boiler.png"},
|
tiles = {"techage_boiler.png"},
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
mesh = "techage_boiler.obj",
|
mesh = "techage_boiler.obj",
|
||||||
@ -201,20 +221,7 @@ minetest.register_node("techage:boiler1", {
|
|||||||
fixed = {-8/32, -16/32, -8/32, 8/32, 16/32, 8/32},
|
fixed = {-8/32, -16/32, -8/32, 8/32, 16/32, 8/32},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_construct = function(pos)
|
|
||||||
local param2 = minetest.get_node(pos).param2
|
|
||||||
local pos2 = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
||||||
local node = minetest.get_node(pos2)
|
|
||||||
if node.name == "air" then
|
|
||||||
minetest.set_node(pos2, {name="techage:boiler2", param2 = param2})
|
|
||||||
minetest.registered_nodes["techage:boiler2"].on_construct(pos2)
|
|
||||||
minetest.registered_nodes["techage:boiler2"].after_place_node(pos2)
|
|
||||||
on_rightclick(pos2)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
--diggable = false,
|
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
@ -223,7 +230,7 @@ minetest.register_node("techage:boiler1", {
|
|||||||
|
|
||||||
-- boiler2: Main part, needed as generator
|
-- boiler2: Main part, needed as generator
|
||||||
minetest.register_node("techage:boiler2", {
|
minetest.register_node("techage:boiler2", {
|
||||||
description = ("TA2 Boiler"),
|
description = I("TA2 Boiler Top"),
|
||||||
tiles = {"techage_boiler2.png"},
|
tiles = {"techage_boiler2.png"},
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
mesh = "techage_boiler.obj",
|
mesh = "techage_boiler.obj",
|
||||||
@ -240,42 +247,54 @@ minetest.register_node("techage:boiler2", {
|
|||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
|
||||||
techage = {
|
techage = {
|
||||||
power_network = techage.SteamPipe,
|
|
||||||
power_consumption = techage.generator_power_consumption,
|
power_consumption = techage.generator_power_consumption,
|
||||||
|
power_network = techage.SteamPipe,
|
||||||
power_consume = 0,
|
power_consume = 0,
|
||||||
trigger_boiler = function(pos)
|
trigger_boiler = function(pos)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
mem.fire_trigger = true
|
mem.fire_trigger = true
|
||||||
start_boiler(pos)
|
if not minetest.get_node_timer(pos):is_started() then
|
||||||
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
power_side = "U",
|
power_side = "U",
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = techage.generator_after_place_node,
|
|
||||||
after_tube_update = techage.generator_after_tube_update,
|
|
||||||
on_destruct = techage.generator_on_destruct,
|
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local inv = M(pos):get_inventory()
|
local inv = M(pos):get_inventory()
|
||||||
inv:set_size('water', 1)
|
inv:set_size('water', 1)
|
||||||
inv:set_size('input', 1)
|
inv:set_size('input', 1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode)
|
after_place_node = function(pos, placer)
|
||||||
techage.generator_after_dig_node(pos, oldnode)
|
local mem = techage.generator_after_place_node(pos)
|
||||||
|
State:node_init(pos, mem, "")
|
||||||
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||||
if node.name == "techage:boiler1" then
|
if node.name == "techage:boiler1" then
|
||||||
minetest.remove_node({x=pos.x, y=pos.y-1, z=pos.z})
|
on_rightclick(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||||
|
techage.generator_after_dig_node(pos, oldnode)
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_tube_update = techage.generator_after_tube_update,
|
||||||
|
on_destruct = techage.generator_on_destruct,
|
||||||
|
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||||
|
techage.generator_after_dig_node(pos, oldnode)
|
||||||
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_put = function(pos)
|
on_metadata_inventory_put = function(pos)
|
||||||
minetest.after(0.5, move_to_water, pos)
|
minetest.after(0.5, move_to_water, pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=1, not_in_creative_inventory=1},
|
groups = {cracky=1},
|
||||||
drop = "techage:boiler1",
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
local P = minetest.string_to_pos
|
local P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local TP = function(pos) return minetest.registered_nodes[minetest.get_node(pos).name].techage end
|
local TP = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||||
local TN = function(node) return minetest.registered_nodes[node.name].techage end
|
local TN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local MP = minetest.get_modpath("tubelib2")
|
local MP = minetest.get_modpath("tubelib2")
|
||||||
|
Loading…
Reference in New Issue
Block a user