This commit is contained in:
Joachim Stolberg 2019-03-08 22:08:39 +01:00
parent fc88161bf8
commit c037ac6613
3 changed files with 148 additions and 27 deletions

View File

@ -61,18 +61,12 @@ function techage.get_pos(pos, side)
return tubelib2.get_pos(pos, dir)
end
local function dbg(name, pos, val)
local node = minetest.get_node(pos)
print(name.." ("..node.name..") "..dump(val))
end
local power_consumption = nil
local function call_read_power_consumption(pos, in_dir)
if not pos_already_reached(pos) then
local this = TP(pos)
if this and this.read_power_consumption then
dbg("power_consumption", pos, this.read_power_consumption(pos, in_dir))
return this.read_power_consumption(pos, in_dir)
else
return power_consumption(pos, in_dir)
@ -116,9 +110,9 @@ local function call_turn_on(pos, in_dir, sum)
end
if this and this.animated_power_network then
turn_tube_on(pos, in_dir, this.power_network, sum > 0)
else
turn_on(pos, in_dir, sum)
end
-- Needed for junctions which could have a local "turn_on" in addition
turn_on(pos, in_dir, sum)
end
end
@ -186,7 +180,6 @@ end
-- Power network callback function
function techage.generator.read_power_consumption(pos, in_dir)
local mem = tubelib2.get_mem(pos)
print("generator.read_power_consumption", in_dir, mem.power_dir, mem.power_capacity)
if in_dir == mem.power_dir then
return mem.power_capacity or 0
end
@ -227,6 +220,11 @@ function techage.distributor.after_tube_update(node, pos, out_dir, peer_pos, pee
minetest.after(0.2, start_network_power_consumption, pos)
end
-- Needed if the junction consumes power in addition
function techage.distributor.read_power_consumption(pos, in_dir)
return power_consumption(pos, in_dir) - TP(pos).power_consumption or 0
end
function techage.distributor.after_dig_node(pos, oldnode)
TN(oldnode).power_network:after_dig_node(pos)
tubelib2.del_mem(pos)

View File

@ -0,0 +1,124 @@
# Blender v2.78 (sub 0) OBJ File: 'oven.blend'
# www.blender.org
o Cylinder
v 0.000000 -0.500000 -0.600000
v 0.000000 0.500000 -0.600000
v 0.229610 -0.500000 -0.554328
v 0.229610 0.500000 -0.554328
v 0.424264 -0.500000 -0.424264
v 0.424264 0.500000 -0.424264
v 0.554328 -0.500000 -0.229610
v 0.554328 0.500000 -0.229610
v 0.600000 -0.500000 0.000000
v 0.600000 0.500000 0.000000
v 0.554328 -0.500000 0.229610
v 0.554328 0.500000 0.229610
v 0.424264 -0.500000 0.424264
v 0.424264 0.500000 0.424264
v 0.229610 -0.500000 0.554328
v 0.229610 0.500000 0.554328
v 0.000000 -0.500000 0.600000
v 0.000000 0.500000 0.600000
v -0.229610 -0.500000 0.554328
v -0.229610 0.500000 0.554328
v -0.424264 -0.500000 0.424264
v -0.424264 0.500000 0.424264
v -0.554328 -0.500000 0.229610
v -0.554328 0.500000 0.229610
v -0.600000 -0.500000 -0.000000
v -0.600000 0.500000 -0.000000
v -0.554328 -0.500000 -0.229610
v -0.554328 0.500000 -0.229610
v -0.424264 -0.500000 -0.424264
v -0.424264 0.500000 -0.424264
v -0.229610 -0.500000 -0.554328
v -0.229610 0.500000 -0.554328
vt 0.5486 0.5000
vt 0.5486 1.0000
vt 0.4725 1.0000
vt 0.4725 0.5000
vt 0.4142 1.0000
vt 0.4142 0.5000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.9239 1.0000
vt 0.9239 0.5000
vt 0.8415 1.0000
vt 0.8415 0.5000
vt 0.7654 1.0000
vt 0.7654 0.5000
vt 0.4142 0.5000
vt 0.4142 0.0000
vt 0.4725 0.0000
vt 0.4725 0.5000
vt 0.5486 0.0000
vt 0.5486 0.5000
vt 0.6310 0.0000
vt 0.6310 0.5000
vt 0.7071 0.0000
vt 0.7071 0.5000
vt 0.7654 0.0000
vt 0.7654 0.5000
vt 0.8415 0.0000
vt 0.8415 0.5000
vt 0.9239 0.0000
vt 0.9239 0.5000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.7654 0.5000
vt 0.7654 1.0000
vt 0.7071 1.0000
vt 0.7071 0.5000
vt 0.3244 0.4749
vt 0.3827 0.5370
vt 0.4142 0.6181
vt 0.4142 0.7059
vt 0.3827 0.7870
vt 0.3244 0.8491
vt 0.2483 0.8827
vt 0.1659 0.8827
vt 0.0898 0.8491
vt 0.0315 0.7870
vt 0.0000 0.7059
vt 0.0000 0.6181
vt 0.0315 0.5370
vt 0.0898 0.4749
vt 0.1659 0.4414
vt 0.2483 0.4414
vt 0.6310 1.0000
vt 0.6310 0.5000
vt 0.0000 0.2646
vt 0.0000 0.1768
vt 0.0315 0.0957
vt 0.0898 0.0336
vt 0.1659 0.0000
vt 0.2483 0.0000
vt 0.3244 0.0336
vt 0.3827 0.0957
vt 0.4142 0.1768
vt 0.4142 0.2646
vt 0.3827 0.3457
vt 0.3244 0.4078
vt 0.2483 0.4414
vt 0.1659 0.4414
vt 0.0898 0.4078
vt 0.0315 0.3457
s off
f 1/1 2/2 4/3 3/4
f 3/4 4/3 6/5 5/6
f 5/7 6/8 8/9 7/10
f 7/10 8/9 10/11 9/12
f 9/12 10/11 12/13 11/14
f 11/15 12/16 14/17 13/18
f 13/18 14/17 16/19 15/20
f 15/20 16/19 18/21 17/22
f 17/22 18/21 20/23 19/24
f 19/24 20/23 22/25 21/26
f 21/26 22/25 24/27 23/28
f 23/28 24/27 26/29 25/30
f 25/30 26/29 28/31 27/32
f 27/33 28/34 30/35 29/36
f 4/37 2/38 32/39 30/40 28/41 26/42 24/43 22/44 20/45 18/46 16/47 14/48 12/49 10/50 8/51 6/52
f 29/36 30/35 32/53 31/54
f 31/54 32/53 2/2 1/1
f 1/55 3/56 5/57 7/58 9/59 11/60 13/61 15/62 17/63 19/64 21/65 23/66 25/67 27/68 29/69 31/70

View File

@ -21,8 +21,10 @@ local M = minetest.get_meta
local MP = minetest.get_modpath("tubelib2")
local I,_ = dofile(MP.."/intllib.lua")
local POWER_CONSUMPTION = 1
local POWER_CONSUME = 1
local Axle = techage.Axle
local distributor = techage.distributor
local function swap_node(pos, name)
local node = minetest.get_node(pos)
@ -33,8 +35,8 @@ local function swap_node(pos, name)
minetest.swap_node(pos, node)
end
local function turn_on(pos, dir, on)
if on then
local function turn_on(pos, dir, sum)
if sum > 0 then
swap_node(pos, "techage:gearbox_on")
else
swap_node(pos, "techage:gearbox")
@ -42,20 +44,19 @@ local function turn_on(pos, dir, on)
end
minetest.register_node("techage:gearbox", {
description = "TA2 Gearbox",
description = I("TA2 Gearbox"),
tiles = {"techage_filling_ta2.png^techage_axle_gearbox.png^techage_frame_ta2.png"},
techage = {
turn_on = turn_on,
power_consumption = techage.distributor_power_consumption,
power_network = techage.Axle,
power_consume = POWER_CONSUME,
read_power_consumption = distributor.read_power_consumption,
power_network = Axle,
power_consumption = POWER_CONSUMPTION,
animated_power_network = true,
},
after_place_node = techage.distributor_after_place_node,
after_tube_update = techage.distributor_after_tube_update,
on_destruct = techage.distributor_on_destruct,
after_dig_node = techage.distributor_after_dig_node,
after_place_node = distributor.after_place_node,
after_tube_update = distributor.after_tube_update,
after_dig_node = distributor.after_dig_node,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -81,16 +82,14 @@ minetest.register_node("techage:gearbox_on", {
},
techage = {
turn_on = turn_on,
power_consumption = techage.distributor_power_consumption,
power_network = techage.Axle,
power_consume = POWER_CONSUME,
read_power_consumption = distributor.read_power_consumption,
power_network = Axle,
power_consumption = POWER_CONSUMPTION,
animated_power_network = true,
},
after_place_node = techage.distributor_after_place_node,
after_tube_update = techage.distributor_after_tube_update,
on_destruct = techage.distributor_on_destruct,
after_dig_node = techage.distributor_after_dig_node,
after_tube_update = distributor.after_tube_update,
after_dig_node = distributor.after_dig_node,
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},