65 lines
3.5 KiB
Lua
65 lines
3.5 KiB
Lua
local S = minetest.get_translator(minetest.get_current_modname())
|
|
local name = minetest.get_current_modname()
|
|
local path = minetest.get_modpath(name)
|
|
local energy_hatch_table ={
|
|
{"base","Base",32,64000,"#575757","owl_tech:copper_electro_wire","steel"}
|
|
}
|
|
for i, value in ipairs(energy_hatch_table) do
|
|
minetest.register_node("owl_tech:"..energy_hatch_table[i][1].."_battery", {
|
|
description = S(energy_hatch_table[i][2].." baattery"),
|
|
_doc_items_longdesc = S("Contains electricity tire"..i), --
|
|
tiles = {
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_steam_input.png",
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_steam_output.png",
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_base_battary_side.png",
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_base_battary_side.png",
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_base_battary_side.png",
|
|
"(owl_tech_base_meshanism_side.png^[colorize:"..energy_hatch_table[i][5]..":128)^owl_tech_base_battary_side.png",
|
|
},
|
|
is_ground_content = false,
|
|
stack_max = 64,
|
|
groups = {pickaxey=2, owl_tech_electro_battery=1},
|
|
sounds = mcl_sounds.node_sound_metal_defaults(),
|
|
paramtype2 = "facedir",
|
|
_mcl_blast_resistance = 6,
|
|
_mcl_hardness = 5,
|
|
on_construct = function(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
owl_tech.set_mashine_tire(meta,i+1)
|
|
owl_tech:add_electro(pos,energy_hatch_table[i][3],energy_hatch_table[i][4])
|
|
local timer =minetest.get_node_timer(pos)
|
|
meta:set_string("infotext",owl_tech:get_charge(meta).."/"..owl_tech:get_charge_max(meta))
|
|
timer:start(0.2)
|
|
end,
|
|
on_timer = function(pos, elapsed)
|
|
local timer = minetest.get_node_timer(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})).name,"owl_tech_electro_wire")>0
|
|
and owl_tech:get_charge_max(meta)-owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta) then --get from wire electro
|
|
local meta_up = minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z})
|
|
if owl_tech:get_charge(meta_up)>0 and owl_tech:get_voltage(meta)==owl_tech:get_voltage(meta_up) then
|
|
owl_tech.send_electro_from_wire_in_pos(meta_up,pos)
|
|
end
|
|
end
|
|
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})).name,"owl_tech_electro_wire")>0
|
|
and owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)>=0 then --Send to wire electro
|
|
local meta_up = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
|
|
if owl_tech:get_charge(meta_up)+owl_tech:get_voltage(meta_up)<=owl_tech:get_charge_max(meta_up) and owl_tech:get_voltage(meta)==owl_tech:get_voltage(meta_up) then
|
|
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y-1,z=pos.z})
|
|
end
|
|
end
|
|
meta:set_string("infotext",owl_tech:get_charge(meta).."/"..owl_tech:get_charge_max(meta))
|
|
timer:start(0.2)
|
|
end
|
|
})
|
|
--Crafte iron fluid pipe
|
|
minetest.register_craft({
|
|
type = "shaped",
|
|
output = "owl_tech:"..energy_hatch_table[i][1].."_battery",
|
|
recipe = {
|
|
{"owl_tech:"..energy_hatch_table[i][7].."_plate","owl_tech:batteri_tire_"..i,"owl_tech:"..energy_hatch_table[i][7].."_plate"},
|
|
{energy_hatch_table[i][6],"owl_tech:"..energy_hatch_table[i][6].."_frames",energy_hatch_table[i][6]},
|
|
{"owl_tech:"..energy_hatch_table[i][7].."_plate","owl_tech:batteri_tire_"..i,"owl_tech:"..energy_hatch_table[i][7].."_plate"}
|
|
}
|
|
})
|
|
end |