From 4775d98fb7e12f7210cf778351767828e551011d Mon Sep 17 00:00:00 2001 From: SmallJoker <mk939@ymail.com> Date: Thu, 20 Oct 2022 20:08:56 +0200 Subject: [PATCH] Unify and simplify LED/Lamp node definition --- technic/machines/HV/quarry.lua | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index b6f9c14..1bf1ad6 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -47,19 +47,30 @@ local radius = meta:get_int("size") local diameter = radius*2 + 1 local machine_name = S("%s Quarry"):format("HV") - if meta:get_int("enabled") == 0 or meta:get_int("purge_on") == 1 then - meta:set_string("infotext", S(meta:get_int("purge_on") == 1 and "%s purging cache" or "%s Disabled"):format(machine_name)) + local do_purge = meta:get_int("purge_on") == 1 + if meta:get_int("enabled") == 0 or do_purge then + local infotext = do_purge and + S("%s purging cache") or S("%s Disabled") + meta:set_string("infotext", infotext:format(machine_name)) meta:set_int("HV_EU_demand", 0) elseif meta:get_int("dug") == diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) then meta:set_string("infotext", S("%s Finished"):format(machine_name)) meta:set_int("HV_EU_demand", 0) else - meta:set_string("infotext", S(meta:get_int("HV_EU_input") >= quarry_demand and "%s Active" or "%s Unpowered"):format(machine_name)) + local infotext = meta:get_int("HV_EU_input") >= quarry_demand + and S("%s Active") or S("%s Unpowered") + meta:set_string("infotext", infotext:format(machine_name)) meta:set_int("HV_EU_demand", quarry_demand) end end local function quarry_receive_fields(pos, formname, fields, sender) + local player_name = sender:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.chat_send_player(player_name, "You are not allowed to edit this!") + minetest.record_protection_violation(pos, player_name) + return + end local meta = minetest.get_meta(pos) if fields.size and string.find(fields.size, "^[0-9]+$") then local size = tonumber(fields.size) @@ -129,7 +140,7 @@ vector.multiply(qdir, -radius)) local owner = meta:get_string("owner") local nd = meta:get_int("dug") - while nd ~= diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) do + while nd < diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) do local ry = math.floor(nd / (diameter*diameter)) local ndl = nd % (diameter*diameter) if ry % 2 == 1 then -- Gitblit v1.8.0