From d6b0deb989e649e2800932d4a587c3ba9e3e24c7 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz <vanessaezekowitz@gmail.com> Date: Sat, 17 Jan 2015 01:16:39 +0100 Subject: [PATCH] fix cnc stick formspec img (missed the border) --- technic/machines/supply_converter.lua | 93 ++++++++++++++++++++++++---------------------- 1 files changed, 48 insertions(+), 45 deletions(-) diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index d9081b7..6b0da99 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -7,12 +7,51 @@ -- Once the receiver side is powered it will deliver power to the other side. -- Unused power is wasted just like any other producer! +local S = technic.getter + +local run = function(pos, node) + local demand = 10000 + local remain = 0.9 + -- Machine information + local machine_name = S("Supply Converter") + local meta = minetest.get_meta(pos) + + local pos_up = {x=pos.x, y=pos.y+1, z=pos.z} + local pos_down = {x=pos.x, y=pos.y-1, z=pos.z} + local name_up = minetest.get_node(pos_up).name + local name_down = minetest.get_node(pos_down).name + + local from = technic.get_cable_tier(name_up) + local to = technic.get_cable_tier(name_down) + + if from and to then + local input = meta:get_int(from.."_EU_input") + meta:set_int(from.."_EU_demand", demand) + meta:set_int(from.."_EU_supply", 0) + meta:set_int(to.."_EU_demand", 0) + meta:set_int(to.."_EU_supply", input * remain) + meta:set_string("infotext", machine_name + .." ("..input.." "..from.." -> " + ..input * remain.." "..to..")") + else + meta:set_string("infotext", S("%s Has Bad Cabling"):format(machine_name)) + if to then + meta:set_int(to.."_EU_supply", 0) + end + if from then + meta:set_int(from.."_EU_demand", 0) + end + return + end + +end + minetest.register_node("technic:supply_converter", { - description = "Supply Converter", + description = S("Supply Converter"), tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png"}, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}, sounds = default.node_sound_wood_defaults(), drawtype = "nodebox", paramtype = "light", @@ -21,59 +60,23 @@ fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, }, on_construct = function(pos) - local meta = minetest.env:get_meta(pos) - meta:set_string("infotext", "Supply Converter") + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Supply Converter")) meta:set_float("active", false) end, + technic_run = run, }) minetest.register_craft({ output = 'technic:supply_converter 1', recipe = { - {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'}, - {'technic:mv_transformer', 'technic:mv_cable0', 'technic:lv_transformer'}, - {'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'}, + {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'}, + {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'}, + {'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'}, } }) -minetest.register_abm({ - nodenames = {"technic:supply_converter"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local demand = 10000 - local remain = 0.9 - -- Machine information - local machine_name = "Supply Converter" - local meta = minetest.get_meta(pos) - - local pos_up = {x=pos.x, y=pos.y+1, z=pos.z} - local pos_down = {x=pos.x, y=pos.y-1, z=pos.z} - local name_up = minetest.get_node(pos_up).name - local name_down = minetest.get_node(pos_down).name - - local from = technic.get_cable_tier(name_up) - local to = technic.get_cable_tier(name_down) - - if from and to then - technic.switching_station_timeout_count(pos, from) - local input = meta:get_int(from.."_EU_input") - meta:set_int(from.."_EU_demand", demand) - meta:set_int(from.."_EU_supply", 0) - meta:set_int(to.."_EU_demand", 0) - meta:set_int(to.."_EU_supply", input * remain) - meta:set_string("infotext", machine_name - .." ("..input.." "..from.." -> " - ..input * remain.." "..to..")") - else - meta:set_string("infotext", machine_name.." has bad cabling") - return - end - - end, -}) - for tier, machines in pairs(technic.machines) do - technic.register_machine(tier, "technic:supply_converter", technic.battery) + technic.register_machine(tier, "technic:supply_converter", technic.producer_receiver) end -- Gitblit v1.8.0