This commit is contained in:
Joachim Stolberg 2019-06-09 15:02:17 +02:00
parent 116636380c
commit ae085ddc3f
17 changed files with 251 additions and 215 deletions

View File

@ -8,7 +8,7 @@
LGPLv2.1+ LGPLv2.1+
See LICENSE.txt for more information 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(), sounds = default.node_sound_wood_defaults(),
num_items = {0,1,2,4}, num_items = {0,1,2,4},
power_consumption = {0,3,4,5}, power_consumption = {0,3,4,5},
}) },
{false, true, false, false}) -- TA2 only
minetest.register_craft({ minetest.register_craft({
output = node_name_ta2, output = node_name_ta2,

View File

@ -77,16 +77,16 @@ end
local function check_space(pos, param2, AssemblyPlan, player_name) local function check_space(pos, param2, AssemblyPlan, player_name)
for _,item in ipairs(AssemblyPlan) do for _,item in ipairs(AssemblyPlan) do
local y, path, node_name = item[1], item[2], item[4] 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 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 return false
end end
local ndef = minetest.registered_nodes[minetest.get_node(pos1).name] local node = minetest.get_node(pos1)
--print(dump(ndef)) local ndef = minetest.registered_nodes[node.name]
if not ndef or ndef.walkable then if not ndef or ndef.walkable and node.name ~= node_name then
minetest.chat_send_player(player_name, I("Not enough space!")) minetest.chat_send_player(player_name, I("[TA] Not enough space!"))
return false return false
end end
end end

View File

@ -10,7 +10,7 @@
Consumer node basis functionality. Consumer node basis functionality.
It handles: It handles:
- 3 stages of nodes (TA2/TA3/TA4) - up to 3 stages of nodes (TA2/TA3/TA4)
- power consumption - power consumption
- node state handling - node state handling
- registration of passive, active and defect nodes - registration of passive, active and defect nodes
@ -76,8 +76,11 @@ local function prepare_tiles(tiles, stage, power_png)
return tbl return tbl
end 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 = {} local names = {}
validStates = validStates or {true, true, true, true}
for stage = 2,4 do for stage = 2,4 do
local name_pas = "techage:ta"..stage.."_"..base_name.."_pas" local name_pas = "techage:ta"..stage.."_"..base_name.."_pas"
local name_act = "techage:ta"..stage.."_"..base_name.."_act" 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 local name_inv = "TA"..stage.." "..inv_name
names[#names+1] = name_pas names[#names+1] = name_pas
local on_recv_message = tNode.tubing.on_recv_message if validStates[stage] then
if stage > 2 then local on_recv_message = tNode.tubing.on_recv_message
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 stage > 2 then if stage > 2 then
power_network = techage.ElectricCable on_recv_message = function(pos, topic, payload)
power_png = 'techage_appl_hole_electric.png' return "unsupported"
else end
power_network = techage.Axle
power_png = 'techage_axle_clutch.png'
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, local power_network
local power_png = 'techage_axle_clutch.png'
after_place_node = function(pos, placer, itemstack, pointed_thing) local power_used = tNode.power_consumption ~= nil
local meta = M(pos) -- power needed?
local mem = tubelib2.get_mem(pos) if power_used then
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 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 end
if tNode.after_place_node then power_network:add_secondary_node_names({name_pas, name_act})
tNode.after_place_node(pos, placer, itemstack, pointed_thing) end
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, { local tState = techage.NodeStates:new({
description = name_inv, node_name_passive = name_pas,
tiles = prepare_tiles(tiles.act, stage, power_png), node_name_active = name_act,
consumer = tConsumer, node_name_defect = name_def,
drawtype = tNode.drawtype, infotext_name = name_inv,
node_box = tNode.node_box, cycle_time = tNode.cycle_time,
selection_box = tNode.selection_box, standby_ticks = tNode.standby_ticks,
has_item_meter = tNode.has_item_meter,
on_rotate = screwdriver.disallow, aging_factor = tNode.aging_factor * (stage-1) * 2,
on_timer = tNode.node_timer, formspec_func = tNode.formspec,
on_receive_fields = tNode.on_receive_fields, on_state_change = tNode.on_state_change,
on_rightclick = tNode.on_rightclick, start_node = power_used and start_node or nil,
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put, stop_node = power_used and stop_node or nil,
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 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 end
techage.register_node({name_pas, name_act, name_def}, tNode.tubing)
end end
return names[1], names[2], names[3] return names[1], names[2], names[3]
end end

View File

@ -144,6 +144,7 @@ function NodeStates:new(attr)
start_node = attr.start_node, start_node = attr.start_node,
stop_node = attr.stop_node, stop_node = attr.stop_node,
formspec_func = attr.formspec_func, formspec_func = attr.formspec_func,
on_state_change = attr.on_state_change,
} }
if attr.aging_factor then if attr.aging_factor then
o.aging_level1 = attr.aging_factor * techage.machine_aging_value o.aging_level1 = attr.aging_factor * techage.machine_aging_value
@ -188,6 +189,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
if self.on_state_change then
self.on_state_change(pos, state, STOPPED)
end
if minetest.get_node_timer(pos):is_started() then if minetest.get_node_timer(pos):is_started() then
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
end end
@ -225,6 +229,9 @@ function NodeStates:start(pos, mem, called_from_on_timer)
if minetest.get_node_timer(pos):is_started() then if minetest.get_node_timer(pos):is_started() then
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
end end
if self.on_state_change then
self.on_state_change(pos, state, RUNNING)
end
minetest.get_node_timer(pos):start(self.cycle_time) minetest.get_node_timer(pos):start(self.cycle_time)
return true return true
end end
@ -232,8 +239,8 @@ function NodeStates:start(pos, mem, called_from_on_timer)
end end
function NodeStates:standby(pos, mem) function NodeStates:standby(pos, mem)
mem.techage_state = mem.techage_state or STOPPED local state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING then if state == RUNNING then
mem.techage_state = STANDBY mem.techage_state = STANDBY
-- 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
@ -250,6 +257,9 @@ function NodeStates:standby(pos, mem)
if minetest.get_node_timer(pos):is_started() then if minetest.get_node_timer(pos):is_started() then
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
end 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) minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
return true return true
end end
@ -258,8 +268,8 @@ end
-- special case of standby for pushing nodes -- special case of standby for pushing nodes
function NodeStates:blocked(pos, mem) function NodeStates:blocked(pos, mem)
mem.techage_state = mem.techage_state or STOPPED local state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING then if state == RUNNING then
mem.techage_state = BLOCKED mem.techage_state = BLOCKED
-- 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
@ -276,6 +286,9 @@ function NodeStates:blocked(pos, mem)
if minetest.get_node_timer(pos):is_started() then if minetest.get_node_timer(pos):is_started() then
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
end 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) minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
return true return true
end end
@ -283,8 +296,8 @@ function NodeStates:blocked(pos, mem)
end end
function NodeStates:nopower(pos, mem) function NodeStates:nopower(pos, mem)
mem.techage_state = mem.techage_state or STOPPED local state = mem.techage_state or RUNNING
if mem.techage_state ~= STOPPED and mem.techage_state ~= DEFECT then if state ~= STOPPED and state ~= DEFECT then
mem.techage_state = NOPOWER mem.techage_state = NOPOWER
if self.node_name_passive then if self.node_name_passive then
swap_node(pos, self.node_name_passive) swap_node(pos, self.node_name_passive)
@ -296,6 +309,9 @@ function NodeStates:nopower(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
if self.on_state_change then
self.on_state_change(pos, state, NOPOWER)
end
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
return true return true
end end
@ -303,8 +319,8 @@ function NodeStates:nopower(pos, mem)
end end
function NodeStates:fault(pos, mem) function NodeStates:fault(pos, mem)
mem.techage_state = mem.techage_state or STOPPED local state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING or mem.techage_state == STOPPED then if state == RUNNING or state == STOPPED then
mem.techage_state = FAULT mem.techage_state = FAULT
if self.node_name_passive then if self.node_name_passive then
swap_node(pos, self.node_name_passive) swap_node(pos, self.node_name_passive)
@ -316,6 +332,9 @@ function NodeStates:fault(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
if self.on_state_change then
self.on_state_change(pos, state, FAULT)
end
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
return true return true
end end
@ -323,6 +342,7 @@ function NodeStates:fault(pos, mem)
end end
function NodeStates:defect(pos, mem) function NodeStates:defect(pos, mem)
local state = mem.techage_state or STOPPED
mem.techage_state = DEFECT mem.techage_state = DEFECT
if self.node_name_defect then if self.node_name_defect then
swap_node(pos, self.node_name_defect) swap_node(pos, self.node_name_defect)
@ -334,6 +354,9 @@ function NodeStates:defect(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
if self.on_state_change then
self.on_state_change(pos, state, DEFECT)
end
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
return true return true
end end

View File

@ -35,14 +35,11 @@ local formspec0 = "size[5,4]"..
"button_exit[1,3.2;3,1;build;"..I("Build Tower").."]" "button_exit[1,3.2;3,1;build;"..I("Build Tower").."]"
local function play_sound(pos) local function play_sound(pos)
local mem = tubelib2.get_mem(pos) mem.handle = minetest.sound_play("techage_oildrill", {
if CRD(pos).State:is_active(mem) then pos = pos,
mem.handle = minetest.sound_play("techage_oildrill", { gain = 1,
pos = pos, max_hear_distance = 15})
gain = 1, minetest.after(4, play_sound, pos)
max_hear_distance = 15})
minetest.after(4, play_sound, pos)
end
end end
local function stop_sound(pos) 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;]".. "image_button[3.5,2;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
"label[6.2,0.5;OUT]".. "label[6.2,0.5;OUT]"..
"list[context;dst;6,1;1,1;]".. "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;]".. "list[current_player;main;0,4;8,4;]"..
"listring[context;dst]".. "listring[context;dst]"..
"listring[current_player;main]".. "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 if minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
--local meta = minetest.get_meta(pos)
--local inv = meta:get_inventory()
local crd = CRD(pos) local crd = CRD(pos)
if listname == "src" then if listname == "src" then
crd.State:start_if_standby(pos) 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)) M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
end 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) local function drilling(pos, crd, mem, inv)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem)) 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} 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) crd.State:idle(pos, mem)
elseif curr_depth >= depth then elseif curr_depth >= depth then
M(pos):set_string("oil_found", "true") M(pos):set_string("oil_found", "true")
stop_sound(pos)
crd.State:stop(pos, mem) crd.State:stop(pos, mem)
elseif minetest.is_protected(mem.drill_pos, owner) then elseif minetest.is_protected(mem.drill_pos, owner) then
stop_sound(pos)
crd.State:fault(pos, mem) crd.State:fault(pos, mem)
elseif node.name == "techage:oil_drillbit2" then elseif node.name == "techage:oil_drillbit2" then
mem.drill_pos.y = mem.drill_pos.y-1 mem.drill_pos.y = mem.drill_pos.y-1
@ -182,7 +183,7 @@ local function on_receive_fields(pos, formname, fields, player)
end end
if fields.build then if fields.build then
techage.oiltower.build(pos, player:get_player_name()) techage.oiltower.build(pos, player:get_player_name())
elseif fields.destroy then elseif fields.remove then
local inv = M(pos):get_inventory() local inv = M(pos):get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then if inv:is_empty("dst") and inv:is_empty("src") then
techage.oiltower.remove(pos, player:get_player_name()) techage.oiltower.remove(pos, player:get_player_name())
@ -190,13 +191,7 @@ local function on_receive_fields(pos, formname, fields, player)
else else
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
if not mem.assemble_locked and M(pos):get_string("oil_found") ~= "true" then 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 CRD(pos).State:state_button_event(pos, mem, fields)
if mem.techage_state == techage.RUNNING then
play_sound(pos)
else
stop_sound(pos)
end
end
end end
end end
end end
@ -289,7 +284,8 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
num_items = {0,1,1,1}, num_items = {0,1,1,1},
power_consumption = {0,10,16,24}, power_consumption = {0,10,16,24},
}) },
{false, false, true, false}) -- TA3 only
minetest.register_craft({ minetest.register_craft({
output = node_name_ta3, output = node_name_ta3,
@ -307,10 +303,11 @@ Oil is used as fuel.]]), node_name_ta3)
minetest.register_lbm({ minetest.register_lbm({
label = "[techage] Oil Tower sound", label = "[techage] Oil Tower sound",
name = "techage:oil_tower", name = "techage:oil_tower",
nodenames = {"techage:ta3_drillbox_act"}, nodenames = {"techage:ta3_drillbox_pas", "techage:ta3_drillbox_act"},
run_at_every_load = true, run_at_every_load = true,
action = function(pos, node) action = function(pos, node)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
mem.assemble_locked = false
if mem.techage_state == techage.RUNNING then if mem.techage_state == techage.RUNNING then
play_sound(pos) play_sound(pos)
end end

View File

@ -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 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 pos2 = {x = posC.x + radius, y = posC.y + radius, z = posC.z + radius}
local amount = oil_amount(posC) 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", { minetest.sound_play("techage_explore", {
pos = pos, pos = pos,

View File

@ -274,10 +274,12 @@ techage.oiltower = {}
-- 1) mem.assemble_locked is true while the tower is being assembled/disassembled -- 1) mem.assemble_locked is true while the tower is being assembled/disassembled
-- 2) mem.assemble_build is true if the tower is assembled -- 2) mem.assemble_build is true if the tower is assembled
function techage.oiltower.build(pos, player_name) 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) techage.assemble.build(pos, AssemblyPlan, player_name)
end end
function techage.oiltower.remove(pos, player_name) 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) techage.assemble.remove(pos, AssemblyPlan, player_name)
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 14 KiB