some bugs fixed
parent
e70e638d3a
commit
b6d572ba26
|
@ -125,14 +125,10 @@ local function side_to_dir(side, param2)
|
|||
return dir
|
||||
end
|
||||
|
||||
local function get_dest_node(pos, side)
|
||||
-- TODO die Daten aus dem Cache holen und ueber die node callback wieder loeschen
|
||||
local _,node = Tube:get_node(pos)
|
||||
local dir = side_to_dir(side, node.param2)
|
||||
local spos, sdir = Tube:get_connected_node_pos(pos, dir)
|
||||
_,node = Tube:get_node(spos)
|
||||
local in_side = dir_to_side(sdir, node.param2)
|
||||
return spos, in_side, Name2Name[node.name] or node.name
|
||||
local function get_dest_node(pos, out_dir)
|
||||
local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir)
|
||||
local _,node = Tube:get_node(spos)
|
||||
return spos, in_dir, Name2Name[node.name] or node.name
|
||||
end
|
||||
|
||||
local function item_handling_node(name)
|
||||
|
@ -316,20 +312,20 @@ end
|
|||
-- Client side Push/Pull item functions
|
||||
-------------------------------------------------------------------
|
||||
|
||||
function techage.pull_items(pos, side, num)
|
||||
local npos, nside, name = get_dest_node(pos, side)
|
||||
function techage.pull_items(pos, out_dir, num)
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if npos == nil then return end
|
||||
if NodeDef[name] and NodeDef[name].on_pull_item then
|
||||
return NodeDef[name].on_pull_item(npos, nside, num)
|
||||
return NodeDef[name].on_pull_item(npos, in_dir, num)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function techage.push_items(pos, side, stack)
|
||||
local npos, nside, name = get_dest_node(pos, side)
|
||||
function techage.push_items(pos, out_dir, stack)
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if npos == nil then return end
|
||||
if NodeDef[name] and NodeDef[name].on_push_item then
|
||||
return NodeDef[name].on_push_item(npos, nside, stack)
|
||||
return NodeDef[name].on_push_item(npos, in_dir, stack)
|
||||
elseif name == "air" then
|
||||
minetest.add_item(npos, stack)
|
||||
return true
|
||||
|
@ -337,11 +333,11 @@ function techage.push_items(pos, side, stack)
|
|||
return false
|
||||
end
|
||||
|
||||
function techage.unpull_items(pos, side, items)
|
||||
local npos, nside, name = get_dest_node(pos, side)
|
||||
function techage.unpull_items(pos, out_dir, items)
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if npos == nil then return end
|
||||
if NodeDef[name] and NodeDef[name].on_unpull_item then
|
||||
return NodeDef[name].on_unpull_item(npos, nside, items)
|
||||
return NodeDef[name].on_unpull_item(npos, in_dir, items)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -56,6 +56,11 @@ local function side_to_dir(pos, side)
|
|||
return dir
|
||||
end
|
||||
|
||||
function techage.next_pos(pos, side)
|
||||
local dir = side_to_dir(pos, side)
|
||||
return tubelib2.get_pos(pos, dir)
|
||||
end
|
||||
|
||||
-- Calculate the power consumption on the given network
|
||||
local function power_consumption(pos, dir)
|
||||
if pos_already_reached(pos) then return 0 end
|
||||
|
@ -66,6 +71,7 @@ local function power_consumption(pos, dir)
|
|||
if fdir ~= tubelib2.Turn180Deg[dir or 0] then
|
||||
local this = TP(fpos)
|
||||
if this and this.power_consumption then
|
||||
--print("power_consumption", S(fpos), dump(val), dump(this.power_consumption(fpos, fdir)))
|
||||
val = val + this.power_consumption(fpos, fdir)
|
||||
else
|
||||
val = val + power_consumption(fpos, fdir)
|
||||
|
@ -76,12 +82,10 @@ local function power_consumption(pos, dir)
|
|||
end
|
||||
|
||||
local function turn_tube_on(pos, dir, network, on)
|
||||
if network.switch_tube_line then
|
||||
if on then
|
||||
network:switch_tube_line(pos, dir, "on")
|
||||
else
|
||||
network:switch_tube_line(pos, dir, "off")
|
||||
end
|
||||
if on then
|
||||
network:switch_tube_line(pos, dir, "on")
|
||||
else
|
||||
network:switch_tube_line(pos, dir, "off")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,14 +93,15 @@ local function turn_on(pos, dir, on)
|
|||
if pos_already_reached(pos) then return end
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local conn = mem.connections or {}
|
||||
--print("turn_on", dump(conn))
|
||||
for fdir,fpos in pairs(conn) do
|
||||
if fdir ~= tubelib2.Turn180Deg[dir or 0] then
|
||||
local this = TP(fpos)
|
||||
if this and this.turn_on then
|
||||
this.turn_on(fpos, fdir, on)
|
||||
end
|
||||
if this and this.network then
|
||||
turn_tube_on(pos, fdir, this.network, on)
|
||||
if this and this.animated_power_network then
|
||||
turn_tube_on(pos, fdir, this.power_network, on)
|
||||
end
|
||||
turn_on(fpos, fdir, on)
|
||||
end
|
||||
|
@ -110,6 +115,7 @@ local function sink_power_consumption(pos, power)
|
|||
Route = {}
|
||||
local sum = power + power_consumption(pos)
|
||||
Route = {}
|
||||
print("sink_power_consumption", sum)
|
||||
turn_on(pos, nil, sum > 0)
|
||||
return sum
|
||||
end
|
||||
|
@ -128,13 +134,13 @@ techage.source_power_consumption = source_power_consumption
|
|||
--
|
||||
-- Generator with on power output side
|
||||
--
|
||||
function techage.generator_on(pos, power, network)
|
||||
function techage.generator_on(pos, power)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.power_produce = power
|
||||
return source_power_consumption(pos, mem)
|
||||
end
|
||||
|
||||
function techage.generator_off(pos, network)
|
||||
function techage.generator_off(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.power_produce = 0
|
||||
return source_power_consumption(pos, mem)
|
||||
|
@ -142,19 +148,19 @@ end
|
|||
|
||||
function techage.generator_power_consumption(pos, dir)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
--print("generator_power_consumption", dir, mem.power_dir)
|
||||
if dir == tubelib2.Turn180Deg[mem.power_dir or 0] then
|
||||
return mem.power_produce
|
||||
return mem.power_produce or 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function techage.generator_after_place_node(pos)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
mem.power_dir = side_to_dir(pos, TP(pos).side or 'R')
|
||||
mem.power_dir = side_to_dir(pos, TP(pos).power_side or 'R')
|
||||
mem.power_produce = 0 -- will be set via generator_on
|
||||
mem.power_result = 0
|
||||
local network = TP(pos).network
|
||||
network:after_place_node(pos)
|
||||
TP(pos).power_network:after_place_node(pos)
|
||||
end
|
||||
|
||||
function techage.generator_after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
|
@ -171,13 +177,13 @@ function techage.generator_on_destruct(pos)
|
|||
techage.generator_off(pos)
|
||||
end
|
||||
|
||||
function techage.generator_after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
TN(oldnode).network:after_dig_node(pos)
|
||||
function techage.generator_after_dig_node(pos, oldnode)
|
||||
TN(oldnode).power_network:after_dig_node(pos)
|
||||
tubelib2.del_mem(pos)
|
||||
end
|
||||
|
||||
function techage.generator_formspec_level(mem)
|
||||
print("generator_formspec_level", mem.power_result, mem.power_produce)
|
||||
--print("generator_formspec_level", mem.power_result, mem.power_produce)
|
||||
local percent = ((mem.power_result or 0) * 100) / (mem.power_produce or 1)
|
||||
return "techage_form_level_bg.png^[lowpart:"..percent..":techage_form_level_fg.png]"
|
||||
end
|
||||
|
@ -192,11 +198,12 @@ end
|
|||
|
||||
function techage.distributor_after_place_node(pos, placer)
|
||||
local this = TP(pos)
|
||||
this.network:after_place_node(pos)
|
||||
this.power_network:after_place_node(pos)
|
||||
sink_power_consumption(pos, -this.power_consume)
|
||||
end
|
||||
|
||||
function techage.distributor_after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
print("Distributor", node, S(pos), out_dir, S(peer_pos), peer_in_dir)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.connections = mem.connections or {}
|
||||
mem.connections[out_dir] = peer_pos
|
||||
|
@ -207,38 +214,42 @@ function techage.distributor_on_destruct(pos)
|
|||
sink_power_consumption(pos, -TP(pos).power_consume)
|
||||
end
|
||||
|
||||
function techage.distributor_after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
TN(oldnode).network:after_dig_node(pos)
|
||||
function techage.distributor_after_dig_node(pos, oldnode)
|
||||
TN(oldnode).power_network:after_dig_node(pos)
|
||||
tubelib2.del_mem(pos)
|
||||
end
|
||||
|
||||
--
|
||||
-- Consumer with on power input side (default)
|
||||
-- Consumer with one power input side (default)
|
||||
--
|
||||
function techage.consumer_power_consumption(pos)
|
||||
function techage.consumer_power_consumption(pos, dir)
|
||||
print("consumer_power_consumption")
|
||||
return -TP(pos).power_consume
|
||||
end
|
||||
|
||||
function techage.consumer_after_place_node(pos, placer)
|
||||
print("consumer_after_place_node")
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
mem.power_dir = tubelib2.Turn180Deg[side_to_dir(pos, TP(pos).side or 'L')]
|
||||
local this = TP(pos)
|
||||
this.network:after_place_node(pos)
|
||||
sink_power_consumption(pos, -this.power_consume)
|
||||
mem.power_dir = tubelib2.Turn180Deg[side_to_dir(pos, this.power_side or 'L')]
|
||||
this.power_network:after_place_node(pos)
|
||||
--sink_power_consumption(pos, -this.power_consume)
|
||||
end
|
||||
|
||||
function techage.consumer_after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.connections = mem.connections or {}
|
||||
mem.connections[out_dir] = peer_pos
|
||||
sink_power_consumption(pos, -TP(pos).power_consume)
|
||||
mem.connections = {[out_dir] = peer_pos}
|
||||
print("consumer_after_tube_update", out_dir, S(peer_pos))
|
||||
local sum = sink_power_consumption(pos, -TP(pos).power_consume)
|
||||
-- Needed to be able to turn off the consumer itself
|
||||
TP(pos).turn_on(pos, nil, sum > 0)
|
||||
end
|
||||
|
||||
function techage.consumer_on_destruct(pos)
|
||||
sink_power_consumption(pos, -TP(pos).power_consume)
|
||||
end
|
||||
|
||||
function techage.consumer_after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
TN(oldnode).network:after_dig_node(pos)
|
||||
function techage.consumer_after_dig_node(pos, oldnode)
|
||||
TN(oldnode).power_network:after_dig_node(pos)
|
||||
tubelib2.del_mem(pos)
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ local Cable = tubelib2.Tube:new({
|
|||
dirs_to_check = {1,2,3,4,5,6},
|
||||
max_tube_length = 1000,
|
||||
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"},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
|
@ -149,6 +150,11 @@ techage.register_junction("techage:electric_junction", 2/8, Boxes, Cable, {
|
|||
tiles = {"techage_electric_junction.png"},
|
||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
techage = {
|
||||
power_consumption = techage.distributor_power_consumption,
|
||||
power_network = Cable,
|
||||
power_consume = 0,
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
tubelib2.init_mem(pos)
|
||||
|
|
|
@ -18,14 +18,14 @@ local function swap_node(pos, name)
|
|||
end
|
||||
|
||||
local function lamp_turn_on(pos, dir, on)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.power_dir == dir or mem.power_dir == tubelib2.Turn180Deg[dir] then
|
||||
-- local mem = tubelib2.get_mem(pos)
|
||||
-- if mem.power_dir == dir or mem.power_dir == tubelib2.Turn180Deg[dir] then
|
||||
if on then
|
||||
swap_node(pos, "techage:lamp_on")
|
||||
else
|
||||
swap_node(pos, "techage:lamp")
|
||||
end
|
||||
end
|
||||
-- end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:lamp", {
|
||||
|
@ -36,15 +36,15 @@ minetest.register_node("techage:lamp", {
|
|||
'techage_electric_button.png',
|
||||
'techage_electric_button.png',
|
||||
'techage_electric_button.png',
|
||||
'techage_electric_button.png^techage_electric_plug.png',
|
||||
'techage_electric_button.png^techage_electric_plug.png',
|
||||
'techage_electric_button.png',
|
||||
'techage_electric_button.png',
|
||||
},
|
||||
techage = {
|
||||
turn_on = lamp_turn_on,
|
||||
power_consumption = techage.consumer_power_consumption,
|
||||
network = techage.ElectricCable,
|
||||
power_network = techage.ElectricCable,
|
||||
power_consume = POWER_CONSUME,
|
||||
side = 'B',
|
||||
power_side = 'B',
|
||||
},
|
||||
|
||||
after_place_node = techage.consumer_after_place_node,
|
||||
|
@ -69,7 +69,7 @@ minetest.register_node("techage:lamp_on", {
|
|||
techage = {
|
||||
turn_on = lamp_turn_on,
|
||||
power_consumption = techage.consumer_power_consumption,
|
||||
network = techage.ElectricCable,
|
||||
power_network = techage.ElectricCable,
|
||||
power_consume = POWER_CONSUME,
|
||||
},
|
||||
|
||||
|
@ -106,7 +106,7 @@ minetest.register_node("techage:power", {
|
|||
is_ground_content = false,
|
||||
|
||||
techage = {
|
||||
network = Cable,
|
||||
power_network = Cable,
|
||||
power_consumption = techage.generator_power_consumption,
|
||||
},
|
||||
|
||||
|
|
2
init.lua
2
init.lua
|
@ -22,7 +22,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")
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ local function start_boiler(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())
|
||||
--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)
|
||||
|
@ -191,14 +191,45 @@ local function node_timer(pos)
|
|||
end
|
||||
|
||||
|
||||
minetest.register_node("techage:boiler", {
|
||||
minetest.register_node("techage:boiler1", {
|
||||
description = I("TA2 Boiler"),
|
||||
tiles = {"techage_boiler.png"},
|
||||
drawtype = "mesh",
|
||||
mesh = "techage_boiler.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-10/32, -16/32, -10/32, 10/32, 46/32, 10/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",
|
||||
--diggable = false,
|
||||
groups = {cracky=1},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- boiler2: Main part, needed as generator
|
||||
minetest.register_node("techage:boiler2", {
|
||||
description = ("TA2 Boiler"),
|
||||
tiles = {"techage_boiler2.png"},
|
||||
drawtype = "mesh",
|
||||
mesh = "techage_boiler.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-10/32, -48/32, -10/32, 10/32, 16/32, 10/32},
|
||||
},
|
||||
|
||||
can_dig = can_dig,
|
||||
|
@ -209,85 +240,44 @@ minetest.register_node("techage:boiler", {
|
|||
on_rightclick = on_rightclick,
|
||||
|
||||
techage = {
|
||||
network = techage.SteamPipe,
|
||||
power_consumption = function(pos, dir)
|
||||
techage.generator_power_consumption(pos, dir)
|
||||
end,
|
||||
power_network = techage.SteamPipe,
|
||||
power_consumption = techage.generator_power_consumption,
|
||||
power_consume = 0,
|
||||
trigger_boiler = function(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.fire_trigger = true
|
||||
start_boiler(pos)
|
||||
end,
|
||||
power_side = "U",
|
||||
},
|
||||
|
||||
on_destruct = function(pos)
|
||||
techage.generator_on_destruct({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end,
|
||||
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)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('water', 1)
|
||||
inv:set_size('input', 1)
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
if node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
minetest.add_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "techage:boiler2", param2 = minetest.get_node(pos).param2})
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer, pointed_thing)
|
||||
techage.generator_after_place_node({x=pos.x, y=pos.y+1, z=pos.z}, placer)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.running = false
|
||||
mem.water_level = 0
|
||||
mem.temperatur = 20
|
||||
M(pos):set_string("formspec", formspec(mem))
|
||||
after_dig_node = function(pos, oldnode)
|
||||
techage.generator_after_dig_node(pos, oldnode)
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
if node.name == "techage:boiler1" then
|
||||
minetest.remove_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos)
|
||||
minetest.after(0.5, move_to_water, pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
if node.name == "techage:boiler2" then
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
techage.generator_after_dig_node({x=pos.x, y=pos.y+1, z=pos.z}, oldnode, oldmetadata, digger)
|
||||
end
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=1},
|
||||
groups = {cracky=1, not_in_creative_inventory=1},
|
||||
drop = "techage:boiler1",
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- boiler2
|
||||
minetest.register_node("techage:boiler2", {
|
||||
description = ("TA2 Boiler"),
|
||||
tiles = {"techage_boiler2.png"},
|
||||
drawtype = "mesh",
|
||||
mesh = "techage_boiler.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-10/32, -16/32, -10/32, 10/32, 16/32, 10/32},
|
||||
},
|
||||
|
||||
techage = {
|
||||
network = techage.SteamPipe,
|
||||
power_consumption = function(pos, dir)
|
||||
techage.generator_power_consumption({x=pos.x, y=pos.y-1, z=pos.z}, dir)
|
||||
end,
|
||||
},
|
||||
|
||||
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
techage.generator_after_tube_update(node,
|
||||
{x=pos.x, y=pos.y-1, z=pos.z}, out_dir, peer_pos, peer_in_dir)
|
||||
end,
|
||||
|
||||
diggable = false,
|
||||
--pointable = false,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
|
|
|
@ -16,16 +16,14 @@
|
|||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
local TP = function(pos) return minetest.registered_nodes[minetest.get_node(pos).name].techage end
|
||||
local TN = function(node) return minetest.registered_nodes[node.name].techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local inv = M(pos):get_inventory()
|
||||
return inv:is_empty("fuel")
|
||||
end
|
||||
local POWER_CONSUME = 8
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
|
@ -36,6 +34,24 @@ local function swap_node(pos, name)
|
|||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function turn_on(pos, dir, on)
|
||||
--local mem = tubelib2.get_mem(pos)
|
||||
--print("turn_on", mem.power_dir, dir, on)
|
||||
--if mem.power_dir == dir then
|
||||
local npos = techage.next_pos(pos, "R")
|
||||
print("turn_on", S(pos), S(npos))
|
||||
local this = TP(npos)
|
||||
if this and this.try_to_start then
|
||||
on = this.try_to_start(npos, on)
|
||||
end
|
||||
if on then
|
||||
swap_node(pos, "techage:cylinder_on")
|
||||
else
|
||||
swap_node(pos, "techage:cylinder")
|
||||
end
|
||||
--end
|
||||
end
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
|
@ -48,12 +64,24 @@ minetest.register_node("techage:cylinder", {
|
|||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
|
||||
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
|
||||
},
|
||||
techage = {
|
||||
turn_on = turn_on,
|
||||
power_consumption = techage.consumer_power_consumption,
|
||||
power_network = techage.SteamPipe,
|
||||
power_consume = POWER_CONSUME,
|
||||
power_side = 'L',
|
||||
},
|
||||
|
||||
after_place_node = techage.consumer_after_place_node,
|
||||
after_tube_update = techage.consumer_after_tube_update,
|
||||
on_destruct = techage.consumer_on_destruct,
|
||||
after_dig_node = techage.consumer_after_dig_node,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
|
@ -67,8 +95,8 @@ minetest.register_node("techage:cylinder_on", {
|
|||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
|
||||
{
|
||||
image = "techage_filling4_ta2.png^techage_cylinder4.png^techage_frame4_ta2.png",
|
||||
backface_culling = false,
|
||||
|
@ -90,14 +118,24 @@ minetest.register_node("techage:cylinder_on", {
|
|||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
sunlight_propagates = true,
|
||||
techage = {
|
||||
turn_on = turn_on,
|
||||
power_consumption = techage.consumer_power_consumption,
|
||||
power_network = techage.SteamPipe,
|
||||
power_consume = POWER_CONSUME,
|
||||
power_side = 'L',
|
||||
},
|
||||
|
||||
after_place_node = techage.consumer_after_place_node,
|
||||
after_tube_update = techage.consumer_after_tube_update,
|
||||
on_destruct = techage.consumer_on_destruct,
|
||||
after_dig_node = techage.consumer_after_dig_node,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
diggable = false,
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2, crumbly=2, choppy=2, not_in_creative_inventory = 1},
|
||||
drop = "techage:cylinder",
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ minetest.register_node("techage:axle", {
|
|||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {crumbly = 3, cracky = 3, snappy = 3},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:axle_on", {
|
||||
|
@ -173,5 +173,5 @@ minetest.register_node("techage:axle_on", {
|
|||
is_ground_content = false,
|
||||
diggable = false,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
|
|
@ -105,9 +105,9 @@ end
|
|||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.running then
|
||||
local this = TP({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
local this = TP({x=pos.x, y=pos.y+2, z=pos.z})
|
||||
if this and this.trigger_boiler then
|
||||
this.trigger_boiler({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
this.trigger_boiler({x=pos.x, y=pos.y+2, z=pos.z})
|
||||
end
|
||||
mem.burn_cycles = (mem.burn_cycles or 0) - 1
|
||||
if mem.burn_cycles <= 0 then
|
||||
|
|
|
@ -33,6 +33,34 @@ local function swap_node(pos, name)
|
|||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function turn_on(pos, dir, on)
|
||||
print("jou")
|
||||
-- if on then
|
||||
-- swap_node(pos, "techage:flywheel_on")
|
||||
-- if not minetest.get_node_timer(pos):is_started() then
|
||||
-- minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
-- end
|
||||
-- else
|
||||
-- swap_node(pos, "techage:flywheel")
|
||||
-- if minetest.get_node_timer(pos):is_started() then
|
||||
-- minetest.get_node_timer(pos):stop()
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
local function try_to_start(pos, on)
|
||||
print("try_to_start", S(pos))
|
||||
-- if on then
|
||||
-- if techage.generator_on(pos, POWER) then
|
||||
-- return true
|
||||
-- end
|
||||
-- else
|
||||
-- techage.generator_off(pos)
|
||||
-- end
|
||||
-- return false
|
||||
return on
|
||||
end
|
||||
|
||||
local function formspec(mem)
|
||||
return "size[8,7]"..
|
||||
default.gui_bg..
|
||||
|
@ -69,21 +97,6 @@ local function node_timer(pos, elapsed)
|
|||
return true
|
||||
end
|
||||
|
||||
local function on_punch(pos, node, puncher, pointed_thing)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.power_produce and mem.power_produce > 0 then
|
||||
swap_node(pos, "techage:flywheel")
|
||||
techage.generator_off(pos, techage.Axle)
|
||||
--techage.generator_off(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
else
|
||||
swap_node(pos, "techage:flywheel_on")
|
||||
techage.generator_on(pos, POWER, techage.Axle)
|
||||
--techage.generator_on(pos, POWER)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:flywheel", {
|
||||
description = I("TA2 Flywheel"),
|
||||
tiles = {
|
||||
|
@ -96,8 +109,12 @@ minetest.register_node("techage:flywheel", {
|
|||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_flywheel.png^[transformFX]",
|
||||
},
|
||||
techage = {
|
||||
network = techage.Axle,
|
||||
power_network = techage.Axle,
|
||||
power_consumption = techage.generator_power_consumption,
|
||||
power_consume = 0,
|
||||
animated_power_network = true,
|
||||
turn_on = turn_on,
|
||||
try_to_start = try_to_start,
|
||||
},
|
||||
|
||||
after_place_node = techage.generator_after_place_node,
|
||||
|
@ -108,7 +125,6 @@ minetest.register_node("techage:flywheel", {
|
|||
on_timer = node_timer,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_punch = on_punch,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
|
@ -156,8 +172,12 @@ minetest.register_node("techage:flywheel_on", {
|
|||
},
|
||||
},
|
||||
techage = {
|
||||
network = techage.Axle,
|
||||
power_network = techage.Axle,
|
||||
power_consumption = techage.generator_power_consumption,
|
||||
power_consume = 0,
|
||||
animated_power_network = true,
|
||||
turn_on = turn_on,
|
||||
try_to_start = try_to_start,
|
||||
},
|
||||
|
||||
after_place_node = techage.generator_after_place_node,
|
||||
|
@ -168,7 +188,6 @@ minetest.register_node("techage:flywheel_on", {
|
|||
on_timer = node_timer,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_punch = on_punch,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2, not_in_creative_inventory=1},
|
||||
|
|
|
@ -47,8 +47,9 @@ minetest.register_node("techage:gearbox", {
|
|||
techage = {
|
||||
turn_on = turn_on,
|
||||
power_consumption = techage.distributor_power_consumption,
|
||||
network = techage.Axle,
|
||||
power_network = techage.Axle,
|
||||
power_consume = POWER_CONSUME,
|
||||
animated_power_network = true,
|
||||
},
|
||||
|
||||
after_place_node = techage.distributor_after_place_node,
|
||||
|
@ -81,8 +82,9 @@ minetest.register_node("techage:gearbox_on", {
|
|||
techage = {
|
||||
turn_on = turn_on,
|
||||
power_consumption = techage.distributor_power_consumption,
|
||||
network = techage.Axle,
|
||||
power_network = techage.Axle,
|
||||
power_consume = POWER_CONSUME,
|
||||
animated_power_network = true,
|
||||
},
|
||||
|
||||
after_place_node = techage.distributor_after_place_node,
|
||||
|
|
|
@ -24,10 +24,10 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||
|
||||
local Pipe = tubelib2.Tube:new({
|
||||
dirs_to_check = {1,2,3,4,5,6},
|
||||
max_tube_length = 1000,
|
||||
max_tube_length = 6,
|
||||
show_infotext = false,
|
||||
primary_node_names = {"techage:steam_pipeS", "techage:steam_pipeA"},
|
||||
secondary_node_names = {"techage:cylinder", "techage:boiler2"},
|
||||
secondary_node_names = {"techage:cylinder", "techage:cylinder_on", "techage:boiler2"},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
minetest.swap_node(pos, {name = "techage:steam_pipe"..tube_type, param2 = param2})
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue