155 lines
3.6 KiB
Lua
155 lines
3.6 KiB
Lua
-- IndustrialTest
|
|
-- Copyright (C) 2023 mrkubax10
|
|
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
local S=minetest.get_translator("industrialtest")
|
|
|
|
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
|
|
}
|
|
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
|
|
|
|
registerCable("copper","Copper",industrialtest.elementKeys.copperIngot,0.15,216)
|