oil tower added
@ -49,7 +49,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:blackhole", {}, {
|
techage.register_node({"techage:blackhole"}, {
|
||||||
on_pull_item = nil, -- not needed
|
on_pull_item = nil, -- not needed
|
||||||
on_unpull_item = nil, -- not needed
|
on_unpull_item = nil, -- not needed
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ minetest.register_node("techage:chest_ta4", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:chest_ta2", {"techage:chest_ta3", "techage:chest_ta4"}, {
|
techage.register_node({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4"}, {
|
||||||
on_pull_item = function(pos, in_dir, num)
|
on_pull_item = function(pos, in_dir, num)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
@ -31,7 +31,7 @@ local function is_owner(pos, meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
techage.register_node("default:chest", {"default:chest_open"}, {
|
techage.register_node({"default:chest", "default:chest_open"}, {
|
||||||
on_pull_item = function(pos, in_dir, num)
|
on_pull_item = function(pos, in_dir, num)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -49,7 +49,7 @@ techage.register_node("default:chest", {"default:chest_open"}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("default:chest_locked", {"default:chest_locked_open"}, {
|
techage.register_node({"default:chest_locked", "default:chest_locked_open"}, {
|
||||||
on_pull_item = function(pos, in_dir, num)
|
on_pull_item = function(pos, in_dir, num)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if is_owner(pos, meta) then
|
if is_owner(pos, meta) then
|
||||||
@ -69,7 +69,7 @@ techage.register_node("default:chest_locked", {"default:chest_locked_open"}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("default:furnace", {"default:furnace_active"}, {
|
techage.register_node({"default:furnace", "default:furnace_active"}, {
|
||||||
on_pull_item = function(pos, in_dir, num)
|
on_pull_item = function(pos, in_dir, num)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
130
basis/assemble.lua
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
Assemble routines
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
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
|
||||||
|
|
||||||
|
-- Load support for intllib.
|
||||||
|
local MP = minetest.get_modpath("techage")
|
||||||
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
techage.assemble = {}
|
||||||
|
|
||||||
|
local Face2Dir = {[0]=
|
||||||
|
{x=0, y=0, z=1},
|
||||||
|
{x=1, y=0, z=0},
|
||||||
|
{x=0, y=0, z=-1},
|
||||||
|
{x=-1, y=0, z=0},
|
||||||
|
{x=0, y=-1, z=0},
|
||||||
|
{x=0, y=1, z=0}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Determine the destination position based on the base position,
|
||||||
|
-- param2, and a route table like : {0,3}
|
||||||
|
-- 0 = forward, 1 = right, 2 = backward, 3 = left
|
||||||
|
local function dest_pos(pos, param2, route, y_offs)
|
||||||
|
local p2 = param2
|
||||||
|
local pos1 = {x=pos.x, y=pos.y+y_offs, z=pos.z}
|
||||||
|
for _,dir in ipairs(route) do
|
||||||
|
p2 = (param2 + dir) % 4
|
||||||
|
pos1 = vector.add(pos1, Face2Dir[p2])
|
||||||
|
end
|
||||||
|
return pos1, p2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- timer based function
|
||||||
|
local function build(pos, param2, AssemblyPlan, idx)
|
||||||
|
local item = AssemblyPlan[idx]
|
||||||
|
if item ~= nil then
|
||||||
|
local y, path, fd_offs, node_name = item[1], item[2], item[3], item[4]
|
||||||
|
local pos1 = dest_pos(pos, param2, path, y)
|
||||||
|
minetest.add_node(pos1, {name=node_name, param2=(param2 + fd_offs) % 4})
|
||||||
|
minetest.after(0.5, build, pos, param2, AssemblyPlan, idx+1)
|
||||||
|
else
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.assemble_locked = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- timer based function
|
||||||
|
local function remove(pos, param2, AssemblyPlan, idx)
|
||||||
|
local item = AssemblyPlan[idx]
|
||||||
|
if item ~= nil then
|
||||||
|
local y, path = item[1], item[2]
|
||||||
|
local pos1 = dest_pos(pos, param2, path, y)
|
||||||
|
minetest.remove_node(pos1)
|
||||||
|
minetest.after(0.5, remove, pos, param2, AssemblyPlan, idx-1)
|
||||||
|
else
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.assemble_locked = false
|
||||||
|
end
|
||||||
|
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)
|
||||||
|
if minetest.is_protected(pos1, player_name) then
|
||||||
|
minetest.chat_send_player(player_name, I("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!"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Two important flags:
|
||||||
|
-- 1) mem.assemble_locked is true while the object is being assembled/disassembled
|
||||||
|
-- 2) mem.assemble_build is true if the object is assembled
|
||||||
|
function techage.assemble.build(pos, AssemblyPlan, player_name)
|
||||||
|
-- check protection
|
||||||
|
if minetest.is_protected(pos, player_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.assemble_locked then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if check_space(pos, node.param2, AssemblyPlan, player_name) then
|
||||||
|
mem.assemble_locked = true
|
||||||
|
build(pos, node.param2, AssemblyPlan, 1)
|
||||||
|
mem.assemble_build = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.assemble.remove(pos, AssemblyPlan, player_name)
|
||||||
|
-- check protection
|
||||||
|
if minetest.is_protected(pos, player_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.assemble_locked then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
mem.assemble_locked = true
|
||||||
|
remove(pos, node.param2, AssemblyPlan, #AssemblyPlan)
|
||||||
|
mem.assemble_build = false
|
||||||
|
end
|
@ -31,7 +31,6 @@ local function update_mod_storage()
|
|||||||
storage:set_string("NextNumber", minetest.serialize(NextNumber))
|
storage:set_string("NextNumber", minetest.serialize(NextNumber))
|
||||||
storage:set_string("Version", minetest.serialize(Version))
|
storage:set_string("Version", minetest.serialize(Version))
|
||||||
storage:set_string("Number2Pos", minetest.serialize(Number2Pos))
|
storage:set_string("Number2Pos", minetest.serialize(Number2Pos))
|
||||||
storage:set_string("Key2Number", nil) -- not used any more
|
|
||||||
-- store data each hour
|
-- store data each hour
|
||||||
minetest.after(60*59, update_mod_storage)
|
minetest.after(60*59, update_mod_storage)
|
||||||
minetest.log("action", "[TechAge] Data stored")
|
minetest.log("action", "[TechAge] Data stored")
|
||||||
@ -47,12 +46,17 @@ minetest.after(60*59, update_mod_storage)
|
|||||||
-- Key2Number will be generated at runtine
|
-- Key2Number will be generated at runtine
|
||||||
local Key2Number = {}
|
local Key2Number = {}
|
||||||
|
|
||||||
local Name2Name = {} -- translation table
|
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
-- Local helper functions
|
-- Local helper functions
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
local function in_list(list, x)
|
||||||
|
for _, v in ipairs(list) do
|
||||||
|
if v == x then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Localize functions to avoid table lookups (better performance).
|
-- Localize functions to avoid table lookups (better performance).
|
||||||
local string_split = string.split
|
local string_split = string.split
|
||||||
local NodeDef = techage.NodeDef
|
local NodeDef = techage.NodeDef
|
||||||
@ -97,9 +101,8 @@ local function register_lbm(name, nodenames)
|
|||||||
nodenames = nodenames,
|
nodenames = nodenames,
|
||||||
run_at_every_load = true,
|
run_at_every_load = true,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local name = Name2Name[node.name]
|
if NodeDef[node.name] and NodeDef[node.name].on_node_load then
|
||||||
if NodeDef[name] and NodeDef[name].on_node_load then
|
NodeDef[node.name].on_node_load(pos)
|
||||||
NodeDef[name].on_node_load(pos)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
@ -134,13 +137,13 @@ end
|
|||||||
local function get_next_node(pos, out_dir)
|
local function get_next_node(pos, out_dir)
|
||||||
local res, npos, node = Tube:compatible_node(pos, out_dir)
|
local res, npos, node = Tube:compatible_node(pos, out_dir)
|
||||||
local in_dir = tubelib2.Turn180Deg[out_dir]
|
local in_dir = tubelib2.Turn180Deg[out_dir]
|
||||||
return res, npos, in_dir, Name2Name[node.name] or node.name
|
return res, npos, in_dir, node.name
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_dest_node(pos, out_dir)
|
local function get_dest_node(pos, out_dir)
|
||||||
local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir)
|
local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir)
|
||||||
local _,node = Tube:get_node(spos)
|
local _,node = Tube:get_node(spos)
|
||||||
return spos, in_dir, Name2Name[node.name] or node.name
|
return spos, in_dir, node.name
|
||||||
end
|
end
|
||||||
|
|
||||||
local function item_handling_node(name)
|
local function item_handling_node(name)
|
||||||
@ -245,8 +248,7 @@ end
|
|||||||
|
|
||||||
-- Register node for techage communication
|
-- Register node for techage communication
|
||||||
-- Call this function only at load time!
|
-- Call this function only at load time!
|
||||||
-- Param name: The node name like "techage:pusher"
|
-- Param names: List of node names like {"techage:pusher_off", "techage:pusher_on"}
|
||||||
-- Param add_names: Alternativ node names if needded, e.g.: "techage:pusher_active"
|
|
||||||
-- Param node_definition: A table according to:
|
-- Param node_definition: A table according to:
|
||||||
-- {
|
-- {
|
||||||
-- on_pull_item = func(pos, in_dir, num),
|
-- on_pull_item = func(pos, in_dir, num),
|
||||||
@ -255,31 +257,24 @@ end
|
|||||||
-- on_recv_message = func(pos, topic, payload),
|
-- on_recv_message = func(pos, topic, payload),
|
||||||
-- on_node_load = func(pos), -- LBM function
|
-- on_node_load = func(pos), -- LBM function
|
||||||
-- on_node_repair = func(pos), -- repair defect (feature!) nodes
|
-- on_node_repair = func(pos), -- repair defect (feature!) nodes
|
||||||
|
-- on_transfer = func(pos, in_dir, topic, payload),
|
||||||
-- }
|
-- }
|
||||||
function techage.register_node(name, add_names, node_definition)
|
function techage.register_node(names, node_definition)
|
||||||
NodeDef[name] = node_definition
|
|
||||||
-- store facedir table for all known node names
|
-- store facedir table for all known node names
|
||||||
Name2Name[name] = name
|
for _,n in ipairs(names) do
|
||||||
for _,n in ipairs(add_names) do
|
NodeDef[n] = node_definition
|
||||||
Name2Name[n] = name
|
|
||||||
end
|
end
|
||||||
if node_definition.on_pull_item or node_definition.on_push_item or
|
if node_definition.on_pull_item or node_definition.on_push_item or
|
||||||
node_definition.is_pusher then
|
node_definition.is_pusher then
|
||||||
Tube:add_secondary_node_names({name})
|
Tube:add_secondary_node_names(names)
|
||||||
Tube:add_secondary_node_names(add_names)
|
|
||||||
|
|
||||||
techage.KnownNodes[name] = true
|
for _,n in ipairs(names) do
|
||||||
for _,n in ipairs(add_names) do
|
|
||||||
techage.KnownNodes[n] = true
|
techage.KnownNodes[n] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- register LBM
|
-- register LBM
|
||||||
if node_definition.on_node_load then
|
if node_definition.on_node_load then
|
||||||
local nodenames = {name}
|
register_lbm(names[1], names)
|
||||||
for _,n in ipairs(add_names) do
|
|
||||||
nodenames[#nodenames + 1] = n
|
|
||||||
end
|
|
||||||
register_lbm(name, nodenames)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -287,7 +282,7 @@ end
|
|||||||
-- Send message functions
|
-- Send message functions
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
function techage.send_message(numbers, placer_name, clicker_name, topic, payload)
|
function techage.send_multi(numbers, placer_name, clicker_name, topic, payload)
|
||||||
for _,num in ipairs(string_split(numbers, " ")) do
|
for _,num in ipairs(string_split(numbers, " ")) do
|
||||||
if Number2Pos[num] and Number2Pos[num].name then
|
if Number2Pos[num] and Number2Pos[num].name then
|
||||||
local data = Number2Pos[num]
|
local data = Number2Pos[num]
|
||||||
@ -300,7 +295,7 @@ function techage.send_message(numbers, placer_name, clicker_name, topic, payload
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.send_request(number, topic, payload)
|
function techage.send_single(number, topic, payload)
|
||||||
if Number2Pos[number] and Number2Pos[number].name then
|
if Number2Pos[number] and Number2Pos[number].name then
|
||||||
local data = Number2Pos[number]
|
local data = Number2Pos[number]
|
||||||
if NodeDef[data.name] and NodeDef[data.name].on_recv_message then
|
if NodeDef[data.name] and NodeDef[data.name].on_recv_message then
|
||||||
@ -310,12 +305,45 @@ function techage.send_request(number, topic, payload)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The destination node location is either:
|
||||||
|
-- A) a destination position, specified by pos
|
||||||
|
-- B) a neighbor position, specified by caller pos/outdir, or pos/side
|
||||||
|
-- C) a tubelib2 network connection, specified by caller pos/outdir, or pos/side
|
||||||
|
-- outdir is one of: 1..6
|
||||||
|
-- side is one of: "B", "R", "F", "L", "D", "U"
|
||||||
|
-- network is a tuebelib2 network instance
|
||||||
|
-- opt: nodenames is a table of valid the callee node names
|
||||||
|
function techage.transfer(pos, outdir, topic, payload, network, nodenames)
|
||||||
|
-- determine out-dir
|
||||||
|
if outdir and type(outdir) == "string" then
|
||||||
|
local param2 = Tube:get_node_lvm(pos).param2
|
||||||
|
outdir = side_to_dir(outdir, param2)
|
||||||
|
end
|
||||||
|
-- determine destination pos
|
||||||
|
local dpos, indir
|
||||||
|
if network then
|
||||||
|
dpos, indir = network:get_connected_node_pos(pos, outdir)
|
||||||
|
else
|
||||||
|
dpos, indir = tubelib2.get_pos(pos, outdir)
|
||||||
|
end
|
||||||
|
-- check node name
|
||||||
|
local name = Tube:get_node_lvm(dpos).name
|
||||||
|
if nodenames and not in_list(nodenames, name) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
-- call "on_transfer"
|
||||||
|
local ndef = NodeDef[name]
|
||||||
|
if ndef and ndef.on_transfer then
|
||||||
|
return ndef.on_transfer(dpos, indir, topic, payload)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- for defect nodes
|
-- for defect nodes
|
||||||
function techage.repair_node(pos)
|
function techage.repair_node(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local name = Name2Name[node.name]
|
if NodeDef[node.name] and NodeDef[node.name].on_node_repair then
|
||||||
if NodeDef[name] and NodeDef[name].on_node_repair then
|
return NodeDef[node.name].on_node_repair(pos)
|
||||||
return NodeDef[name].on_node_repair(pos)
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -266,7 +266,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||||||
power_network = power_network,
|
power_network = power_network,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
techage.register_node(name_pas, {name_act, name_def}, tNode.tubing)
|
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
|
||||||
|
@ -22,8 +22,6 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||||||
|
|
||||||
techage.firebox = {}
|
techage.firebox = {}
|
||||||
|
|
||||||
local BURN_TIME_FACTOR = 1
|
|
||||||
|
|
||||||
techage.firebox.Burntime = {
|
techage.firebox.Burntime = {
|
||||||
["techage:charcoal"] = true, -- will be replaced by burntime
|
["techage:charcoal"] = true, -- will be replaced by burntime
|
||||||
["default:coal_lump"] = true,
|
["default:coal_lump"] = true,
|
||||||
@ -34,7 +32,7 @@ techage.firebox.Burntime = {
|
|||||||
local function determine_burntimes()
|
local function determine_burntimes()
|
||||||
for k,_ in pairs(techage.firebox.Burntime)do
|
for k,_ in pairs(techage.firebox.Burntime)do
|
||||||
local fuel,_ = minetest.get_craft_result({method = "fuel", width = 1, items = {k}})
|
local fuel,_ = minetest.get_craft_result({method = "fuel", width = 1, items = {k}})
|
||||||
techage.firebox.Burntime[k] = fuel.time * BURN_TIME_FACTOR
|
techage.firebox.Burntime[k] = fuel.time
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.after(1, determine_burntimes)
|
minetest.after(1, determine_burntimes)
|
||||||
@ -44,18 +42,21 @@ function techage.firebox.formspec(mem)
|
|||||||
if mem.running then
|
if mem.running then
|
||||||
fuel_percent = ((mem.burn_cycles or 1) * 100) / (mem.burn_cycles_total or 1)
|
fuel_percent = ((mem.burn_cycles or 1) * 100) / (mem.burn_cycles_total or 1)
|
||||||
end
|
end
|
||||||
return "size[8,6]"..
|
local power_level = mem.power_level or 4
|
||||||
|
return "size[8,6.5]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
"list[current_name;fuel;1,0.5;1,1;]"..
|
"list[current_name;fuel;1,0.5;1,1;]"..
|
||||||
"image[3,0.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
"image[2,0.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
fuel_percent..":default_furnace_fire_fg.png]"..
|
fuel_percent..":default_furnace_fire_fg.png]"..
|
||||||
"button[5,0.5;1.8,1;update;"..I("Update").."]"..
|
"label[4.5,0.1;"..I("Power")..":]"..
|
||||||
"list[current_player;main;0,2;8,4;]"..
|
"dropdown[6,0;1.8;power_level;25%,50%,75%,100%;"..power_level.."]"..
|
||||||
|
"button[1,1.5;1.8,1;update;"..I("Update").."]"..
|
||||||
|
"list[current_player;main;0,2.8;8,4;]"..
|
||||||
"listring[current_name;fuel]"..
|
"listring[current_name;fuel]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
default.get_hotbar_bg(0, 2)
|
default.get_hotbar_bg(0, 2.8)
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.firebox.can_dig(pos, player)
|
function techage.firebox.can_dig(pos, player)
|
||||||
@ -74,15 +75,34 @@ function techage.firebox.allow_metadata_inventory(pos, listname, index, stack, p
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local PowerLevel = {
|
||||||
|
["25%"] = 1,
|
||||||
|
["50%"] = 2,
|
||||||
|
["75%"] = 3,
|
||||||
|
["100%"] = 4,
|
||||||
|
}
|
||||||
|
|
||||||
function techage.firebox.on_receive_fields(pos, formname, fields, player)
|
function techage.firebox.on_receive_fields(pos, formname, fields, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
print(dump(fields))
|
||||||
if fields.update then
|
if fields.update then
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
M(pos):set_string("formspec", techage.firebox.formspec(mem))
|
M(pos):set_string("formspec", techage.firebox.formspec(mem))
|
||||||
end
|
end
|
||||||
|
if fields.power_level then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.power_level = PowerLevel[fields.power_level]
|
||||||
|
techage.transfer(
|
||||||
|
{x=pos.x, y=pos.y+2, z=pos.z},
|
||||||
|
nil, -- outdir
|
||||||
|
"power_level", -- topic
|
||||||
|
mem.power_level, -- payload
|
||||||
|
nil, -- network
|
||||||
|
{"techage:coalboiler_top"} -- nodenames
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.firebox.on_rightclick(pos, node, clicker)
|
function techage.firebox.on_rightclick(pos, node, clicker)
|
||||||
|
@ -53,3 +53,14 @@ function techage.is_primary_node(pos, dir)
|
|||||||
local param2 = M(npos):get_int("tl2_param2")
|
local param2 = M(npos):get_int("tl2_param2")
|
||||||
return param2 ~= 0
|
return param2 ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- returns true if node can be dug
|
||||||
|
function techage.can_node_dig(node)
|
||||||
|
-- don't remove nodes with some intelligence or undiggable nodes
|
||||||
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
if not ndef or node.name == "air" then return false end
|
||||||
|
if ndef.drop == "" then return false end
|
||||||
|
if ndef.diggable == false then return false end
|
||||||
|
if ndef.after_dig_node then return false end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
@ -23,10 +23,6 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||||||
|
|
||||||
local Pipe = techage.SteamPipe
|
local Pipe = techage.SteamPipe
|
||||||
|
|
||||||
local function turn_on(pos, mem, in_dir, on)
|
|
||||||
return on
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("techage:coalboiler_base", {
|
minetest.register_node("techage:coalboiler_base", {
|
||||||
description = I("TA3 Boiler Base"),
|
description = I("TA3 Boiler Base"),
|
||||||
tiles = {"techage_coal_boiler_mesh_base.png"},
|
tiles = {"techage_coal_boiler_mesh_base.png"},
|
||||||
@ -48,11 +44,20 @@ minetest.register_node("techage:coalboiler_base", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
techage.power.register_node({"techage:coalboiler_base"}, {
|
techage.power.register_node({"techage:coalboiler_base"}, {
|
||||||
turn_on = turn_on,
|
|
||||||
conn_sides = {"F"},
|
conn_sides = {"F"},
|
||||||
power_network = Pipe,
|
power_network = Pipe,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
techage.register_node({"techage:coalboiler_base"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
if topic == "start" then
|
||||||
|
return true
|
||||||
|
elseif topic == "stop" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:coalboiler_base",
|
output = "techage:coalboiler_base",
|
||||||
|
@ -65,13 +65,14 @@ local function can_start(pos, mem, state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function start_node(pos, mem, state)
|
local function start_node(pos, mem, state)
|
||||||
local out_dir = techage.power.side_to_outdir(pos, "F")
|
print("start_node", S(pos))
|
||||||
mem.running = techage.power.start_line_node(pos, out_dir, "techage:turbine", true)
|
mem.running = techage.transfer(pos, "F", "start", nil, Pipe, {"techage:turbine"})
|
||||||
|
techage.transfer(pos, "F", "power_level", mem.power_level, Pipe, {"techage:turbine"})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stop_node(pos, mem, state)
|
local function stop_node(pos, mem, state)
|
||||||
local out_dir = techage.power.side_to_outdir(pos, "F")
|
print("stop_node", S(pos))
|
||||||
techage.power.start_line_node(pos, out_dir, "techage:turbine_on", false)
|
techage.transfer(pos, "F", "stop", nil, Pipe, {"techage:turbine_on"})
|
||||||
mem.running = false
|
mem.running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -254,14 +255,6 @@ minetest.register_node("techage:coalboiler_top", {
|
|||||||
minetest.after(0.5, move_to_water, pos)
|
minetest.after(0.5, move_to_water, pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
trigger_boiler = function(pos)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
mem.fire_trigger = true
|
|
||||||
if not minetest.get_node_timer(pos):is_started() then
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
drop = "",
|
drop = "",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
@ -274,7 +267,26 @@ techage.power.register_node({"techage:coalboiler_top"}, {
|
|||||||
conn_sides = {"F"},
|
conn_sides = {"F"},
|
||||||
power_network = Pipe,
|
power_network = Pipe,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:coalboiler_top"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
if topic == "trigger" then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.fire_trigger = true
|
||||||
|
if not minetest.get_node_timer(pos):is_started() then
|
||||||
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
|
end
|
||||||
|
elseif topic == "power_level" then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.power_level = payload
|
||||||
|
print("coalboiler_top power_level", payload)
|
||||||
|
techage.transfer(pos, "F", topic, payload, Pipe,
|
||||||
|
{"techage:turbine", "techage:turbine_on"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:coalboiler_top",
|
output = "techage:coalboiler_top",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -21,7 +21,7 @@ local M = minetest.get_meta
|
|||||||
local MP = minetest.get_modpath("techage")
|
local MP = minetest.get_modpath("techage")
|
||||||
local I,_ = dofile(MP.."/intllib.lua")
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
local Power = techage.SteamPipe
|
local Pipe = techage.SteamPipe
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
@ -32,17 +32,6 @@ local function swap_node(pos, name)
|
|||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- called from pipe network
|
|
||||||
local function turn_on(pos, mem, dir, on)
|
|
||||||
on = techage.power.start_line_node(pos, dir, "techage:coalboiler_base", on)
|
|
||||||
if on then
|
|
||||||
swap_node(pos, "techage:cooler_on")
|
|
||||||
else
|
|
||||||
swap_node(pos, "techage:cooler")
|
|
||||||
end
|
|
||||||
return on
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("techage:cooler", {
|
minetest.register_node("techage:cooler", {
|
||||||
description = I("TA3 Cooler"),
|
description = I("TA3 Cooler"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -102,10 +91,27 @@ minetest.register_node("techage:cooler_on", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- for mechanical pipe connections
|
||||||
techage.power.register_node({"techage:cooler", "techage:cooler_on"}, {
|
techage.power.register_node({"techage:cooler", "techage:cooler_on"}, {
|
||||||
turn_on = turn_on,
|
|
||||||
conn_sides = {"L", "R"},
|
conn_sides = {"L", "R"},
|
||||||
power_network = Power,
|
power_network = Pipe,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
techage.register_node({"techage:cooler", "techage:cooler_on"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
if topic == "start" then
|
||||||
|
local on = techage.transfer(pos, in_dir, "start", nil, Pipe, {"techage:coalboiler_base"})
|
||||||
|
if on then
|
||||||
|
swap_node(pos, "techage:cooler_on")
|
||||||
|
end
|
||||||
|
return on
|
||||||
|
elseif topic == "stop" then
|
||||||
|
techage.transfer(pos, in_dir, "stop", nil, Pipe, {"techage:coalboiler_base"})
|
||||||
|
swap_node(pos, "techage:cooler")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -40,16 +40,22 @@ end
|
|||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
if mem.running then
|
if mem.running then
|
||||||
local ndef = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}).name]
|
techage.transfer(
|
||||||
if ndef and ndef.trigger_boiler then
|
{x=pos.x, y=pos.y+2, z=pos.z},
|
||||||
ndef.trigger_boiler({x=pos.x, y=pos.y+2, z=pos.z})
|
nil, -- outdir
|
||||||
end
|
"trigger", -- topic
|
||||||
|
nil, -- payload
|
||||||
|
nil, -- network
|
||||||
|
{"techage:coalboiler_top"} -- nodenames
|
||||||
|
)
|
||||||
mem.burn_cycles = (mem.burn_cycles or 0) - 1
|
mem.burn_cycles = (mem.burn_cycles or 0) - 1
|
||||||
if mem.burn_cycles <= 0 then
|
if mem.burn_cycles <= 0 then
|
||||||
local taken = firebox.get_fuel(pos)
|
local taken = firebox.get_fuel(pos)
|
||||||
if taken then
|
if taken then
|
||||||
mem.burn_cycles = firebox.Burntime[taken:get_name()] / CYCLE_TIME
|
mem.burn_cycles = firebox.Burntime[taken:get_name()] / CYCLE_TIME
|
||||||
|
mem.burn_cycles = mem.burn_cycles * 4 / (mem.power_level or 4)
|
||||||
mem.burn_cycles_total = mem.burn_cycles
|
mem.burn_cycles_total = mem.burn_cycles
|
||||||
|
print("firebox", mem.burn_cycles_total)
|
||||||
else
|
else
|
||||||
mem.running = false
|
mem.running = false
|
||||||
firehole(pos, false)
|
firehole(pos, false)
|
||||||
@ -174,6 +180,33 @@ minetest.register_node("techage:coalfirehole_on", {
|
|||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:coalfirehole", "techage:coalfirehole_on"}, {
|
||||||
|
on_pull_item = function(pos, in_dir, num)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.get_items(inv, "fuel", num)
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.put_items(inv, "fuel", stack)
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.put_items(inv, "fuel", stack)
|
||||||
|
end,
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
if topic == "state" then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
return techage.get_inv_state(meta, "fuel")
|
||||||
|
else
|
||||||
|
return "unsupported"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:coalfirebox",
|
output = "techage:coalfirebox",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -183,7 +216,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:coalfirebox", {}, {
|
techage.register_node({"techage:coalfirebox"}, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -206,3 +239,4 @@ minetest.register_lbm({
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ local I,_ = dofile(MP.."/intllib.lua")
|
|||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 4
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 8
|
local CYCLE_TIME = 8
|
||||||
local POWER_CAPACITY = 75
|
local POWER_CAPACITY = 80
|
||||||
|
|
||||||
local Cable = techage.ElectricCable
|
local Cable = techage.ElectricCable
|
||||||
|
|
||||||
@ -43,7 +43,10 @@ end
|
|||||||
local function turbine_running(pos)
|
local function turbine_running(pos)
|
||||||
local pos1 = techage.get_pos(pos, 'L')
|
local pos1 = techage.get_pos(pos, 'L')
|
||||||
local node = minetest.get_node(pos1)
|
local node = minetest.get_node(pos1)
|
||||||
return node.name == "techage:turbine_on"
|
if node.name == "techage:turbine_on" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_node(pos, mem, state)
|
local function start_node(pos, mem, state)
|
||||||
@ -68,7 +71,7 @@ local State = techage.NodeStates:new({
|
|||||||
-- Pass1: Power balance calculation
|
-- Pass1: Power balance calculation
|
||||||
local function on_power_pass1(pos, mem)
|
local function on_power_pass1(pos, mem)
|
||||||
if State:is_active(mem) then
|
if State:is_active(mem) then
|
||||||
return -POWER_CAPACITY
|
return -POWER_CAPACITY * (mem.power_level or 4) / 4
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -117,6 +120,7 @@ end
|
|||||||
|
|
||||||
local function on_rightclick(pos)
|
local function on_rightclick(pos)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
techage.power.power_distribution(pos)
|
||||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -216,6 +220,18 @@ techage.power.register_node({"techage:generator", "techage:generator_on"}, {
|
|||||||
power_network = Cable,
|
power_network = Cable,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
techage.register_node({"techage:generator", "techage:generator_on"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
print("generator", topic, payload)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if topic == "power_level" then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.power_level = payload
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
techage.register_help_page(I("TA3 Generator"),
|
techage.register_help_page(I("TA3 Generator"),
|
||||||
I([[Part of the Coal Power Station.
|
I([[Part of the Coal Power Station.
|
||||||
Has to be placed side by side
|
Has to be placed side by side
|
||||||
|
@ -21,7 +21,7 @@ local M = minetest.get_meta
|
|||||||
local MP = minetest.get_modpath("techage")
|
local MP = minetest.get_modpath("techage")
|
||||||
local I,_ = dofile(MP.."/intllib.lua")
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
local Power = techage.SteamPipe
|
local Pipe = techage.SteamPipe
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
@ -51,25 +51,14 @@ local function stop_sound(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- called from pipe network
|
-- called with any pipe change
|
||||||
local function turn_on(pos, mem, dir, on)
|
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
if on then
|
local mem = tubelib2.get_mem(pos)
|
||||||
on = techage.power.start_line_node(pos, 6, "techage:cooler", true)
|
techage.transfer(pos, 6, "stop", nil, Pipe, {"techage:cooler_on"})
|
||||||
else
|
swap_node(pos, "techage:turbine")
|
||||||
techage.power.start_line_node(pos, 6, "techage:cooler_on", false)
|
mem.running = false
|
||||||
end
|
stop_sound(pos)
|
||||||
|
end
|
||||||
if on then
|
|
||||||
swap_node(pos, "techage:turbine_on")
|
|
||||||
mem.running = true
|
|
||||||
play_sound(pos)
|
|
||||||
else
|
|
||||||
swap_node(pos, "techage:turbine")
|
|
||||||
mem.running = false
|
|
||||||
stop_sound(pos)
|
|
||||||
end
|
|
||||||
return on
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("techage:turbine", {
|
minetest.register_node("techage:turbine", {
|
||||||
description = I("TA3 Turbine"),
|
description = I("TA3 Turbine"),
|
||||||
@ -119,6 +108,7 @@ minetest.register_node("techage:turbine_on", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
after_tube_update = after_tube_update,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
@ -128,16 +118,44 @@ minetest.register_node("techage:turbine_on", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- for mechanical pipe connections
|
||||||
techage.power.register_node({"techage:turbine", "techage:turbine_on"}, {
|
techage.power.register_node({"techage:turbine", "techage:turbine_on"}, {
|
||||||
turn_on = turn_on,
|
|
||||||
conn_sides = {"L", "U"},
|
conn_sides = {"L", "U"},
|
||||||
power_network = Power,
|
power_network = Pipe,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
techage.register_node({"techage:turbine", "techage:turbine_on"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
print("turbine", topic, payload)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if topic == "power_level" then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.power_level = payload
|
||||||
|
techage.transfer(pos, "R", topic, payload, nil,
|
||||||
|
{"techage:generator", "techage:generator_on"})
|
||||||
|
elseif topic == "start" then
|
||||||
|
local on = techage.transfer(pos, 6, "start", nil, Pipe, {"techage:cooler"})
|
||||||
|
if on then
|
||||||
|
swap_node(pos, "techage:turbine_on")
|
||||||
|
mem.running = true
|
||||||
|
play_sound(pos)
|
||||||
|
end
|
||||||
|
return on
|
||||||
|
elseif topic == "stop" then
|
||||||
|
techage.transfer(pos, 6, "stop", nil, Pipe, {"techage:cooler_on"})
|
||||||
|
swap_node(pos, "techage:turbine")
|
||||||
|
mem.running = false
|
||||||
|
stop_sound(pos)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:turbine",
|
output = "techage:turbine",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"basic_materials:steel_bar", "techage:iron_ingot", "default:wood"},
|
{"basic_materials:steel_bar", "techage:steam_pipeS", "default:wood"},
|
||||||
{"techage:steam_pipeS", "basic_materials:gear_steel", ""},
|
{"techage:steam_pipeS", "basic_materials:gear_steel", ""},
|
||||||
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
|
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
|
||||||
},
|
},
|
||||||
|
3
init.lua
@ -32,6 +32,7 @@ else
|
|||||||
dofile(MP.."/basis/consumer.lua") -- consumer base model
|
dofile(MP.."/basis/consumer.lua") -- consumer base model
|
||||||
dofile(MP.."/basis/firebox_lib.lua") -- common firebox functions
|
dofile(MP.."/basis/firebox_lib.lua") -- common firebox functions
|
||||||
dofile(MP.."/basis/mark.lua")
|
dofile(MP.."/basis/mark.lua")
|
||||||
|
dofile(MP.."/basis/assemble.lua")
|
||||||
|
|
||||||
-- Overrides
|
-- Overrides
|
||||||
dofile(MP.."/overrides/signs_bot.lua")
|
dofile(MP.."/overrides/signs_bot.lua")
|
||||||
@ -116,6 +117,8 @@ else
|
|||||||
|
|
||||||
-- Oil
|
-- Oil
|
||||||
dofile(MP.."/oil/explore.lua")
|
dofile(MP.."/oil/explore.lua")
|
||||||
|
dofile(MP.."/oil/tower.lua")
|
||||||
|
dofile(MP.."/oil/drillbox.lua")
|
||||||
|
|
||||||
|
|
||||||
--dofile(MP.."/test/generator.lua")
|
--dofile(MP.."/test/generator.lua")
|
||||||
|
@ -139,7 +139,7 @@ for idx = 0,3 do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
techage.register_node("techage:sieve0", {"techage:sieve1", "techage:sieve2", "techage:sieve3"}, {
|
techage.register_node({"techage:sieve0", "techage:sieve1", "techage:sieve2", "techage:sieve3"}, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
@ -143,7 +143,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:hopper_ta1", {}, {
|
techage.register_node({"techage:hopper_ta1"}, {
|
||||||
on_pull_item = nil, -- not needed
|
on_pull_item = nil, -- not needed
|
||||||
on_unpull_item = nil, -- not needed
|
on_unpull_item = nil, -- not needed
|
||||||
|
|
||||||
|
317
oil/drillbox.lua
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA3 Oil Drill Box
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
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
|
||||||
|
-- Consumer Related Data
|
||||||
|
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
||||||
|
|
||||||
|
-- Load support for intllib.
|
||||||
|
local MP = minetest.get_modpath("techage")
|
||||||
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
local STANDBY_TICKS = 4
|
||||||
|
local COUNTDOWN_TICKS = 6
|
||||||
|
local CYCLE_TIME = 8
|
||||||
|
|
||||||
|
local formspec0 = "size[5,4]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"image[1,0;3.4,3.4;techage_oil_tower_inv.png]"..
|
||||||
|
"button_exit[1,3.2;3,1;build;"..I("Build Tower").."]"
|
||||||
|
|
||||||
|
local function play_sound(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.techage_state == techage.RUNNING then
|
||||||
|
mem.handle = minetest.sound_play("techage_oildrill", {
|
||||||
|
pos = pos,
|
||||||
|
gain = 1,
|
||||||
|
max_hear_distance = 15})
|
||||||
|
minetest.after(4, play_sound, pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function stop_sound(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.techage_state ~= techage.RUNNING and mem.handle then
|
||||||
|
minetest.sound_stop(mem.handle)
|
||||||
|
mem.handle = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function formspec(self, pos, mem)
|
||||||
|
if not mem.assemble_build then
|
||||||
|
return formspec0
|
||||||
|
end
|
||||||
|
local depth = M(pos):get_int("depth")
|
||||||
|
local curr_depth = pos.y - (mem.drill_pos or pos).y
|
||||||
|
return "size[8,8]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"list[context;src;1,1;1,1;]"..
|
||||||
|
"label[1.3,0.5;IN]"..
|
||||||
|
"item_image[1,1;1,1;techage:oil_drillbit]"..
|
||||||
|
"label[1,2;"..I("Drill Bit").."]"..
|
||||||
|
"label[0.5,3;"..I("Depth")..": "..curr_depth.."/"..depth.."]"..
|
||||||
|
"image[3.5,0;1,1;"..techage.get_power_image(pos, mem).."]"..
|
||||||
|
"image[3.5,1;1,1;techage_form_arrow.png]"..
|
||||||
|
"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").."]"..
|
||||||
|
"list[current_player;main;0,4;8,4;]"..
|
||||||
|
"listring[context;dst]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;src]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 4)
|
||||||
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local stack = inv:get_stack(from_list, from_index)
|
||||||
|
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drilling(pos, crd, mem, inv)
|
||||||
|
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
||||||
|
print("drilling")
|
||||||
|
if inv:contains_item("src", ItemStack("techage:oil_drillbit")) then
|
||||||
|
mem.drill_pos = mem.drill_pos or {x=pos.x, y=pos.y, z=pos.z}
|
||||||
|
mem.drill_pos.y = mem.drill_pos.y-1
|
||||||
|
local owner = M(pos):get_string("owner")
|
||||||
|
local depth = M(pos):get_int("depth")
|
||||||
|
if mem.drill_pos.y > -depth then
|
||||||
|
if not minetest.is_protected(mem.drill_pos, owner) then
|
||||||
|
local node = minetest.get_node(mem.drill_pos)
|
||||||
|
if node.name ~= "techage:oil_drillbit2" then
|
||||||
|
local item = ItemStack(node.name)
|
||||||
|
if techage.can_node_dig(node) then
|
||||||
|
if inv:room_for_item("dst", item) then
|
||||||
|
inv:add_item("dst", item)
|
||||||
|
else
|
||||||
|
stop_sound(pos)
|
||||||
|
crd.State:blocked(pos, mem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.swap_node(mem.drill_pos, {name = "techage:oil_drillbit2"})
|
||||||
|
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
stop_sound(pos)
|
||||||
|
crd.State:fault(pos, mem)
|
||||||
|
end
|
||||||
|
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
M(pos):set_string("oil_found", "true")
|
||||||
|
stop_sound(pos)
|
||||||
|
crd.State:stop(pos, mem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
crd.State:idle(pos, mem)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function keep_running(pos, elapsed)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
local crd = CRD(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
if inv then
|
||||||
|
drilling(pos, crd, mem, inv)
|
||||||
|
end
|
||||||
|
return crd.State:is_active(mem)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function can_dig(pos, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.assemble_locked or mem.assemble_build then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return inv:is_empty("dst") and inv:is_empty("src")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if fields.build then
|
||||||
|
techage.oiltower.build(pos, player:get_player_name())
|
||||||
|
elseif fields.destroy 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())
|
||||||
|
end
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local tiles = {}
|
||||||
|
-- '#' will be replaced by the stage number
|
||||||
|
tiles.pas = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta#.png^techage_frame_ta#_top.png",
|
||||||
|
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||||
|
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||||
|
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||||
|
"techage_filling_ta#.png^techage_appl_oildrill.png^techage_frame_ta#.png",
|
||||||
|
"techage_filling_ta#.png^techage_appl_oildrill.png^techage_frame_ta#.png",
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles.act = tiles.pas
|
||||||
|
tiles.def = tiles.pas
|
||||||
|
|
||||||
|
local tubing = {
|
||||||
|
on_pull_item = function(pos, in_dir, num)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("pull_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.get_items(inv, "dst", num)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("push_dir") == in_dir or in_dir == 5 then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.put_items(inv, "src", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("pull_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.put_items(inv, "dst", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||||
|
if resp then
|
||||||
|
return resp
|
||||||
|
else
|
||||||
|
return "unsupported"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_node_load = function(pos)
|
||||||
|
CRD(pos).State:on_node_load(pos)
|
||||||
|
end,
|
||||||
|
on_node_repair = function(pos)
|
||||||
|
return CRD(pos).State:on_node_repair(pos)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||||
|
techage.register_consumer("drillbox", I("Oil Drill Box"), tiles, {
|
||||||
|
drawtype = "normal",
|
||||||
|
cycle_time = CYCLE_TIME,
|
||||||
|
standby_ticks = STANDBY_TICKS,
|
||||||
|
has_item_meter = true,
|
||||||
|
aging_factor = 10,
|
||||||
|
formspec = formspec,
|
||||||
|
tubing = tubing,
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
inv:set_size("src", 1)
|
||||||
|
inv:set_size("dst", 1)
|
||||||
|
local info = techage.explore.get_oil_info(pos)
|
||||||
|
M(pos):set_int("depth", info.depth)
|
||||||
|
M(pos):set_int("amount", info.amount)
|
||||||
|
M(pos):set_string("oil_found", "false")
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
if oldmetadata.fields.oil_found == "true" then
|
||||||
|
minetest.set_node(pos, {name = "techage:oil_source"})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
can_dig = can_dig,
|
||||||
|
node_timer = keep_running,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
on_rightclick = on_rightclick,
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||||
|
groups = {choppy=2, cracky=2, crumbly=2},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
num_items = {0,1,1,1},
|
||||||
|
power_consumption = {0,10,16,24},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = node_name_ta3,
|
||||||
|
recipe = {
|
||||||
|
{"default:steel_ingot", "default:diamond", "default:steel_ingot"},
|
||||||
|
{"techage:tubeS", "basic_materials:gear_steel", "techage:tubeS"},
|
||||||
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.register_help_page(I("Oil Drill Box"),
|
||||||
|
I([[Used to drill for oil,
|
||||||
|
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"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if mem.techage_state == techage.RUNNING then
|
||||||
|
play_sound(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
@ -8,9 +8,9 @@ local MP = minetest.get_modpath("techage")
|
|||||||
local I,IS = dofile(MP.."/intllib.lua")
|
local I,IS = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
|
||||||
local PROBABILITY = 10
|
local PROBABILITY = 100
|
||||||
local OIL_MIN = 500
|
local OIL_MIN = 1000
|
||||||
local OIL_MAX = 10000
|
local OIL_MAX = 20000
|
||||||
local DEPTH_MIN = 8
|
local DEPTH_MIN = 8
|
||||||
local DEPTH_MAX = (16 * 25) + 8
|
local DEPTH_MAX = (16 * 25) + 8
|
||||||
local DEPTH_STEP = 96
|
local DEPTH_STEP = 96
|
||||||
@ -42,8 +42,8 @@ end
|
|||||||
|
|
||||||
local function gen_oil_slice(pos1, posc, y, radius, data, id)
|
local function gen_oil_slice(pos1, posc, y, radius, data, id)
|
||||||
local y_offs = (y - pos1.y) * 16
|
local y_offs = (y - pos1.y) * 16
|
||||||
for x = posc.x - radius, posc.x + radius do
|
for x = posc.x - radius + 2, posc.x + radius + 2 do
|
||||||
for z = posc.z - radius, posc.z + radius do
|
for z = posc.z - radius + 1, posc.z + radius + 1 do
|
||||||
local idx = x - pos1.x + y_offs + (z - pos1.z) * 16 * 16
|
local idx = x - pos1.x + y_offs + (z - pos1.z) * 16 * 16
|
||||||
data[idx] = id
|
data[idx] = id
|
||||||
end
|
end
|
||||||
@ -58,7 +58,6 @@ local function gen_oil_bubble(pos1, posC, amount, data)
|
|||||||
local sum = 0
|
local sum = 0
|
||||||
for y = posC.y - radius, posC.y + radius do
|
for y = posC.y - radius, posC.y + radius do
|
||||||
sum = sum + gen_oil_slice(pos1, posC, y, radius + 1, data, id)
|
sum = sum + gen_oil_slice(pos1, posC, y, radius + 1, data, id)
|
||||||
print(y, sum, amount)
|
|
||||||
if sum >= amount then break end
|
if sum >= amount then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -123,7 +122,6 @@ local function explore_area(pos, pos1, pos2, posC, depth, amount, player_name)
|
|||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
vm:update_map()
|
vm:update_map()
|
||||||
print("explore_area", S(pos1), S(pos2))
|
|
||||||
M(pos):set_int("oil_amount", amount)
|
M(pos):set_int("oil_amount", amount)
|
||||||
M(pos):set_int("depth", depth)
|
M(pos):set_int("depth", depth)
|
||||||
set_oil_amount(posC, amount)
|
set_oil_amount(posC, amount)
|
||||||
@ -153,7 +151,6 @@ local function emerge_area(pos, node, player_name)
|
|||||||
|
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
if get_oil_amount(posC) == 0 then -- not explored so far?
|
if get_oil_amount(posC) == 0 then -- not explored so far?
|
||||||
print("emerge_area", S(pos1), S(pos2), S(posC))
|
|
||||||
minetest.emerge_area(pos1, pos2)
|
minetest.emerge_area(pos1, pos2)
|
||||||
minetest.after(2, explore_area, pos, pos1, pos2, posC, depth, amount, player_name)
|
minetest.after(2, explore_area, pos, pos1, pos2, posC, depth, amount, player_name)
|
||||||
else
|
else
|
||||||
@ -341,3 +338,17 @@ To go deeper, you can click on the block several times.
|
|||||||
When oil is found, the position for the Oil Tower is highlighted.
|
When oil is found, the position for the Oil Tower is highlighted.
|
||||||
Hint: Mark and protect the position for later use.]]),
|
Hint: Mark and protect the position for later use.]]),
|
||||||
"techage:oilexplorer")
|
"techage:oilexplorer")
|
||||||
|
|
||||||
|
techage.explore = {}
|
||||||
|
|
||||||
|
function techage.explore.get_oil_info(pos)
|
||||||
|
local amount = 0
|
||||||
|
local depth = DEPTH_MIN
|
||||||
|
while amount == 0 and depth < DEPTH_MAX do
|
||||||
|
depth = depth + DEPTH_STEP
|
||||||
|
local posC = {x = center(pos.x), y = center(-depth), z = center(pos.z)}
|
||||||
|
amount = oil_amount(posC)
|
||||||
|
end
|
||||||
|
return {depth = center(depth) - 2 + pos.y, amount = amount}
|
||||||
|
end
|
||||||
|
|
||||||
|
31
oil/oilpump.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
local function formspec(self, pos, mem)
|
||||||
|
if not mem.tower_built then
|
||||||
|
return formspec0
|
||||||
|
end
|
||||||
|
local icon = "techage_oil_inv"
|
||||||
|
local depth = "1/480"
|
||||||
|
return "size[8,8]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"list[context;src;1,1;1,1;]"..
|
||||||
|
"label[1.3,0.5;IN]"..
|
||||||
|
"item_image[1,1;1,1;techage:oil_drillbit]"..
|
||||||
|
"label[1,2;"..I("Drill Bit").."]"..
|
||||||
|
"label[0.5,3;"..I("Depth")..": "..depth.."]"..
|
||||||
|
"image[3.5,0;1,1;"..techage.get_power_image(pos, mem).."]"..
|
||||||
|
"image[3.5,1;1,1;techage_form_arrow.png]"..
|
||||||
|
"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;]"..
|
||||||
|
"label[6.2,2;"..I("Oil").."]"..
|
||||||
|
"label[5.5,3;"..I("Extract")..": "..depth.."]"..
|
||||||
|
"item_image[6,1;1,1;techage:oil_source]"..
|
||||||
|
"button_exit[0,3.9;3,1;destroy;"..I("Destroy Tower").."]"..
|
||||||
|
"list[current_player;main;0,4;8,4;]"..
|
||||||
|
"listring[context;dst]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;src]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 4)
|
||||||
|
end
|
283
oil/tower.lua
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA3 Oil Tower
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
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
|
||||||
|
|
||||||
|
-- Load support for intllib.
|
||||||
|
local MP = minetest.get_modpath("techage")
|
||||||
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("techage:oiltower1", {
|
||||||
|
description = I("TA3 Oil Tower"),
|
||||||
|
tiles = {
|
||||||
|
"techage_oil_tower1.png",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, -7/16, 8/16, 8/16},
|
||||||
|
{ 7/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||||
|
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
|
||||||
|
{-8/16, 7/16, -8/16, 8/16, 8/16, 8/16},
|
||||||
|
{-8/16, -8/16, -8/16, 8/16, 8/16, -7/16},
|
||||||
|
{-8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oiltower2", {
|
||||||
|
description = I("TA3 Oil Tower"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower2.png^[transformFX",
|
||||||
|
"techage_oil_tower2.png",
|
||||||
|
"techage_oil_tower2.png",
|
||||||
|
"techage_oil_tower2.png^[transformFX",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, -7/16, 8/16, 4/16},
|
||||||
|
{ 3/16, -8/16, -8/16, 4/16, 8/16, 4/16},
|
||||||
|
{-8/16, -8/16, -8/16, 4/16, -7/16, 4/16},
|
||||||
|
{-8/16, 7/16, -8/16, 4/16, 8/16, 4/16},
|
||||||
|
{-8/16, -8/16, -8/16, 4/16, 8/16, -7/16},
|
||||||
|
{-8/16, -8/16, 3/16, 4/16, 8/16, 4/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oiltower3", {
|
||||||
|
description = I("TA3 Oil Tower"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower3.png^[transformFX",
|
||||||
|
"techage_oil_tower3.png",
|
||||||
|
"techage_oil_tower3.png",
|
||||||
|
"techage_oil_tower3.png^[transformFX",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, -7/16, 8/16, 0/16},
|
||||||
|
{-1/16, -8/16, -8/16, 0/16, 8/16, 0/16},
|
||||||
|
{-8/16, -8/16, -8/16, 0/16, -7/16, 0/16},
|
||||||
|
{-8/16, 7/16, -8/16, 0/16, 8/16, 0/16},
|
||||||
|
{-8/16, -8/16, -8/16, 0/16, 8/16, -7/16},
|
||||||
|
{-8/16, -8/16, -1/16, 0/16, 8/16, 0/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oiltower4", {
|
||||||
|
description = I("TA3 Oil Tower"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower_top.png^[transformR180",
|
||||||
|
"techage_oil_tower4.png^[transformFX",
|
||||||
|
"techage_oil_tower4.png",
|
||||||
|
"techage_oil_tower4.png",
|
||||||
|
"techage_oil_tower4.png^[transformFX",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, -7/16, 8/16, -4/16},
|
||||||
|
{-5/16, -8/16, -8/16, -4/16, 8/16, -4/16},
|
||||||
|
{-8/16, -8/16, -8/16, -4/16, -7/16, -4/16},
|
||||||
|
{-8/16, 7/16, -8/16, -4/16, 8/16, -4/16},
|
||||||
|
{-8/16, -8/16, -8/16, -4/16, 8/16, -7/16},
|
||||||
|
{-8/16, -8/16, -5/16, -4/16, 8/16, -4/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oiltower5", {
|
||||||
|
description = I("TA4 Oil Tower"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_oil_tower1.png",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oil_drillbit", {
|
||||||
|
description = I("TA3 Drill Bit"),
|
||||||
|
drawtype = "plantlike",
|
||||||
|
tiles = {"techage_oil_drillbit.png"},
|
||||||
|
inventory_image = "techage_oil_drillbit_inv.png",
|
||||||
|
wield_image = "techage_oil_drillbit_inv.png",
|
||||||
|
visual_scale = 1,
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {cracky = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:oil_drillbit2", {
|
||||||
|
description = I("TA3 Drill Bit"),
|
||||||
|
drawtype = "plantlike",
|
||||||
|
tiles = {"techage_oil_drillbit.png"},
|
||||||
|
inventory_image = "techage_oil_drillbit_inv.png",
|
||||||
|
wield_image = "techage_oil_drillbit_inv.png",
|
||||||
|
visual_scale = 1,
|
||||||
|
paramtype = "light",
|
||||||
|
drop = "",
|
||||||
|
diggable = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
local AssemblyPlan = {
|
||||||
|
-- y-offs, path, facedir-offs, name
|
||||||
|
|
||||||
|
-- level 0
|
||||||
|
{ 0, {0,1}, 0, "techage:oiltower1"},
|
||||||
|
{ 0, {0,3}, 0, "techage:oiltower1"},
|
||||||
|
{ 0, {2,1}, 0, "techage:oiltower1"},
|
||||||
|
{ 0, {2,3}, 0, "techage:oiltower1"},
|
||||||
|
-- level 1
|
||||||
|
{ 1, {0,1}, 0, "techage:oiltower1"},
|
||||||
|
{ 1, {0,3}, 0, "techage:oiltower1"},
|
||||||
|
{ 1, {2,1}, 0, "techage:oiltower1"},
|
||||||
|
{ 1, {2,3}, 0, "techage:oiltower1"},
|
||||||
|
{ 1, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 1, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 1, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 1, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 2
|
||||||
|
{ 2, {0,1}, 0, "techage:oiltower2"},
|
||||||
|
{ 2, {0,3}, 3, "techage:oiltower2"},
|
||||||
|
{ 2, {2,1}, 1, "techage:oiltower2"},
|
||||||
|
{ 2, {2,3}, 2, "techage:oiltower2"},
|
||||||
|
{ 2, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 2, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 2, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 2, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 3
|
||||||
|
{ 3, {0,1}, 0, "techage:oiltower3"},
|
||||||
|
{ 3, {0,3}, 3, "techage:oiltower3"},
|
||||||
|
{ 3, {2,1}, 1, "techage:oiltower3"},
|
||||||
|
{ 3, {2,3}, 2, "techage:oiltower3"},
|
||||||
|
{ 3, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 3, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 3, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 3, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 4
|
||||||
|
{ 4, {0,1}, 0, "techage:oiltower4"},
|
||||||
|
{ 4, {0,3}, 3, "techage:oiltower4"},
|
||||||
|
{ 4, {2,1}, 1, "techage:oiltower4"},
|
||||||
|
{ 4, {2,3}, 2, "techage:oiltower4"},
|
||||||
|
{ 4, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 4, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 4, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 4, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 5
|
||||||
|
{ 5, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 5, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 5, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 5, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 6
|
||||||
|
{ 6, {0}, 2, "techage:oiltower5"},
|
||||||
|
{ 6, {1}, 3, "techage:oiltower5"},
|
||||||
|
{ 6, {2}, 0, "techage:oiltower5"},
|
||||||
|
{ 6, {3}, 1, "techage:oiltower5"},
|
||||||
|
-- level 7
|
||||||
|
{ 7, {}, 0, "techage:oiltower1"},
|
||||||
|
-- drill bits
|
||||||
|
{ 1, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
{ 2, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
{ 3, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
{ 4, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
{ 5, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
{ 6, {}, 0, "techage:oil_drillbit2"},
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:oil_drillbit 12",
|
||||||
|
recipe = {
|
||||||
|
{"", "default:steel_ingot", "default:obsidian_shard"},
|
||||||
|
{"", "default:steel_ingot", ""},
|
||||||
|
{"default:obsidian_shard", "default:steel_ingot", ""},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.oiltower = {}
|
||||||
|
|
||||||
|
-- Two important flags:
|
||||||
|
-- 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)
|
||||||
|
techage.assemble.build(pos, AssemblyPlan, player_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.oiltower.remove(pos, player_name)
|
||||||
|
techage.assemble.remove(pos, AssemblyPlan, player_name)
|
||||||
|
end
|
||||||
|
|
@ -184,7 +184,6 @@ function techage.power.register_node(names, pwr_def)
|
|||||||
if ndef then
|
if ndef then
|
||||||
minetest.override_item(name, {
|
minetest.override_item(name, {
|
||||||
power = {
|
power = {
|
||||||
turn_on = pwr_def.turn_on, -- line-like networks
|
|
||||||
on_power_pass1 = pwr_def.on_power_pass1,
|
on_power_pass1 = pwr_def.on_power_pass1,
|
||||||
on_power_pass2 = pwr_def.on_power_pass2,
|
on_power_pass2 = pwr_def.on_power_pass2,
|
||||||
on_power_pass3 = pwr_def.on_power_pass3,
|
on_power_pass3 = pwr_def.on_power_pass3,
|
||||||
@ -262,24 +261,3 @@ function techage.power.side_to_outdir(pos, side)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
return side_to_dir(node.param2, side)
|
return side_to_dir(node.param2, side)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Simplified version of power distribution for line-like networks
|
|
||||||
-- like the for the steam engine pipe.
|
|
||||||
-- Function uses the node "turn_on" callback
|
|
||||||
-- Returns true, if node could be started/stopped.
|
|
||||||
function techage.power.start_line_node(pos, out_dir, node_name, on)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
local conn = mem.connections and mem.connections[out_dir]
|
|
||||||
if conn and conn.in_dir and conn.pos then
|
|
||||||
local node = minetest.get_node(conn.pos)
|
|
||||||
if node.name == node_name then
|
|
||||||
local pwr = PWR(conn.pos)
|
|
||||||
if pwr and pwr.turn_on then
|
|
||||||
local mem = tubelib2.get_mem(conn.pos)
|
|
||||||
return pwr.turn_on(conn.pos, mem, conn.in_dir, on)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
BIN
sounds/techage_oildrill.ogg
Normal file
@ -65,13 +65,11 @@ local function can_start(pos, mem, state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function start_node(pos, mem, state)
|
local function start_node(pos, mem, state)
|
||||||
local out_dir = techage.side_to_outdir("U")
|
mem.running = techage.transfer(pos, 6, "start", nil, Pipe, {"techage:cylinder"})
|
||||||
mem.running = techage.power.start_line_node(pos, out_dir, "techage:cylinder", true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stop_node(pos, mem, state)
|
local function stop_node(pos, mem, state)
|
||||||
local out_dir = techage.side_to_outdir("U")
|
techage.transfer(pos, 6, "stop", nil, Pipe, {"techage:cylinder_on"})
|
||||||
techage.power.start_line_node(pos, out_dir, "techage:cylinder_on", false)
|
|
||||||
mem.running = false
|
mem.running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -271,14 +269,6 @@ minetest.register_node("techage:boiler2", {
|
|||||||
minetest.after(0.5, move_to_water, pos)
|
minetest.after(0.5, move_to_water, pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
power_signal_heat = function(pos)
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
mem.fire_trigger = true
|
|
||||||
if not minetest.get_node_timer(pos):is_started() then
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
drop = "",
|
drop = "",
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -291,6 +281,17 @@ techage.power.register_node({"techage:boiler2"}, {
|
|||||||
power_network = Pipe,
|
power_network = Pipe,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:boiler2"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
if topic == "trigger" then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.fire_trigger = true
|
||||||
|
if not minetest.get_node_timer(pos):is_started() then
|
||||||
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:boiler1",
|
output = "techage:boiler1",
|
||||||
|
@ -32,11 +32,6 @@ local function swap_node(pos, name)
|
|||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function turn_on(pos, mem, in_dir, on)
|
|
||||||
mem.running = on
|
|
||||||
return on
|
|
||||||
end
|
|
||||||
|
|
||||||
-- called from flywheel
|
-- called from flywheel
|
||||||
local function start_cylinder(pos, on)
|
local function start_cylinder(pos, on)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
@ -51,6 +46,11 @@ local function start_cylinder(pos, on)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- called with any pipe change
|
||||||
|
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.running = false
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("techage:cylinder", {
|
minetest.register_node("techage:cylinder", {
|
||||||
description = I("TA2 Cylinder"),
|
description = I("TA2 Cylinder"),
|
||||||
@ -105,6 +105,7 @@ minetest.register_node("techage:cylinder_on", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
start_cylinder = start_cylinder,
|
start_cylinder = start_cylinder,
|
||||||
|
after_tube_update = after_tube_update,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
@ -115,11 +116,24 @@ minetest.register_node("techage:cylinder_on", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
techage.power.register_node({"techage:cylinder", "techage:cylinder_on"}, {
|
techage.power.register_node({"techage:cylinder", "techage:cylinder_on"}, {
|
||||||
turn_on = turn_on,
|
|
||||||
conn_sides = {"L"},
|
conn_sides = {"L"},
|
||||||
power_network = Pipe,
|
power_network = Pipe,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- used by firebox
|
||||||
|
techage.register_node({"techage:cylinder", "techage:cylinder_on"}, {
|
||||||
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if topic == "start" then
|
||||||
|
mem.running = true
|
||||||
|
return true
|
||||||
|
elseif topic == "stop" then
|
||||||
|
mem.running = false
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:cylinder",
|
output = "techage:cylinder",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -133,4 +147,4 @@ techage.register_help_page(I("TA2 Cylinder"),
|
|||||||
I([[Part of the steam engine.
|
I([[Part of the steam engine.
|
||||||
Has to be placed side by side
|
Has to be placed side by side
|
||||||
with the TA2 Flywheel.
|
with the TA2 Flywheel.
|
||||||
(see TA2 Steam Engine)]]), "techage:cylinder")
|
(see TA2 Steam Engine)]]), "techage:cylinder")
|
||||||
|
@ -25,14 +25,36 @@ local firebox = techage.firebox
|
|||||||
|
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
|
|
||||||
|
local function formspec(mem)
|
||||||
|
local fuel_percent = 0
|
||||||
|
if mem.running then
|
||||||
|
fuel_percent = ((mem.burn_cycles or 1) * 100) / (mem.burn_cycles_total or 1)
|
||||||
|
end
|
||||||
|
return "size[8,6]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"list[current_name;fuel;1,0.5;1,1;]"..
|
||||||
|
"image[3,0.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
|
fuel_percent..":default_furnace_fire_fg.png]"..
|
||||||
|
"button[5,0.5;1.8,1;update;"..I("Update").."]"..
|
||||||
|
"list[current_player;main;0,2;8,4;]"..
|
||||||
|
"listring[current_name;fuel]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 2)
|
||||||
|
end
|
||||||
|
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
if mem.running then
|
if mem.running then
|
||||||
local ndef = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}).name]
|
techage.transfer(
|
||||||
if ndef and ndef.power_signal_heat then
|
{x=pos.x, y=pos.y+2, z=pos.z},
|
||||||
ndef.power_signal_heat({x=pos.x, y=pos.y+2, z=pos.z})
|
nil, -- outdir
|
||||||
end
|
"trigger", -- topic
|
||||||
|
nil, -- payload
|
||||||
|
nil, -- network
|
||||||
|
{"techage:boiler2"} -- nodenames
|
||||||
|
)
|
||||||
mem.burn_cycles = (mem.burn_cycles or 0) - 1
|
mem.burn_cycles = (mem.burn_cycles or 0) - 1
|
||||||
if mem.burn_cycles <= 0 then
|
if mem.burn_cycles <= 0 then
|
||||||
local taken = firebox.get_fuel(pos)
|
local taken = firebox.get_fuel(pos)
|
||||||
@ -42,7 +64,7 @@ local function node_timer(pos, elapsed)
|
|||||||
else
|
else
|
||||||
mem.running = false
|
mem.running = false
|
||||||
firebox.swap_node(pos, "techage:firebox")
|
firebox.swap_node(pos, "techage:firebox")
|
||||||
M(pos):set_string("formspec", firebox.formspec(mem))
|
M(pos):set_string("formspec", formspec(mem))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -50,6 +72,22 @@ local function node_timer(pos, elapsed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if fields.update then
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(mem))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos, node, clicker)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(mem))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("techage:firebox", {
|
minetest.register_node("techage:firebox", {
|
||||||
description = I("TA2 Firebox"),
|
description = I("TA2 Firebox"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -71,15 +109,15 @@ minetest.register_node("techage:firebox", {
|
|||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local mem = tubelib2.init_mem(pos)
|
local mem = tubelib2.init_mem(pos)
|
||||||
mem.running = false
|
mem.running = false
|
||||||
mem.burn_cycles = 0
|
mem.burn_cycles = 0
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
meta:set_string("formspec", firebox.formspec(mem))
|
meta:set_string("formspec", formspec(mem))
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size('fuel', 1)
|
inv:set_size('fuel', 1)
|
||||||
end,
|
end,
|
||||||
@ -90,7 +128,7 @@ minetest.register_node("techage:firebox", {
|
|||||||
-- activate the formspec fire temporarily
|
-- activate the formspec fire temporarily
|
||||||
mem.burn_cycles = firebox.Burntime[stack:get_name()] / CYCLE_TIME
|
mem.burn_cycles = firebox.Burntime[stack:get_name()] / CYCLE_TIME
|
||||||
mem.burn_cycles_total = mem.burn_cycles
|
mem.burn_cycles_total = mem.burn_cycles
|
||||||
M(pos):set_string("formspec", firebox.formspec(mem))
|
M(pos):set_string("formspec", formspec(mem))
|
||||||
mem.burn_cycles = 0
|
mem.burn_cycles = 0
|
||||||
firebox.swap_node(pos, "techage:firebox_on")
|
firebox.swap_node(pos, "techage:firebox_on")
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
@ -129,8 +167,8 @@ minetest.register_node("techage:firebox_on", {
|
|||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -142,7 +180,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:firebox", {"techage:firebox_on"}, {
|
techage.register_node({"techage:firebox", "techage:firebox_on"}, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
BIN
textures/techage_appl_oildrill.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
textures/techage_oil_drill.png
Normal file
After Width: | Height: | Size: 946 B |
BIN
textures/techage_oil_drillbit.png
Normal file
After Width: | Height: | Size: 299 B |
BIN
textures/techage_oil_drillbit_inv.png
Normal file
After Width: | Height: | Size: 863 B |
BIN
textures/techage_oil_tower1.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
textures/techage_oil_tower2.png
Normal file
After Width: | Height: | Size: 769 B |
BIN
textures/techage_oil_tower3.png
Normal file
After Width: | Height: | Size: 550 B |
BIN
textures/techage_oil_tower4.png
Normal file
After Width: | Height: | Size: 485 B |
BIN
textures/techage_oil_tower_inv.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
textures/techage_oil_tower_top.png
Normal file
After Width: | Height: | Size: 596 B |