From 2dae1d931d77e326bf55d0b370f774755d7e9aa0 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sun, 11 May 2025 18:34:25 +0200 Subject: [PATCH] Re-add electrocution by uninsulated cables --- cables.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++- init.lua | 3 ++- settingtypes.txt | 3 +++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/cables.lua b/cables.lua index 668608b..016c3c4 100644 --- a/cables.lua +++ b/cables.lua @@ -162,12 +162,15 @@ function industrialtest.Cable.createDefinitionTable(self,description,inventoryIm def.sound=mcl_sounds.node_sound_metal_defaults() end def.groups._industrialtest_cable=1 + if insulated then + def.groups._industrialtest_insulatedCable=1 + end return def end function industrialtest.Cable.register(self) - local def=self:createDefinitionTable(self.description,self.inventoryImage,self.tile,false) + local def=self:createDefinitionTable(self.description,self.inventoryImage,self.tile,self.safe) minetest.register_node(self.name,def) if self.insulated then @@ -385,6 +388,7 @@ industrialtest.internal.unpackTableInto(industrialtest.GlassFibreCable,{ inventoryImage="industrialtest_glass_fibre_cable_inv.png", transparent=true, tile="industrialtest_glass_fibre_cable.png", + safe=true, size=0.12, flow=industrialtest.api.ivPowerFlow }) @@ -401,3 +405,52 @@ minetest.register_craft({ } }) -- TODO: Add glass fibre cable craft with silver ingot + +if industrialtest.config.electrocution then + local electrocutionDelta=0 + minetest.register_globalstep(function(dtime) + electrocutionDelta=electrocutionDelta+dtime + if electrocutionDelta0 then + local removed=math.ceil(current/500) + player:set_hp(player:get_hp()-removed,"electrocution") + break + end + end + end + end + end + end) +end diff --git a/init.lua b/init.lua index b32fd34..c03beb8 100644 --- a/init.lua +++ b/init.lua @@ -21,7 +21,8 @@ industrialtest={} -- Settings industrialtest.config={ - updateDelay=minetest.settings:get("industrialtest.updateDelay") or 1, + updateDelay=tonumber(minetest.settings:get("industrialtest.updateDelay") or "1"), + electrocution=minetest.settings:get_bool("industrialtest.electrocution",true), developerMode=minetest.settings:get_bool("industrialtest.developerMode",false) } diff --git a/settingtypes.txt b/settingtypes.txt index 4c4b4a0..5d5876b 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,5 +1,8 @@ # This determines value how frequently machines update industrialtest.updateDelay (Update delay) float 1.0 +# Whether electrocution by uninsulated cables is used +industrialtest.electrocution (Electrocution) bool true + # Enables additional utils useful when developing mod industrialtest.developerMode (Developer mode) bool false