Use nodebox for rendering cables
This commit is contained in:
parent
4e7499279c
commit
7ce091f423
16
api.lua
16
api.lua
@ -131,13 +131,15 @@ industrialtest.api.powerFlow=function(pos)
|
||||
transferred=true
|
||||
end
|
||||
local def=minetest.registered_nodes[minetest.get_node(neighbourPositions[key]).name]
|
||||
local updateFormspec=def._industrialtest_updateFormspec
|
||||
if updateFormspec then
|
||||
updateFormspec(value)
|
||||
end
|
||||
local onPowerFlow=def._industrialtest_onPowerFlow
|
||||
if onPowerFlow and transferred then
|
||||
onPowerFlow(neighbourPositions[key],industrialtest.api.getOppositeSide(key))
|
||||
if def then
|
||||
local updateFormspec=def._industrialtest_updateFormspec
|
||||
if updateFormspec then
|
||||
updateFormspec(value)
|
||||
end
|
||||
local onPowerFlow=def._industrialtest_onPowerFlow
|
||||
if onPowerFlow and transferred then
|
||||
onPowerFlow(neighbourPositions[key],industrialtest.api.getOppositeSide(key))
|
||||
end
|
||||
end
|
||||
minetest.get_node_timer(neighbourPositions[key]):start(industrialtest.updateDelay)
|
||||
if not industrialtest.api.isFullyCharged(value) then
|
||||
|
166
cables.lua
166
cables.lua
@ -16,39 +16,139 @@
|
||||
|
||||
local S=minetest.get_translator("industrialtest")
|
||||
|
||||
local definition={
|
||||
description=S("Copper Cable"),
|
||||
tiles={"industrialtest_copper_cable.png"},
|
||||
on_construct=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
industrialtest.api.addPowerStorage(meta,390,390,"aaaaaa")
|
||||
end,
|
||||
on_timer=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local afterFlow,_=industrialtest.api.powerFlow(pos)
|
||||
meta:set_string("industrialtest.ioConfig","aaaaaa")
|
||||
if not industrialtest.api.isFullyCharged(meta) then
|
||||
industrialtest.api.triggerNeighbours(pos)
|
||||
local function registerCable(name,displayName,material,size,flow)
|
||||
local definition={
|
||||
description=S(displayName.." Cable"),
|
||||
inventory_image="industrialtest_"..name.."_cable_inv.png",
|
||||
tiles={"industrialtest_"..name.."_cable.png"},
|
||||
wield_image="industrialtest_"..name.."_cable_inv.png",
|
||||
paramtype="light",
|
||||
sunlight_propagates=true,
|
||||
drawtype="nodebox",
|
||||
node_box={
|
||||
type="connected",
|
||||
fixed={
|
||||
-size,
|
||||
-size,
|
||||
-size,
|
||||
size,
|
||||
size,
|
||||
size
|
||||
},
|
||||
connect_top={
|
||||
-size,
|
||||
-size,
|
||||
-size,
|
||||
size,
|
||||
0.5,
|
||||
size
|
||||
},
|
||||
connect_bottom={
|
||||
-size,
|
||||
-0.5,
|
||||
-size,
|
||||
size,
|
||||
size,
|
||||
size
|
||||
},
|
||||
connect_front={
|
||||
-size,
|
||||
-size,
|
||||
-0.5,
|
||||
size,
|
||||
size,
|
||||
size,
|
||||
},
|
||||
connect_left={
|
||||
-0.5,
|
||||
-size,
|
||||
-size,
|
||||
size,
|
||||
size,
|
||||
size
|
||||
},
|
||||
connect_back={
|
||||
-size,
|
||||
-size,
|
||||
-size,
|
||||
size,
|
||||
size,
|
||||
0.5
|
||||
},
|
||||
connect_right={
|
||||
-size,
|
||||
-size,
|
||||
-size,
|
||||
0.5,
|
||||
size,
|
||||
size
|
||||
}
|
||||
},
|
||||
connects_to={
|
||||
"group:_industrialtest_hasPowerInput",
|
||||
"group:_industrialtest_hasPowerOutput"
|
||||
},
|
||||
on_construct=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
industrialtest.api.addPowerStorage(meta,flow,flow,"aaaaaa")
|
||||
end,
|
||||
on_timer=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local afterFlow,_=industrialtest.api.powerFlow(pos)
|
||||
meta:set_string("industrialtest.ioConfig","aaaaaa")
|
||||
if not industrialtest.api.isFullyCharged(meta) then
|
||||
industrialtest.api.triggerNeighbours(pos)
|
||||
end
|
||||
return (afterFlow and meta:get_int("industrialtest.powerAmount")>0)
|
||||
end,
|
||||
_industrialtest_onPowerFlow=function(pos,side)
|
||||
local meta=minetest.get_meta(pos)
|
||||
industrialtest.api.changeIoConfig(meta,side,"i")
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end
|
||||
return (afterFlow and meta:get_int("industrialtest.api.powerAmount")>0)
|
||||
end,
|
||||
_industrialtest_hasPowerInput=true,
|
||||
_industrialtest_onPowerFlow=function(pos,side)
|
||||
local meta=minetest.get_meta(pos)
|
||||
industrialtest.api.changeIoConfig(meta,side,"i")
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end
|
||||
}
|
||||
if industrialtest.mtgAvailable then
|
||||
definition.groups={
|
||||
cracky=1,
|
||||
level=1,
|
||||
oddly_breakable_by_hand=1
|
||||
}
|
||||
definition.sound=default.node_sound_metal_defaults()
|
||||
elseif industrialtest.mclAvailable then
|
||||
definition.groups={pickaxey=1}
|
||||
definition._mcl_blast_resistance=1
|
||||
definition._mcl_hardness=0.5
|
||||
if industrialtest.mtgAvailable then
|
||||
definition.groups={
|
||||
cracky=1,
|
||||
level=1,
|
||||
oddly_breakable_by_hand=1
|
||||
}
|
||||
definition.sound=default.node_sound_metal_defaults()
|
||||
elseif industrialtest.mclAvailable then
|
||||
definition.groups={pickaxey=1}
|
||||
definition._mcl_blast_resistance=1
|
||||
definition._mcl_hardness=0.5
|
||||
definition.sound=mcl_sounds.node_sound_metal_defaults()
|
||||
end
|
||||
definition.groups._industrialtest_hasPowerInput=1
|
||||
minetest.register_node("industrialtest:"..name.."_cable",definition)
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
output="industrialtest:"..name.."_cable 6",
|
||||
recipe={
|
||||
{material,material,material},
|
||||
{"","",""},
|
||||
{"","",""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
output="industrialtest:"..name.."_cable 6",
|
||||
recipe={
|
||||
{"","",""},
|
||||
{material,material,material},
|
||||
{"","",""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
output="industrialtest:"..name.."_cable 6",
|
||||
recipe={
|
||||
{"","",""},
|
||||
{"","",""},
|
||||
{material,material,material}
|
||||
}
|
||||
})
|
||||
end
|
||||
minetest.register_node("industrialtest:copper_cable",definition)
|
||||
|
||||
registerCable("copper","Copper",industrialtest.elementKeys.copperIngot,0.15,216)
|
||||
|
@ -480,6 +480,7 @@ if industrialtest.mclAvailable then
|
||||
-- assign element keys for elements that are required later
|
||||
industrialtest.elementKeys.stick="mcl_core:stick"
|
||||
industrialtest.elementKeys.ironIngot="mcl_core:iron_ingot"
|
||||
industrialtest.elementKeys.copperIngot="mcl_copper:copper_ingot"
|
||||
industrialtest.elementKeys.powerCarrier="mesecons:mesecon"
|
||||
industrialtest.elementKeys.furnace="mcl_furnaces:furnace"
|
||||
|
||||
@ -642,6 +643,7 @@ elseif industrialtest.mtgAvailable then
|
||||
industrialtest.elementKeys.tinIngot="default:tin_ingot"
|
||||
industrialtest.elementKeys.bronzeIngot="default:bronze_ingot"
|
||||
industrialtest.elementKeys.ironIngot="default:steel_ingot"
|
||||
industrialtest.elementKeys.copperIngot="default:copper_ingot"
|
||||
industrialtest.elementKeys.stick="default:stick"
|
||||
industrialtest.elementKeys.powerCarrier="default:mese_crystal_fragment"
|
||||
industrialtest.elementKeys.furnace="default:furnace"
|
||||
|
@ -173,10 +173,12 @@ elseif industrialtest.mclAvailable then
|
||||
definition.after_dig_node=function(pos,oldnode,oldmeta)
|
||||
mclAfterDigNode(pos,oldmeta,{"charged","fuel"})
|
||||
end
|
||||
definition.groups={pickaxey=1}
|
||||
definition.sounds=mcl_sounds.node_sound_metal_defaults()
|
||||
definition._mcl_blast_resistance=3.5
|
||||
definition._mcl_hardness=3.9
|
||||
end
|
||||
definition.groups._industrialtest_hasPowerOutput=1
|
||||
minetest.register_node("industrialtest:generator",definition)
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
@ -647,7 +649,6 @@ definition={
|
||||
end
|
||||
end
|
||||
end,
|
||||
_industrialtest_hasPowerInput=true,
|
||||
_industrialtest_updateFormspec=function(meta)
|
||||
meta:set_string("formspec",electricFurnaceFormspec(meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100,meta:get_float("srcTime")/meta:get_float("maxSrcTime")*100))
|
||||
end
|
||||
@ -667,10 +668,12 @@ elseif industrialtest.mclAvailable then
|
||||
definition.after_dig_node=function(pos,oldnode,oldmeta)
|
||||
mclAfterDigNode(pos,oldmeta,{"src","powerStorage","dst","upgrades"})
|
||||
end
|
||||
definition.groups={pickaxey=1}
|
||||
definition.sounds=mcl_sounds.node_sound_metal_defaults()
|
||||
definition._mcl_blast_resistance=3
|
||||
definition._mcl_hardness=3.5
|
||||
end
|
||||
definition.groups._industrialtest_hasPowerInput=1
|
||||
minetest.register_node("industrialtest:electric_furnace",definition)
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
|
@ -42,7 +42,7 @@ minetest.register_craft({
|
||||
-- Node callbacks
|
||||
minetest.register_on_placenode(function(pos,newNode)
|
||||
local def=minetest.registered_nodes[newNode.name]
|
||||
if def and def._industrialtest_hasPowerInput then
|
||||
if def and def.groups and def.groups._industrialtest_hasPowerInput then
|
||||
industrialtest.api.triggerNeighbours(pos)
|
||||
end
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user