bugfixes
@ -8,7 +8,7 @@
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Gravel Rinser, washing sieved gravel to find more ores
|
||||
TA2 Gravel Rinser, washing sieved gravel to find more ores
|
||||
|
||||
]]--
|
||||
|
||||
@ -300,7 +300,8 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
num_items = {0,1,2,4},
|
||||
power_consumption = {0,3,4,5},
|
||||
})
|
||||
},
|
||||
{false, true, false, false}) -- TA2 only
|
||||
|
||||
minetest.register_craft({
|
||||
output = node_name_ta2,
|
||||
|
@ -77,16 +77,16 @@ end
|
||||
local function check_space(pos, param2, AssemblyPlan, player_name)
|
||||
for _,item in ipairs(AssemblyPlan) do
|
||||
local y, path, node_name = item[1], item[2], item[4]
|
||||
pos1 = dest_pos(pos, param2, path, y)
|
||||
local pos1 = dest_pos(pos, param2, path, y)
|
||||
if minetest.is_protected(pos1, player_name) then
|
||||
minetest.chat_send_player(player_name, I("Area is protected!"))
|
||||
minetest.chat_send_player(player_name, I("[TA] Area is protected!"))
|
||||
return false
|
||||
end
|
||||
|
||||
local ndef = minetest.registered_nodes[minetest.get_node(pos1).name]
|
||||
--print(dump(ndef))
|
||||
if not ndef or ndef.walkable then
|
||||
minetest.chat_send_player(player_name, I("Not enough space!"))
|
||||
local node = minetest.get_node(pos1)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if not ndef or ndef.walkable and node.name ~= node_name then
|
||||
minetest.chat_send_player(player_name, I("[TA] Not enough space!"))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
Consumer node basis functionality.
|
||||
It handles:
|
||||
- 3 stages of nodes (TA2/TA3/TA4)
|
||||
- up to 3 stages of nodes (TA2/TA3/TA4)
|
||||
- power consumption
|
||||
- node state handling
|
||||
- registration of passive, active and defect nodes
|
||||
@ -76,8 +76,11 @@ local function prepare_tiles(tiles, stage, power_png)
|
||||
return tbl
|
||||
end
|
||||
|
||||
function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
||||
-- 'validStates' is optional and can be used to e.g. enable
|
||||
-- only one TA2 node {false, true, false, false}
|
||||
function techage.register_consumer(base_name, inv_name, tiles, tNode, validStates)
|
||||
local names = {}
|
||||
validStates = validStates or {true, true, true, true}
|
||||
for stage = 2,4 do
|
||||
local name_pas = "techage:ta"..stage.."_"..base_name.."_pas"
|
||||
local name_act = "techage:ta"..stage.."_"..base_name.."_act"
|
||||
@ -85,188 +88,194 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
||||
local name_inv = "TA"..stage.." "..inv_name
|
||||
names[#names+1] = name_pas
|
||||
|
||||
local on_recv_message = tNode.tubing.on_recv_message
|
||||
if stage > 2 then
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
end
|
||||
end
|
||||
|
||||
local power_network
|
||||
local power_png = 'techage_axle_clutch.png'
|
||||
local power_used = tNode.power_consumption ~= nil
|
||||
-- power needed?
|
||||
if power_used then
|
||||
if validStates[stage] then
|
||||
local on_recv_message = tNode.tubing.on_recv_message
|
||||
if stage > 2 then
|
||||
power_network = techage.ElectricCable
|
||||
power_png = 'techage_appl_hole_electric.png'
|
||||
else
|
||||
power_network = techage.Axle
|
||||
power_png = 'techage_axle_clutch.png'
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
end
|
||||
end
|
||||
power_network:add_secondary_node_names({name_pas, name_act})
|
||||
end
|
||||
|
||||
local tState = techage.NodeStates:new({
|
||||
node_name_passive = name_pas,
|
||||
node_name_active = name_act,
|
||||
node_name_defect = name_def,
|
||||
infotext_name = name_inv,
|
||||
cycle_time = tNode.cycle_time,
|
||||
standby_ticks = tNode.standby_ticks,
|
||||
has_item_meter = tNode.has_item_meter,
|
||||
aging_factor = tNode.aging_factor * (stage-1) * 2,
|
||||
formspec_func = tNode.formspec,
|
||||
start_node = power_used and start_node or nil,
|
||||
stop_node = power_used and stop_node or nil,
|
||||
})
|
||||
|
||||
local tConsumer = {
|
||||
stage = stage,
|
||||
State = tState,
|
||||
num_items = tNode.num_items[stage],
|
||||
power_consumption = power_used and tNode.power_consumption[stage] or {0,0,0,0},
|
||||
}
|
||||
|
||||
tNode.groups.not_in_creative_inventory = 0
|
||||
|
||||
minetest.register_node(name_pas, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.pas, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
||||
local number = "-"
|
||||
local power_network
|
||||
local power_png = 'techage_axle_clutch.png'
|
||||
local power_used = tNode.power_consumption ~= nil
|
||||
-- power needed?
|
||||
if power_used then
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, name_pas)
|
||||
power_network = techage.ElectricCable
|
||||
power_png = 'techage_appl_hole_electric.png'
|
||||
else
|
||||
power_network = techage.Axle
|
||||
power_png = 'techage_axle_clutch.png'
|
||||
end
|
||||
if tNode.after_place_node then
|
||||
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
CRD(pos).State:node_init(pos, mem, number)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if tNode.after_dig_node then
|
||||
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
techage.remove_node(pos)
|
||||
CRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end,
|
||||
|
||||
can_dig = tNode.can_dig,
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
drop = "",
|
||||
paramtype2 = "facedir",
|
||||
groups = table.copy(tNode.groups),
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
tNode.groups.not_in_creative_inventory = 1
|
||||
power_network:add_secondary_node_names({name_pas, name_act})
|
||||
end
|
||||
|
||||
minetest.register_node(name_act, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.act, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
groups = tNode.groups,
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
minetest.register_node(name_def, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.def, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
||||
local number = "-"
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, name_pas)
|
||||
end
|
||||
if tNode.after_place_node then
|
||||
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
CRD(pos).State:defect(pos, mem)
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if tNode.after_dig_node then
|
||||
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
techage.remove_node(pos)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = tNode.groups,
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
if power_used then
|
||||
techage.power.register_node({name_pas, name_act}, {
|
||||
on_power_pass1 = on_power_pass1,
|
||||
on_power_pass2 = on_power_pass2,
|
||||
conn_sides = {"F", "B"},
|
||||
power_network = power_network,
|
||||
local tState = techage.NodeStates:new({
|
||||
node_name_passive = name_pas,
|
||||
node_name_active = name_act,
|
||||
node_name_defect = name_def,
|
||||
infotext_name = name_inv,
|
||||
cycle_time = tNode.cycle_time,
|
||||
standby_ticks = tNode.standby_ticks,
|
||||
has_item_meter = tNode.has_item_meter,
|
||||
aging_factor = tNode.aging_factor * (stage-1) * 2,
|
||||
formspec_func = tNode.formspec,
|
||||
on_state_change = tNode.on_state_change,
|
||||
start_node = power_used and start_node or nil,
|
||||
stop_node = power_used and stop_node or nil,
|
||||
})
|
||||
|
||||
local tConsumer = {
|
||||
stage = stage,
|
||||
State = tState,
|
||||
-- number of items to be processed per cycle
|
||||
num_items = tNode.num_items[stage],
|
||||
power_consumption = power_used and
|
||||
tNode.power_consumption[stage] or {0,0,0,0},
|
||||
}
|
||||
|
||||
tNode.groups.not_in_creative_inventory = 0
|
||||
|
||||
minetest.register_node(name_pas, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.pas, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
||||
local number = "-"
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, name_pas)
|
||||
end
|
||||
if tNode.after_place_node then
|
||||
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
CRD(pos).State:node_init(pos, mem, number)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if tNode.after_dig_node then
|
||||
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
techage.remove_node(pos)
|
||||
CRDN(oldnode).State:after_dig_node(pos, oldnode,
|
||||
oldmetadata, digger)
|
||||
end,
|
||||
|
||||
can_dig = tNode.can_dig,
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
drop = "",
|
||||
paramtype2 = "facedir",
|
||||
groups = table.copy(tNode.groups),
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
tNode.groups.not_in_creative_inventory = 1
|
||||
|
||||
minetest.register_node(name_act, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.act, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
groups = tNode.groups,
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
minetest.register_node(name_def, {
|
||||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.def, stage, power_png),
|
||||
consumer = tConsumer,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local meta = M(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
||||
local number = "-"
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, name_pas)
|
||||
end
|
||||
if tNode.after_place_node then
|
||||
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
CRD(pos).State:defect(pos, mem)
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if tNode.after_dig_node then
|
||||
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
techage.remove_node(pos)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = tNode.groups,
|
||||
is_ground_content = false,
|
||||
sounds = tNode.sounds,
|
||||
})
|
||||
|
||||
if power_used then
|
||||
techage.power.register_node({name_pas, name_act}, {
|
||||
on_power_pass1 = on_power_pass1,
|
||||
on_power_pass2 = on_power_pass2,
|
||||
conn_sides = {"F", "B"},
|
||||
power_network = power_network,
|
||||
})
|
||||
end
|
||||
techage.register_node({name_pas, name_act, name_def}, tNode.tubing)
|
||||
end
|
||||
techage.register_node({name_pas, name_act, name_def}, tNode.tubing)
|
||||
end
|
||||
return names[1], names[2], names[3]
|
||||
end
|
||||
|
@ -144,6 +144,7 @@ function NodeStates:new(attr)
|
||||
start_node = attr.start_node,
|
||||
stop_node = attr.stop_node,
|
||||
formspec_func = attr.formspec_func,
|
||||
on_state_change = attr.on_state_change,
|
||||
}
|
||||
if attr.aging_factor then
|
||||
o.aging_level1 = attr.aging_factor * techage.machine_aging_value
|
||||
@ -188,6 +189,9 @@ function NodeStates:stop(pos, mem)
|
||||
if self.formspec_func then
|
||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, STOPPED)
|
||||
end
|
||||
if minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
@ -225,6 +229,9 @@ function NodeStates:start(pos, mem, called_from_on_timer)
|
||||
if minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, RUNNING)
|
||||
end
|
||||
minetest.get_node_timer(pos):start(self.cycle_time)
|
||||
return true
|
||||
end
|
||||
@ -232,8 +239,8 @@ function NodeStates:start(pos, mem, called_from_on_timer)
|
||||
end
|
||||
|
||||
function NodeStates:standby(pos, mem)
|
||||
mem.techage_state = mem.techage_state or STOPPED
|
||||
if mem.techage_state == RUNNING then
|
||||
local state = mem.techage_state or STOPPED
|
||||
if state == RUNNING then
|
||||
mem.techage_state = STANDBY
|
||||
-- timer has to be stopped once to be able to be restarted
|
||||
self.stop_timer = true
|
||||
@ -250,6 +257,9 @@ function NodeStates:standby(pos, mem)
|
||||
if minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, STANDBY)
|
||||
end
|
||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
||||
return true
|
||||
end
|
||||
@ -258,8 +268,8 @@ end
|
||||
|
||||
-- special case of standby for pushing nodes
|
||||
function NodeStates:blocked(pos, mem)
|
||||
mem.techage_state = mem.techage_state or STOPPED
|
||||
if mem.techage_state == RUNNING then
|
||||
local state = mem.techage_state or STOPPED
|
||||
if state == RUNNING then
|
||||
mem.techage_state = BLOCKED
|
||||
-- timer has to be stopped once to be able to be restarted
|
||||
self.stop_timer = true
|
||||
@ -276,6 +286,9 @@ function NodeStates:blocked(pos, mem)
|
||||
if minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, BLOCKED)
|
||||
end
|
||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
||||
return true
|
||||
end
|
||||
@ -283,8 +296,8 @@ function NodeStates:blocked(pos, mem)
|
||||
end
|
||||
|
||||
function NodeStates:nopower(pos, mem)
|
||||
mem.techage_state = mem.techage_state or STOPPED
|
||||
if mem.techage_state ~= STOPPED and mem.techage_state ~= DEFECT then
|
||||
local state = mem.techage_state or RUNNING
|
||||
if state ~= STOPPED and state ~= DEFECT then
|
||||
mem.techage_state = NOPOWER
|
||||
if self.node_name_passive then
|
||||
swap_node(pos, self.node_name_passive)
|
||||
@ -296,6 +309,9 @@ function NodeStates:nopower(pos, mem)
|
||||
if self.formspec_func then
|
||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, NOPOWER)
|
||||
end
|
||||
minetest.get_node_timer(pos):stop()
|
||||
return true
|
||||
end
|
||||
@ -303,8 +319,8 @@ function NodeStates:nopower(pos, mem)
|
||||
end
|
||||
|
||||
function NodeStates:fault(pos, mem)
|
||||
mem.techage_state = mem.techage_state or STOPPED
|
||||
if mem.techage_state == RUNNING or mem.techage_state == STOPPED then
|
||||
local state = mem.techage_state or STOPPED
|
||||
if state == RUNNING or state == STOPPED then
|
||||
mem.techage_state = FAULT
|
||||
if self.node_name_passive then
|
||||
swap_node(pos, self.node_name_passive)
|
||||
@ -316,6 +332,9 @@ function NodeStates:fault(pos, mem)
|
||||
if self.formspec_func then
|
||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, FAULT)
|
||||
end
|
||||
minetest.get_node_timer(pos):stop()
|
||||
return true
|
||||
end
|
||||
@ -323,6 +342,7 @@ function NodeStates:fault(pos, mem)
|
||||
end
|
||||
|
||||
function NodeStates:defect(pos, mem)
|
||||
local state = mem.techage_state or STOPPED
|
||||
mem.techage_state = DEFECT
|
||||
if self.node_name_defect then
|
||||
swap_node(pos, self.node_name_defect)
|
||||
@ -334,6 +354,9 @@ function NodeStates:defect(pos, mem)
|
||||
if self.formspec_func then
|
||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||
end
|
||||
if self.on_state_change then
|
||||
self.on_state_change(pos, state, DEFECT)
|
||||
end
|
||||
minetest.get_node_timer(pos):stop()
|
||||
return true
|
||||
end
|
||||
|
@ -35,14 +35,11 @@ local formspec0 = "size[5,4]"..
|
||||
"button_exit[1,3.2;3,1;build;"..I("Build Tower").."]"
|
||||
|
||||
local function play_sound(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if CRD(pos).State:is_active(mem) then
|
||||
mem.handle = minetest.sound_play("techage_oildrill", {
|
||||
pos = pos,
|
||||
gain = 1,
|
||||
max_hear_distance = 15})
|
||||
minetest.after(4, play_sound, pos)
|
||||
end
|
||||
mem.handle = minetest.sound_play("techage_oildrill", {
|
||||
pos = pos,
|
||||
gain = 1,
|
||||
max_hear_distance = 15})
|
||||
minetest.after(4, play_sound, pos)
|
||||
end
|
||||
|
||||
local function stop_sound(pos)
|
||||
@ -73,7 +70,7 @@ local function formspec(self, pos, mem)
|
||||
"image_button[3.5,2;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"label[6.2,0.5;OUT]"..
|
||||
"list[context;dst;6,1;1,1;]"..
|
||||
"button_exit[5,3;3,1;destroy;"..I("Destroy Tower").."]"..
|
||||
"button_exit[5,3;3,1;remove;"..I("Remove Tower").."]"..
|
||||
"list[current_player;main;0,4;8,4;]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
@ -86,8 +83,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
--local meta = minetest.get_meta(pos)
|
||||
--local inv = meta:get_inventory()
|
||||
local crd = CRD(pos)
|
||||
if listname == "src" then
|
||||
crd.State:start_if_standby(pos)
|
||||
@ -115,6 +110,14 @@ local function on_rightclick(pos)
|
||||
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
||||
end
|
||||
|
||||
local function on_node_state_change(pos, old_state, new_state)
|
||||
if new_state == techage.RUNNING then
|
||||
play_sound(pos)
|
||||
else
|
||||
stop_sound(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function drilling(pos, crd, mem, inv)
|
||||
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
||||
mem.drill_pos = mem.drill_pos or {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
@ -128,10 +131,8 @@ local function drilling(pos, crd, mem, inv)
|
||||
crd.State:idle(pos, mem)
|
||||
elseif curr_depth >= depth then
|
||||
M(pos):set_string("oil_found", "true")
|
||||
stop_sound(pos)
|
||||
crd.State:stop(pos, mem)
|
||||
elseif minetest.is_protected(mem.drill_pos, owner) then
|
||||
stop_sound(pos)
|
||||
crd.State:fault(pos, mem)
|
||||
elseif node.name == "techage:oil_drillbit2" then
|
||||
mem.drill_pos.y = mem.drill_pos.y-1
|
||||
@ -182,7 +183,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
if fields.build then
|
||||
techage.oiltower.build(pos, player:get_player_name())
|
||||
elseif fields.destroy then
|
||||
elseif fields.remove then
|
||||
local inv = M(pos):get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
techage.oiltower.remove(pos, player:get_player_name())
|
||||
@ -190,13 +191,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
else
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if not mem.assemble_locked and M(pos):get_string("oil_found") ~= "true" then
|
||||
if CRD(pos).State:state_button_event(pos, mem, fields) then
|
||||
if mem.techage_state == techage.RUNNING then
|
||||
play_sound(pos)
|
||||
else
|
||||
stop_sound(pos)
|
||||
end
|
||||
end
|
||||
CRD(pos).State:state_button_event(pos, mem, fields)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -289,7 +284,8 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
num_items = {0,1,1,1},
|
||||
power_consumption = {0,10,16,24},
|
||||
})
|
||||
},
|
||||
{false, false, true, false}) -- TA3 only
|
||||
|
||||
minetest.register_craft({
|
||||
output = node_name_ta3,
|
||||
@ -307,10 +303,11 @@ Oil is used as fuel.]]), node_name_ta3)
|
||||
minetest.register_lbm({
|
||||
label = "[techage] Oil Tower sound",
|
||||
name = "techage:oil_tower",
|
||||
nodenames = {"techage:ta3_drillbox_act"},
|
||||
nodenames = {"techage:ta3_drillbox_pas", "techage:ta3_drillbox_act"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.assemble_locked = false
|
||||
if mem.techage_state == techage.RUNNING then
|
||||
play_sound(pos)
|
||||
end
|
||||
|
@ -140,6 +140,10 @@ local function emerge_area(pos, node, player_name)
|
||||
local pos1 = {x = posC.x - radius, y = posC.y - radius, z = posC.z - radius}
|
||||
local pos2 = {x = posC.x + radius, y = posC.y + radius, z = posC.z + radius}
|
||||
local amount = oil_amount(posC)
|
||||
if creative and creative.is_enabled_for and
|
||||
creative.is_enabled_for(player_name) then
|
||||
amount = 10000
|
||||
end
|
||||
|
||||
minetest.sound_play("techage_explore", {
|
||||
pos = pos,
|
||||
|
@ -274,10 +274,12 @@ techage.oiltower = {}
|
||||
-- 1) mem.assemble_locked is true while the tower is being assembled/disassembled
|
||||
-- 2) mem.assemble_build is true if the tower is assembled
|
||||
function techage.oiltower.build(pos, player_name)
|
||||
minetest.chat_send_player(player_name, I("[TA] Tower is being built!"))
|
||||
techage.assemble.build(pos, AssemblyPlan, player_name)
|
||||
end
|
||||
|
||||
function techage.oiltower.remove(pos, player_name)
|
||||
minetest.chat_send_player(player_name, I("[TA] Tower is being removed!"))
|
||||
techage.assemble.remove(pos, AssemblyPlan, player_name)
|
||||
end
|
||||
|
||||
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 863 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 14 KiB |