From eb3fe21f8aabc357b999004e8a739c8e9efe5571 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 9 Mar 2019 19:26:15 +0100 Subject: [PATCH] pusher, tubes, and legacy_nodes added --- basic_machines/legacy_nodes.lua | 56 ++++++ basic_machines/pusher.lua | 272 +++++++++++++++------------- basis/command.lua | 12 +- basis/node_states.lua | 84 +++------ basis/power.lua | 43 ++--- {basic_machines => basis}/tubes.lua | 24 +-- electric/test.lua | 1 + init.lua | 7 +- steam_engine/cylinder.lua | 2 - steam_engine/firebox.lua | 2 - steam_engine/flywheel.lua | 10 +- textures/techage_defect.png | Bin 0 -> 301 bytes textures/techage_flywheel4.png | Bin 8616 -> 8616 bytes textures/techage_frame_ta2_top.png | Bin 0 -> 1390 bytes textures/techage_frame_ta3_top.png | Bin 0 -> 985 bytes textures/techage_frame_ta4_top.png | Bin 0 -> 238 bytes textures/techage_pusher.png | Bin 0 -> 272 bytes textures/techage_tube_hole.png | Bin 0 -> 194 bytes textures/techage_tube_hole2.png | Bin 0 -> 278 bytes textures/techage_tube_knee.png | Bin 0 -> 373 bytes textures/techage_tube_knee2.png | Bin 0 -> 324 bytes textures/techage_tube_tube.png | Bin 0 -> 321 bytes 22 files changed, 279 insertions(+), 234 deletions(-) create mode 100644 basic_machines/legacy_nodes.lua rename {basic_machines => basis}/tubes.lua (87%) create mode 100644 textures/techage_defect.png create mode 100644 textures/techage_frame_ta2_top.png create mode 100644 textures/techage_frame_ta3_top.png create mode 100644 textures/techage_frame_ta4_top.png create mode 100644 textures/techage_pusher.png create mode 100644 textures/techage_tube_hole.png create mode 100644 textures/techage_tube_hole2.png create mode 100644 textures/techage_tube_knee.png create mode 100644 textures/techage_tube_knee2.png create mode 100644 textures/techage_tube_tube.png diff --git a/basic_machines/legacy_nodes.lua b/basic_machines/legacy_nodes.lua new file mode 100644 index 0000000..7281d9b --- /dev/null +++ b/basic_machines/legacy_nodes.lua @@ -0,0 +1,56 @@ +--[[ + + Tube Library + ============ + + Copyright (C) 2017 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + legacy_nodes.lua: + + Tubelib support for chests and furnace + +]]-- + +techage.register_node("default:chest", {"default:chest_open"}, { + on_pull_item = function(pos, in_dir, num) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.get_items(inv, "main", num) + end, + on_push_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_item(inv, "main", stack) + end, + on_unpull_item = function(pos, in_dir, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_item(inv, "main", stack) + end, +}) + +techage.register_node("default:furnace", {"default:furnace_active"}, { + on_pull_item = function(pos, in_dir, num) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.get_items(inv, "dst", num) + end, + on_push_item = function(pos, side, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + minetest.get_node_timer(pos):start(1.0) + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return techage.put_item(inv, "fuel", stack) + else + return techage.put_item(meta, "src", stack) + end + end, + on_unpull_item = function(pos, side, stack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return techage.put_item(meta, "dst", stack) + end, +}) diff --git a/basic_machines/pusher.lua b/basic_machines/pusher.lua index 62294d0..9a3e264 100644 --- a/basic_machines/pusher.lua +++ b/basic_machines/pusher.lua @@ -18,7 +18,6 @@ IN (L) -->| |X--> OUT (R) | PUSHER | + | |/ - +--------+ ]]-- @@ -27,8 +26,9 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local MEM = tubelib2.get_mem -local RND = function(meta) return RegNodeData[meta:get_int('ta_stage')]] end +-- Techage Related Data +local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end +local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end -- Load support for intllib. local MP = minetest.get_modpath("tubelib2") @@ -38,93 +38,110 @@ local STANDBY_TICKS = 10 local COUNTDOWN_TICKS = 10 local CYCLE_TIME = 2 -local RegNodeData = {} +local function pushing(pos, trd, meta, mem) + local pull_dir = meta:get_int("pull_dir") + local push_dir = meta:get_int("push_dir") + local items = techage.pull_items(pos, pull_dir, TRD(pos).num_items) + if items ~= nil then + if techage.push_items(pos, push_dir, items) == false then + -- place item back + techage.unpull_items(pos, pull_dir, items) + trd.State:blocked(pos, mem) + return + end + trd.State:keep_running(pos, mem, COUNTDOWN_TICKS) + return + end + trd.State:idle(pos, mem) +end -local function register_pusher(idx) - RegNodeData[idx] = {} - RegNodeData[idx].State = techage.NodeStates:new({ - node_name_passive= "techage:ta"..idx.."_pusher", - node_name_active = "techage:ta"..idx.."_pusher_active", - node_name_defect = "techage:ta"..idx.."_pusher_defect", - infotext_name = "TA"..idx.." Pusher", +local function keep_running(pos, elapsed) + local mem = tubelib2.get_mem(pos) + local trd = TRD(pos) + pushing(pos, trd, M(pos), mem) + return trd.State:is_active(mem) +end + +local function on_rightclick(pos, node, clicker) + local mem = tubelib2.get_mem(pos) + if not minetest.is_protected(pos, clicker:get_player_name()) then + if TRD(pos).State:is_active(mem) then + TRD(pos).State:stop(pos, mem) + else + TRD(pos).State:start(pos, mem) + end + end +end + +local function after_dig_node(pos, oldnode, oldmetadata, digger) + techage.remove_node(pos) + TRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger) +end + +local function register_pusher(stage, num_items) + local State = techage.NodeStates:new({ + node_name_passive= "techage:ta"..stage.."_pusher", + node_name_active = "techage:ta"..stage.."_pusher_active", + node_name_defect = "techage:ta"..stage.."_pusher_defect", + infotext_name = "TA"..stage..I(" Pusher"), cycle_time = CYCLE_TIME, standby_ticks = STANDBY_TICKS, has_item_meter = true, aging_factor = 10, }) - local function pushing(pos, rnd, mem) - local items = techage.pull_items(pos, mem.pull_dir, rnd.num_items) - if items ~= nil then - if techage.push_items(pos, mem.push_dir, items) == false then - -- place item back - techage.unpull_items(pos, mem.pull_dir, items) - rnd.State:blocked(pos, mem) - return - end - rnd.State:keep_running(pos, mem, COUNTDOWN_TICKS) - return - end - rnd.State:idle(pos, mem) - end - - local function keep_running(pos, elapsed) - local meta = M(pos) - pushing(pos, meta) - return State:is_active(meta) - end - - minetest.register_node("tubelib:pusher", { - description = "Tubelib Pusher", + minetest.register_node("techage:ta"..stage.."_pusher", { + description = "TA"..stage..I(" Pusher"), tiles = { -- up, down, right, left, back, front - 'tubelib_pusher1.png', - 'tubelib_pusher1.png', - 'tubelib_outp.png', - 'tubelib_inp.png', - "tubelib_pusher1.png^[transformR180]", - "tubelib_pusher1.png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage.."_top.png^techage_appl_arrow.png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_outp.png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_inp.png", + "techage_pusher.png^[transformR180]^techage_frame_ta"..stage..".png", + "techage_pusher.png^techage_frame_ta"..stage..".png", }, - after_place_node = function(pos, placer) - - local meta = minetest.get_meta(pos) - meta:set_string("player_name", placer:get_player_name()) - local number = tubelib.add_node(pos, "tubelib:pusher") -- <<=== tubelib - - this:node_init(pos, number) - end, - - on_rightclick = function(pos, node, clicker) - if not minetest.is_protected(pos, clicker:get_player_name()) then - State:start(pos, M(pos)) - end - end, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - tubelib.remove_node(pos) -- <<=== tubelib - State:after_dig_node(pos, oldnode, oldmetadata, digger) - end, + techage = { + State = State, + num_items = num_items, + }, + after_place_node = function(pos, placer) + local mem = tubelib2.init_mem(pos) + local meta = M(pos) + local node = minetest.get_node(pos) + meta:set_int("pull_dir", techage.side_to_outdir("L", node.param2)) + meta:set_int("push_dir", techage.side_to_outdir("R", node.param2)) + local number = "-" + if stage > 2 then + number = techage.add_node(pos, "techage:ta"..stage.."_pusher") + end + TRD(pos).State:node_init(pos, mem, number) + end, + + on_rightclick = on_rightclick, + after_dig_node = after_dig_node, on_timer = keep_running, on_rotate = screwdriver.disallow, drop = "", - paramtype = "light", - sunlight_propagates = true, paramtype2 = "facedir", groups = {choppy=2, cracky=2, crumbly=2}, is_ground_content = false, sounds = default.node_sound_wood_defaults(), }) - - minetest.register_node("tubelib:pusher_active", { - description = "Tubelib Pusher", + minetest.register_node("techage:ta"..stage.."_pusher_active", { + description = "TA"..stage..I(" Pusher"), tiles = { -- up, down, right, left, back, front + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage.."_top.png^techage_appl_arrow.png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_outp.png", + "techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_inp.png", { - image = "tubelib_pusher.png", + image = "techage_pusher14.png^[transformR180]^techage_frame14_ta"..stage..".png", backface_culling = false, animation = { type = "vertical_frames", @@ -134,29 +151,7 @@ local function register_pusher(idx) }, }, { - image = "tubelib_pusher.png", - backface_culling = false, - animation = { - type = "vertical_frames", - aspect_w = 32, - aspect_h = 32, - length = 2.0, - }, - }, - 'tubelib_outp.png', - 'tubelib_inp.png', - { - image = "tubelib_pusher.png^[transformR180]", - backface_culling = false, - animation = { - type = "vertical_frames", - aspect_w = 32, - aspect_h = 32, - length = 2.0, - }, - }, - { - image = "tubelib_pusher.png", + image = "techage_pusher14.png^techage_frame14_ta"..stage..".png", backface_culling = false, animation = { type = "vertical_frames", @@ -167,25 +162,26 @@ local function register_pusher(idx) }, }, - on_rightclick = function(pos, node, clicker) - if not minetest.is_protected(pos, clicker:get_player_name()) then - State:stop(pos, M(pos)) - end - end, + techage = { + State = State, + num_items = num_items, + }, + on_rightclick = on_rightclick, + after_dig_node = after_dig_node, on_timer = keep_running, on_rotate = screwdriver.disallow, + on_timer = keep_running, - paramtype = "light", - sunlight_propagates = true, paramtype2 = "facedir", + diggable = false, groups = {crumbly=0, not_in_creative_inventory=1}, is_ground_content = false, sounds = default.node_sound_wood_defaults(), }) - minetest.register_node("tubelib:pusher_defect", { - description = "Tubelib Pusher", + minetest.register_node("techage:ta"..stage.."_pusher_defect", { + description = "TA"..stage.." Pusher", tiles = { -- up, down, right, left, back, front 'tubelib_pusher1.png', @@ -196,23 +192,26 @@ local function register_pusher(idx) "tubelib_pusher1.png^tubelib_defect.png", }, + techage = { + State = State, + }, + after_place_node = function(pos, placer) - local meta = minetest.get_meta(pos) - meta:set_string("player_name", placer:get_player_name()) - local number = tubelib.add_node(pos, "tubelib:pusher") -- <<=== tubelib - State:node_init(pos, number) - State:defect(pos, meta) + local mem = tubelib2.get_init(pos) + local number = "-" + if stage > 2 then + number = techage.add_node(pos, "techage:ta"..stage.."_pusher") + end + TRD(pos).State:node_init(pos, mem, number) + TRD(pos).State:defect(pos, mem) end, after_dig_node = function(pos) - tubelib.remove_node(pos) -- <<=== tubelib + techage.remove_node(pos) end, - on_timer = keep_running, on_rotate = screwdriver.disallow, - paramtype = "light", - sunlight_propagates = true, paramtype2 = "facedir", groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, is_ground_content = false, @@ -229,29 +228,42 @@ local function register_pusher(idx) }, }) - --------------------------------------------------------------- tubelib - tubelib.register_node("tubelib:pusher", - {"tubelib:pusher_active", "tubelib:pusher_defect"}, { - on_pull_item = nil, -- pusher has no inventory - on_push_item = nil, -- pusher has no inventory - on_unpull_item = nil, -- pusher has no inventory - is_pusher = true, -- is a pulling/pushing node - - on_recv_message = function(pos, topic, payload) - local resp = State:on_receive_message(pos, topic, payload) - if resp then - return resp - else - return "unsupported" - end - end, - on_node_load = function(pos) - State:on_node_load(pos) - end, - on_node_repair = function(pos) - return State:on_node_repair(pos) - end, - }) - --------------------------------------------------------------- tubelib + if stage == 2 then + techage.register_node("techage:ta"..stage.."_pusher", + {"techage:ta"..stage.."_pusher_active", "techage:ta"..stage.."_pusher_defect"}, { + is_pusher = true, -- is a pulling/pushing node + + on_node_load = function(pos) + TRD(pos).State:on_node_load(pos) + end, + on_node_repair = function(pos) + return TRD(pos).State:on_node_repair(pos) + end, + }) + else + techage.register_node("techage:ta"..stage.."_pusher", + {"techage:ta"..stage.."_pusher_active", "techage:ta"..stage.."_pusher_defect"}, { + is_pusher = true, -- is a pulling/pushing node + + on_recv_message = function(pos, topic, payload) + local resp = TRD(pos).State:on_receive_message(pos, topic, payload) + if resp then + return resp + else + return "unsupported" + end + end, + on_node_load = function(pos) + TRD(pos).State:on_node_load(pos) + end, + on_node_repair = function(pos) + return TRD(pos).State:on_node_repair(pos) + end, + }) + end end +register_pusher(2, 2) +register_pusher(3, 6) +register_pusher(4, 18) + diff --git a/basis/command.lua b/basis/command.lua index f01b1d9..3f388d5 100644 --- a/basis/command.lua +++ b/basis/command.lua @@ -125,6 +125,8 @@ local function side_to_dir(side, param2) return dir end +techage.side_to_outdir = side_to_dir + local function get_dest_node(pos, out_dir) local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir) local _,node = Tube:get_node(spos) @@ -237,9 +239,9 @@ end -- Param add_names: Alternativ node names if needded, e.g.: "techage:pusher_active" -- Param node_definition: A table according to: -- { --- on_pull_item = func(pos, side, player_name, num), --- on_push_item = func(pos, side, item, player_name), --- on_unpull_item = func(pos, side, item, player_name), +-- on_pull_item = func(pos, in_dir, num), +-- on_push_item = func(pos, in_dir, item), +-- on_unpull_item = func(pos, in_dir, item), -- on_recv_message = func(pos, topic, payload), -- on_node_load = func(pos), -- LBM function -- on_node_repair = func(pos), -- repair defect (feature!) nodes @@ -333,11 +335,11 @@ function techage.push_items(pos, out_dir, stack) return false end -function techage.unpull_items(pos, out_dir, items) +function techage.unpull_items(pos, out_dir, stack) local npos, in_dir, name = get_dest_node(pos, out_dir) if npos == nil then return end if NodeDef[name] and NodeDef[name].on_unpull_item then - return NodeDef[name].on_unpull_item(npos, in_dir, items) + return NodeDef[name].on_unpull_item(npos, in_dir, stack) end return false end diff --git a/basis/node_states.lua b/basis/node_states.lua index e897e33..1ade4d3 100644 --- a/basis/node_states.lua +++ b/basis/node_states.lua @@ -41,8 +41,7 @@ Node states: | | | BLOCKED | | | +---------+ +----------+ +---------+ -Node metadata: - "techage_number" - string with tubelib number, like "123" +Node mem data: "techage_state" - node state, like "RUNNING" "techage_item_meter" - node item/runtime counter "techage_countdown" - countdown to stadby mode @@ -146,7 +145,7 @@ end function NodeStates:node_init(pos, mem, number) mem.techage_state = STOPPED - mem.techage_number = number + M(pos):set_string("node_number", number) if self.infotext_name then M(pos):set_string("infotext", self.infotext_name.." "..number..": stopped") end @@ -172,7 +171,7 @@ function NodeStates:stop(pos, mem) swap_node(pos, self.node_name_passive) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": stopped") end if self.formspec_func then @@ -206,7 +205,7 @@ function NodeStates:start(pos, mem, called_from_on_timer) swap_node(pos, self.node_name_active) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": running") end if self.formspec_func then @@ -229,7 +228,7 @@ function NodeStates:standby(pos, mem) swap_node(pos, self.node_name_passive) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": standby") end if self.formspec_func then @@ -251,7 +250,7 @@ function NodeStates:blocked(pos, mem) swap_node(pos, self.node_name_passive) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": blocked") end if self.formspec_func then @@ -270,7 +269,7 @@ function NodeStates:fault(pos, mem) swap_node(pos, self.node_name_passive) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": fault") end if self.formspec_func then @@ -288,7 +287,7 @@ function NodeStates:defect(pos, mem) swap_node(pos, self.node_name_defect) end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": defect") end if self.formspec_func then @@ -389,37 +388,15 @@ function NodeStates:on_receive_message(pos, topic, payload) end end --- repair corrupt node data and/or migrate node to state2 +-- repair corrupt node data function NodeStates:on_node_load(pos, not_start_timer) local mem = tubelib2.get_mem(pos) - -- legacy node number/state/counter? - local number = mem.number - if number ~= "" and number ~= nil then - mem.techage_number = number - mem.techage_state = techage.state(mem.running) - if self.has_item_meter then - mem.techage_item_meter = mem.counter - end - if self.aging_level1 then - mem.techage_aging = 0 - end - mem.number = nil - mem.running = 0 - mem.counter = 0 - end - - -- node number corrupt? - number = mem.techage_number - if number == "" then - number = techage.get_new_number(pos, self.node_name_passive) - mem.techage_number = number - else - local info = techage.get_node_info(number) - if not info or info.pos ~= pos then - number = techage.get_new_number(pos, self.node_name_passive) - mem.techage_number = number - end + -- Meta data corrupt? + local number = M(pos):get_string("node_number") + if number == "" then + swap_node(pos, "techage:defect_dummy") + return end -- state corrupt? @@ -455,7 +432,7 @@ function NodeStates:on_node_repair(pos) mem.techage_aging = 0 end if self.infotext_name then - local number = mem.techage_number + local number = M(pos):get_string("node_number") M(pos):set_string("infotext", self.infotext_name.." "..number..": stopped") end if self.formspec_func then @@ -483,20 +460,17 @@ function NodeStates:after_dig_node(pos, oldnode, oldmetadata, digger) end end --- Return "full", "loaded", or "empty" depending --- on the number of fuel stack items. --- Function only works on fuel inventories with one stacks/99 items -function techage.fuelstate(meta, listname, item) - if meta == nil or meta.get_inventory == nil then return nil end - local inv = meta:get_inventory() - if inv:is_empty(listname) then - return "empty" - end - local list = inv:get_list(listname) - if #list == 1 and list[1]:get_count() == 99 then - return "full" - else - return "loaded" - end -end - +minetest.register_node("techage:defect_dummy", { + description = "Corrupted Node (to be replaced)", + tiles = { + "techage_filling_ta2.png^techage_frame_ta2.png", + "techage_filling_ta2.png^techage_frame_ta2.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_defect.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_defect.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_defect.png", + "techage_filling_ta2.png^techage_frame_ta2.png^techage_defect.png", + }, + drop = "", + groups = {cracky=2, crumbly=2, choppy=2, not_in_creative_inventory=1}, + is_ground_content = false, +}) diff --git a/basis/power.lua b/basis/power.lua index 24af486..850562d 100644 --- a/basis/power.lua +++ b/basis/power.lua @@ -16,8 +16,9 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local TP = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end -local TN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end +-- Techage Related Data +local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end +local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end -- Used to determine the already passed nodes while power distribution local Route = {} @@ -52,7 +53,7 @@ end local function get_power_dir(pos) local key = minetest.hash_node_position(pos) if not PowerInDir[key] then - PowerInDir[key] = tubelib2.Turn180Deg[side_to_dir(pos, TP(pos).power_side or 'L')] + PowerInDir[key] = tubelib2.Turn180Deg[side_to_dir(pos, TRD(pos).power_side or 'L')] end return PowerInDir[key] end @@ -61,9 +62,9 @@ local power_consumption = nil local function call_read_power_consumption(pos, in_dir) if not pos_already_reached(pos) then - local this = TP(pos) - if this and this.read_power_consumption then - return this.read_power_consumption(pos, in_dir) + local trd = TRD(pos) + if trd and trd.read_power_consumption then + return trd.read_power_consumption(pos, in_dir) else return power_consumption(pos, in_dir) end @@ -100,14 +101,14 @@ local turn_on = nil local function call_turn_on(pos, in_dir, sum) if not pos_already_reached(pos) then - local this = TP(pos) - if this and (not this.valid_power_dir or this.valid_power_dir(pos, get_power_dir(pos), in_dir)) then - if this.turn_on then - this.turn_on(pos, in_dir, sum) + local trd = TRD(pos) + if trd and (not trd.valid_power_dir or trd.valid_power_dir(pos, get_power_dir(pos), in_dir)) then + if trd.turn_on then + trd.turn_on(pos, in_dir, sum) end end - if this and this.animated_power_network then - turn_tube_on(pos, in_dir, this.power_network, sum > 0) + if trd and trd.animated_power_network then + turn_tube_on(pos, in_dir, trd.power_network, sum > 0) end -- Needed for junctions which could have a local "turn_on" in addition turn_on(pos, in_dir, sum) @@ -145,7 +146,7 @@ techage.generator = {} function techage.generator.after_place_node(pos) local mem = tubelib2.init_mem(pos) mem.power_produce = 0 - TP(pos).power_network:after_place_node(pos) + TRD(pos).power_network:after_place_node(pos) return mem end @@ -183,7 +184,7 @@ function techage.generator.read_power_consumption(pos, in_dir) end function techage.generator.after_dig_node(pos, oldnode) - TN(oldnode).power_network:after_dig_node(pos) + TRDN(oldnode).power_network:after_dig_node(pos) tubelib2.del_mem(pos) end @@ -200,7 +201,7 @@ techage.distributor = {} function techage.distributor.after_place_node(pos, placer) local mem = tubelib2.init_mem(pos) - TP(pos).power_network:after_place_node(pos) + TRD(pos).power_network:after_place_node(pos) return mem end @@ -218,11 +219,11 @@ end -- Needed if the junction consumes power in addition function techage.distributor.read_power_consumption(pos, in_dir) - return power_consumption(pos, in_dir) - TP(pos).power_consumption or 0 + return power_consumption(pos, in_dir) - TRD(pos).power_consumption or 0 end function techage.distributor.after_dig_node(pos, oldnode) - TN(oldnode).power_network:after_dig_node(pos) + TRDN(oldnode).power_network:after_dig_node(pos) tubelib2.del_mem(pos) end @@ -235,7 +236,7 @@ function techage.consumer.after_place_node(pos, placer) local mem = tubelib2.init_mem(pos) -- Power_dir is in-dir mem.power_consumption = 0 - TP(pos).power_network:after_place_node(pos) + TRD(pos).power_network:after_place_node(pos) return mem end @@ -244,7 +245,7 @@ function techage.consumer.after_tube_update(node, pos, out_dir, peer_pos, peer_i local pwr_dir = get_power_dir(pos) mem.connections = mem.connections or {} -- Check direction - if not TP(pos).valid_power_dir(pos, pwr_dir, tubelib2.Turn180Deg[out_dir]) then return end + if not TRD(pos).valid_power_dir(pos, pwr_dir, tubelib2.Turn180Deg[out_dir]) then return end -- Only one connection is allowed, which can be overwritten, if necessary. if not peer_pos or not next(mem.connections) or mem.connections[out_dir] then if not peer_in_dir then @@ -269,11 +270,11 @@ end function techage.consumer.read_power_consumption(pos, in_dir) local mem = tubelib2.get_mem(pos) -- Check direction - if not TP(pos).valid_power_dir(pos, get_power_dir(pos), in_dir) then return 0 end + if not TRD(pos).valid_power_dir(pos, get_power_dir(pos), in_dir) then return 0 end return -(mem.power_consumption or 0) end function techage.consumer.after_dig_node(pos, oldnode) - TN(oldnode).power_network:after_dig_node(pos) + TRDN(oldnode).power_network:after_dig_node(pos) tubelib2.del_mem(pos) end diff --git a/basic_machines/tubes.lua b/basis/tubes.lua similarity index 87% rename from basic_machines/tubes.lua rename to basis/tubes.lua index 11c44ea..8e3701d 100644 --- a/basic_machines/tubes.lua +++ b/basis/tubes.lua @@ -37,12 +37,12 @@ techage.Tube = Tube minetest.register_node("techage:tubeS", { description = "TechAge Tube", tiles = { -- Top, base, right, left, front, back - "techage_tube.png^[transformR90", - "techage_tube.png^[transformR90", - "techage_tube.png", - "techage_tube.png", - "techage_hole.png", - "techage_hole.png", + "techage_tube_tube.png^[transformR90", + "techage_tube_tube.png^[transformR90", + "techage_tube_tube.png", + "techage_tube_tube.png", + "techage_tube_hole.png", + "techage_tube_hole.png", }, after_place_node = function(pos, placer, itemstack, pointed_thing) @@ -84,12 +84,12 @@ minetest.register_node("techage:tubeS", { minetest.register_node("techage:tubeA", { description = "TechAge Tube", tiles = { -- Top, base, right, left, front, back - "techage_knee2.png", - "techage_hole2.png^[transformR180", - "techage_knee.png^[transformR270", - "techage_knee.png", - "techage_knee2.png", - "techage_hole2.png", + "techage_tube_knee2.png", + "techage_tube_hole2.png^[transformR180", + "techage_tube_knee.png^[transformR270", + "techage_tube_knee.png", + "techage_tube_knee2.png", + "techage_tube_hole2.png", }, after_dig_node = function(pos, oldnode, oldmetadata, digger) diff --git a/electric/test.lua b/electric/test.lua index 4699087..5b2d7c1 100644 --- a/electric/test.lua +++ b/electric/test.lua @@ -155,6 +155,7 @@ minetest.register_node("techage:power", { turn_on = generator_turn_on_clbk, read_power_consumption = generator.read_power_consumption, power_network = Cable, + power_side = "R", }, after_place_node = generator.after_place_node, diff --git a/init.lua b/init.lua index e69e032..8456aa3 100644 --- a/init.lua +++ b/init.lua @@ -17,6 +17,8 @@ dofile(MP.."/basis/power.lua") -- power distribution dofile(MP.."/basis/node_states.lua") dofile(MP.."/basis/trowel.lua") -- hidden networks dofile(MP.."/basis/junction.lua") -- network junction box +dofile(MP.."/basis/tubes.lua") -- tubelib replacement +dofile(MP.."/basis/command.lua") -- tubelib replacement -- Steam Engine dofile(MP.."/steam_engine/drive_axle.lua") @@ -33,12 +35,13 @@ dofile(MP.."/electric/test.lua") dofile(MP.."/electric/generator.lua") dofile(MP.."/electric/consumer.lua") ---dofile(MP.."/basic_machines/pusher.lua") +dofile(MP.."/basic_machines/pusher.lua") +dofile(MP.."/basic_machines/legacy_nodes.lua") --dofile(MP.."/fermenter/biogas_pipe.lua") --dofile(MP.."/fermenter/gasflare.lua") ---dofile(MP.."/nodes/test.lua") +dofile(MP.."/nodes/test.lua") --dofile(MP.."/mechanic/perf_test.lua") diff --git a/steam_engine/cylinder.lua b/steam_engine/cylinder.lua index 895f39a..f0edf35 100644 --- a/steam_engine/cylinder.lua +++ b/steam_engine/cylinder.lua @@ -16,8 +16,6 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local TP = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end -local TN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end -- Load support for intllib. local MP = minetest.get_modpath("tubelib2") diff --git a/steam_engine/firebox.lua b/steam_engine/firebox.lua index 3597677..354b143 100644 --- a/steam_engine/firebox.lua +++ b/steam_engine/firebox.lua @@ -16,8 +16,6 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local TP = function(pos) return minetest.registered_nodes[minetest.get_node(pos).name].techage end -local TN = function(node) return minetest.registered_nodes[node.name].techage end -- Load support for intllib. local MP = minetest.get_modpath("tubelib2") diff --git a/steam_engine/flywheel.lua b/steam_engine/flywheel.lua index 264aa1e..c6da90f 100644 --- a/steam_engine/flywheel.lua +++ b/steam_engine/flywheel.lua @@ -16,8 +16,8 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local TP = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end -local TN = function(name) return (minetest.registered_nodes[name] or {}).techage end +-- Techage Related Data +local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end -- Load support for intllib. local MP = minetest.get_modpath("tubelib2") @@ -45,9 +45,9 @@ end local function start_cylinder(pos, on) local pos2 = techage.get_pos(pos, 'L') - local that = TP(pos2) - if that and that.start_cylinder then - return that.start_cylinder(pos2, on) + local trd = TRD(pos2) + if trd and trd.start_cylinder then + return trd.start_cylinder(pos2, on) end return false end diff --git a/textures/techage_defect.png b/textures/techage_defect.png new file mode 100644 index 0000000000000000000000000000000000000000..5cb0b7ced40d84ac27d13cc67a4061fb18ad62f2 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4*VGbSFISh@b7!7CbNKrM zhPdt5rGZk6B|(0{3=Yq3q=7g|-tI089jvk*Kn`btM`SSr1Gg{;GcwGYBLNg-FY)ws zWq-sY!L210@LuEqP)Ig2B%;JQKQ}iuuLQ_tU~n!5%LgD|JT@i~f@Le!p5!1)AXl7YpU(q}1z_2MD z-4jG*#l;_nl-R|ztbM^0)3Wph+d_{n<}b=(2afTJy7cEKTw;AJp~7%Rg{%KzZ-2!@ inT`A0U&*cat)C^`c1d<$s$+Tv$Vr~AelF{r5}E*l@?O*c literal 0 HcmV?d00001 diff --git a/textures/techage_flywheel4.png b/textures/techage_flywheel4.png index 8d8c15a57fa8a44e308411e83944dc0c95e3b52f..5463b7d11f4057261fef4a87d9390fc2da0c23dd 100644 GIT binary patch delta 20 ccmZ4Cyux`x5GOMyuZ~vFzvF*5M*AuP08Whu`2YX_ delta 20 bcmZ4Cyux`x5GRv3m%IV5oQvMZXkSGDJ%$BK diff --git a/textures/techage_frame_ta2_top.png b/textures/techage_frame_ta2_top.png new file mode 100644 index 0000000000000000000000000000000000000000..593a37ab936146c8b9f05f68c5b2fd79cd375b25 GIT binary patch literal 1390 zcmV-!1(EuRP)i2X3^P~`99cFRY@h-_mL&(4Eg^7jStR@e zBK`qR2^=_b;DEsaprL>SIl_|FGm^p3-89uT_2_!t_v1KdR0vsiR=vZeEv=<}*4f%i z9KZ9XNy9nkU!T%Dd>ps2PcRvirwK){#A&oB!Voan-N(?{VSRc+QRGw)duYc6V*n6B zvK*dM1S_0I181jAwwMvkW*Dnv6~r{_HN4#p(R7N_@R4~EP~3inhdfP|hU8g!EfkET$vE?u&dJ-e%{?r&wN&!5EUuM+A?(z`bLMzqg0os<6&tq8q>9 zgV7Dp0$tVk4IAMI(wo2Gll4>N$r>pz3Q0@wCithsa?cB|N4dz%0ZZtV!b9wA}pm4 z2&`HiZM)>lIeC`iwmZbr5ypTq2B+De$WvzH3oLEpSA5DiLLf<#47b&UD5A)-Z~Nd#+CrUg<+MZe!?Fc@IMVCw>OqqX7l+HF)kos!M}%(LwfS!r%v zKyo={e)<-7{Q|@h3L$W9fs_qQoNQeH0^B%82#aF9M(Jh~lV>QciPjg}pTJ^;*V;#E ziKw_p47~qUgXrLwNY~rCfa>And^kHK`{Aol6i98`8&f2CzWpblq~GuJ>AQbnv7Dm- z-1B=p-@RnLT5g@bSS>OC_!B?fk6FwX$Y?UbQZ9~L!A(l8#f3?Vwp}{6oWs$QSo?pWNBnLmaOE9{ijAP{D{EU0Yl5qbe z1aj;A`Et&^V~P3EtAvv|5@Wtwjk~RD`vrr+00bxmgrB|5v+a^%UA-0)hM&F7U4MmL z){xqE(OHVtnrkVqf{Fu7oKZv(3L|LtZeuVcv&q)^m2z1mjS4^Gil3q(qu>;m+*$lvSUyus%menGXf%f;CY zas1Ak#-uayEJQ0C+pUm<3Jk0s4N+R-?d+0e2~KPGDhCRQl#=E7ReaF4LTQ^k%klO) zq?c2S<3Jo?$^uj7lvYWQ8l1AgYwUbK8^%Y!qw$!=t()J=h6aOj`LAqP@qD};pJ;W-U@+jvFZ`NtJfeQ1i>HcBZ@P>qVu3;a zk8CI`gp|b7OOT-Ib!3td1y^T!ZU2C1aA7Xb?h71{s*17=A? zK~z}7y_ZdI8dnsC9}pgp>=`Ou2ABbcwzj)+lg43*;`sQO;lqepwF%aA7VS?Rgb>uKRa)&fsXyPHFKki3$Ylw` z5P&F(utkAT-czYm^t^4`T3IfeWpFp3R4nQ7=Js}F&--`pd2(<7Kq&8*I%2lE*IiOS z|MJtqt9wW(^*^1`mWvgWuhUfrX6-33_r zR-(LedU{I6G)+FwKGSTp0C@4@$0Oi|%}DL!`x`eN z_&$|Nh2g^p$0?JJqB*v0lgnmTP`^nG^=3{+<)mS3CE@{%0o&&4>WZ`~sik6x z!=uAQLNK@+=%Sa7FRJ3Q=@68PCBiTy2>PoRNCE>Y%u>pw2ZEqaty*O?9I>~*n-~Th zr@Zul(ac+(+Jm;;s}s8y@_B}+oo3#vm9fANyQK>JfiXM#?{i_6PoV(+?` zrb($-T4JEtXfd75c=q&ZA{f})-^CUMrnA{H1j_BoC7YIJqlJ~XbeorsqB*@@k5aLO zSN9UR#Ncj#ZQDfAe3=D?VKAM|IDhjt5fDbvTofrl;dAQW7DEx9CzzGTrMgUfpB(Fj6m7ZG-k}f$yV; zkPw1Q;QN{=IIhdZUmwoYrOw~H)g(lXaU!x#R@C?NAHM$&8BzKi*ClUSnkS|@oz`NV zg0qbg`oG$(IbE7VMh()s%JA4_id8v=N0h`!w|#R(od?o)O0q} z>q?Kpm?9(VIv*vcaf%(Ek5h29@3HwPn(K3qQFXP}{HMXcCwu6?FPp=)00000NkvXX Hu0mjfA?)6$ literal 0 HcmV?d00001 diff --git a/textures/techage_frame_ta4_top.png b/textures/techage_frame_ta4_top.png new file mode 100644 index 0000000000000000000000000000000000000000..b744511de0d251384504240fc4e5734ac9e11e93 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&pI^nNx^MDh;8jB)dyf@RNO^nYxdR6jyq$lia9T0!y=ym%En^-V&~&ylMVy6Z aYz$YIiX2hA#`qBE35lUAJyd6TDXa+5+!$-TJJq7Hy5dNwOHW_-^qJExU%liUTx9^%%b4Wt?!wT)D(eB{ za29w(7Bet#3xhBt!>lNS%G}U;vjb? zhIQv;UIID%0X`wFKADBfRxJhcHgDfFVM>2cRfi8qT}hB%FoVOh8)-m}i>HfYh{pNk z1PK=hmjD+RiH?U%ZHJl^GC0HqLYSBxTevzH!lvI6;x#X;^) z4C~IxyaaOO0(?STeKHG|ty&7?ZQHqZce(xL$-xt*^l!{GUm9zalbc;7?85@mRubeF z%;50sMjDXQ>FMGaVsZNIL~lN3MIPtlrLzpa?=R?Gpd}c&ah9vD9n(A>zUyDZg=7NC z3(iO{_*-XUz0vx?Rt^oBum?vN=P}qJp)78&qol`;+0D!4t>i_@% literal 0 HcmV?d00001 diff --git a/textures/techage_tube_knee.png b/textures/techage_tube_knee.png new file mode 100644 index 0000000000000000000000000000000000000000..935d75e9fd1d8c0eb972cd457ed45a9e92319581 GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-1AIbUeKHGgEsQ%<=em8@wq>i9UYQnls>5qXk?n*j{i~Bra&oiXRv$43 z=`0EI3ubV5b|VeQdFtun7-Dhy?Ido#76T5K?KP+G{Xf7R@>;_7(4w`Sd(JSteg3&W z+F4ICT)F*tI`%TiMp&{yzD3~p)~!_orctZ3>9%) zyeZe(F0!#O#5F8C$`-P~BhrD5L5IJaZ3SbfD|ex~HRGl%3&s~tG9pqZc0?|5@=IWz z>du{apliXrj(u7p3wT3r`VA*u z+_Gt!?@%f@(KzqH(M2MD2mZP$a`$n>GlcO^5Bt`7^q-^R?RmzREt|X_vhzM+f729O RRRQ!cgQu&X%Q~loCIB(alEwf4 literal 0 HcmV?d00001 diff --git a/textures/techage_tube_knee2.png b/textures/techage_tube_knee2.png new file mode 100644 index 0000000000000000000000000000000000000000..50b32056a129ec927c097f8cbf02b2f8de74aea4 GIT binary patch literal 324 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-1AIbUeKHG=G`cNYwRBIp!|i#|mnH@8-nVPx)(sP;^sh@Z%gN0?_JzqD zq_ZT*FPOpM*^M+HXN#wcV~EA+x03?-jwo=roK|4{_K!Vo%hr{G-&nl&_vnAtnfds~ zd86l*Ok(qyIu7&ISQ)MpEj%IAvGS|pNg;-=OkWiSMl%OpCN+nw>O;H%3@#oFZyQW9 znJ>gPa%V6HsBqOW&Sc`A@aHI#2-m-*7yhwL^D9^-!O1^CbIS7OVpcr`j&GkPG7FUH ze=}hGl*IqecwxYf;4xDYgf)Xx^-{%f7aO-S^pJJ SSo9X?eg;ohKbLh*2~7a!Sa`Pp literal 0 HcmV?d00001 diff --git a/textures/techage_tube_tube.png b/textures/techage_tube_tube.png new file mode 100644 index 0000000000000000000000000000000000000000..72b8602b07b5f163ca1ec8d00fd1d19dd4d1b550 GIT binary patch literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-1AIbUeKHFV)w$kX7`trM(rvr8UY!=UtHka^yVry%{cBTAb8@r)ZIoF9 z(peJZ7tG-B>_!@pv(eMVF~s8Z+dxjC76l$=;RQebv*+_`zjz~jM&s5p-YHW)9ds08 zQd}S(&mx!+ckCY6LL2Zb{e|C9bhfKx&%A$sQ{a z(IAK9w#BS{Whw`lG$u~D%)R#Fxq|I+k=*&L)`wTG&;7G7xZ(d1;eAJcbGi9EVE!q# z_k85nlRsDG7EN8z6ub5Akyqc1-5qCrHFzP|8W}SGY<_9@m+MY?yX`INj%%=Q-