From 0211c582e9ce8745e19ff49496b026d393dad074 Mon Sep 17 00:00:00 2001 From: sfence <sfence.software@gmail.com> Date: Mon, 06 Jun 2022 18:53:50 +0200 Subject: [PATCH] Add charge set/get callbacks (#600) --- technic/machines/supply_converter.lua | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index aa41791..24601c6 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -72,6 +72,9 @@ receptor = {action = function() end}, effector = { action = function(pos, node, channel, msg) + if type(msg) ~= "string" then + return + end local meta = minetest.get_meta(pos) if channel ~= meta:get_string("channel") then return @@ -90,7 +93,7 @@ meta:set_int("enabled", 1) elseif msg == "toggle" then local onn = meta:get_int("enabled") - onn = -(onn-1) -- Mirror onn with pivot 0.5, so switch between 1 and 0. + onn = 1-onn -- Mirror onn with pivot 0.5, so switch between 1 and 0. meta:set_int("enabled", onn) elseif msg:sub(1, 5) == "power" then local power = tonumber(msg:sub(7)) @@ -103,6 +106,8 @@ meta:set_int("power", power) elseif msg:sub(1, 12) == "mesecon_mode" then meta:set_int("mesecon_mode", tonumber(msg:sub(14))) + else + return end set_supply_converter_formspec(meta) end @@ -144,7 +149,9 @@ 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", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.pretty_num(input), from, technic.pretty_num(input * remain), to)) + meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, + technic.EU_string(input), from, + technic.EU_string(input * remain), to)) else meta:set_string("infotext", S("%s Has Bad Cabling"):format(machine_name)) if to then @@ -194,10 +201,11 @@ minetest.register_craft({ output = 'technic:supply_converter 1', recipe = { - {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'}, + {'basic_materials:gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'}, {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'}, {'technic:mv_cable', 'technic:rubber', 'technic:lv_cable'}, - } + }, + replacements = { {"basic_materials:gold_wire", "basic_materials:empty_spool"}, }, }) for tier, machines in pairs(technic.machines) do -- Gitblit v1.8.0