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 0000000..5cb0b7c Binary files /dev/null and b/textures/techage_defect.png differ diff --git a/textures/techage_flywheel4.png b/textures/techage_flywheel4.png index 8d8c15a..5463b7d 100644 Binary files a/textures/techage_flywheel4.png and b/textures/techage_flywheel4.png differ diff --git a/textures/techage_frame_ta2_top.png b/textures/techage_frame_ta2_top.png new file mode 100644 index 0000000..593a37a Binary files /dev/null and b/textures/techage_frame_ta2_top.png differ diff --git a/textures/techage_frame_ta3_top.png b/textures/techage_frame_ta3_top.png new file mode 100644 index 0000000..2b2e58b Binary files /dev/null and b/textures/techage_frame_ta3_top.png differ diff --git a/textures/techage_frame_ta4_top.png b/textures/techage_frame_ta4_top.png new file mode 100644 index 0000000..b744511 Binary files /dev/null and b/textures/techage_frame_ta4_top.png differ diff --git a/textures/techage_pusher.png b/textures/techage_pusher.png new file mode 100644 index 0000000..41067fe Binary files /dev/null and b/textures/techage_pusher.png differ diff --git a/textures/techage_tube_hole.png b/textures/techage_tube_hole.png new file mode 100644 index 0000000..6d61205 Binary files /dev/null and b/textures/techage_tube_hole.png differ diff --git a/textures/techage_tube_hole2.png b/textures/techage_tube_hole2.png new file mode 100644 index 0000000..f890046 Binary files /dev/null and b/textures/techage_tube_hole2.png differ diff --git a/textures/techage_tube_knee.png b/textures/techage_tube_knee.png new file mode 100644 index 0000000..935d75e Binary files /dev/null and b/textures/techage_tube_knee.png differ diff --git a/textures/techage_tube_knee2.png b/textures/techage_tube_knee2.png new file mode 100644 index 0000000..50b3205 Binary files /dev/null and b/textures/techage_tube_knee2.png differ diff --git a/textures/techage_tube_tube.png b/textures/techage_tube_tube.png new file mode 100644 index 0000000..72b8602 Binary files /dev/null and b/textures/techage_tube_tube.png differ