Re-add electrocution by uninsulated cables
This commit is contained in:
parent
ce0a5ad2e6
commit
2dae1d931d
55
cables.lua
55
cables.lua
@ -162,12 +162,15 @@ function industrialtest.Cable.createDefinitionTable(self,description,inventoryIm
|
|||||||
def.sound=mcl_sounds.node_sound_metal_defaults()
|
def.sound=mcl_sounds.node_sound_metal_defaults()
|
||||||
end
|
end
|
||||||
def.groups._industrialtest_cable=1
|
def.groups._industrialtest_cable=1
|
||||||
|
if insulated then
|
||||||
|
def.groups._industrialtest_insulatedCable=1
|
||||||
|
end
|
||||||
|
|
||||||
return def
|
return def
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.Cable.register(self)
|
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)
|
minetest.register_node(self.name,def)
|
||||||
|
|
||||||
if self.insulated then
|
if self.insulated then
|
||||||
@ -385,6 +388,7 @@ industrialtest.internal.unpackTableInto(industrialtest.GlassFibreCable,{
|
|||||||
inventoryImage="industrialtest_glass_fibre_cable_inv.png",
|
inventoryImage="industrialtest_glass_fibre_cable_inv.png",
|
||||||
transparent=true,
|
transparent=true,
|
||||||
tile="industrialtest_glass_fibre_cable.png",
|
tile="industrialtest_glass_fibre_cable.png",
|
||||||
|
safe=true,
|
||||||
size=0.12,
|
size=0.12,
|
||||||
flow=industrialtest.api.ivPowerFlow
|
flow=industrialtest.api.ivPowerFlow
|
||||||
})
|
})
|
||||||
@ -401,3 +405,52 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
-- TODO: Add glass fibre cable craft with silver ingot
|
-- 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 electrocutionDelta<industrialtest.config.updateDelay then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
electrocutionDelta=0
|
||||||
|
|
||||||
|
local offsets={
|
||||||
|
vector.new(0,0,0),
|
||||||
|
vector.new(-0.7,0,0),
|
||||||
|
vector.new(-0.7,1,0),
|
||||||
|
vector.new(0,1,0),
|
||||||
|
vector.new(0.7,0,0),
|
||||||
|
vector.new(0.7,1,0),
|
||||||
|
vector.new(0,0,-0.7),
|
||||||
|
vector.new(0,1,-0.7),
|
||||||
|
vector.new(0,0,0.7),
|
||||||
|
vector.new(0,1,0.7)
|
||||||
|
}
|
||||||
|
|
||||||
|
local players=minetest.get_connected_players()
|
||||||
|
for _,player in ipairs(players) do
|
||||||
|
local pos=player:get_pos()
|
||||||
|
for _,offset in ipairs(offsets) do
|
||||||
|
local nodePos=vector.add(pos,offset)
|
||||||
|
local node=minetest.get_node(nodePos)
|
||||||
|
local def=minetest.registered_nodes[node.name]
|
||||||
|
if def and def.groups and def.groups._industrialtest_cable and not def.groups._industrialtest_insulatedCable then
|
||||||
|
local meta=minetest.get_meta(pos)
|
||||||
|
local networks=industrialtest.api.isAttachedToNetwork(meta)
|
||||||
|
if networks then
|
||||||
|
local current=0
|
||||||
|
for _,network in ipairs(networks) do
|
||||||
|
current=current+industrialtest.api.getFlowingCurrent(network)
|
||||||
|
end
|
||||||
|
if current>0 then
|
||||||
|
local removed=math.ceil(current/500)
|
||||||
|
player:set_hp(player:get_hp()-removed,"electrocution")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
3
init.lua
3
init.lua
@ -21,7 +21,8 @@ industrialtest={}
|
|||||||
|
|
||||||
-- Settings
|
-- Settings
|
||||||
industrialtest.config={
|
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)
|
developerMode=minetest.settings:get_bool("industrialtest.developerMode",false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# This determines value how frequently machines update
|
# This determines value how frequently machines update
|
||||||
industrialtest.updateDelay (Update delay) float 1.0
|
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
|
# Enables additional utils useful when developing mod
|
||||||
industrialtest.developerMode (Developer mode) bool false
|
industrialtest.developerMode (Developer mode) bool false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user