Add electro batari and rewrute electro api
This commit is contained in:
parent
56f4c4a7ae
commit
7f846b2016
|
@ -119,10 +119,10 @@ function owl_tech.add_fluid_in_pull_from_itemslot(meta,itemstak_buck,inv,itemsta
|
|||
local fluid_indef=""
|
||||
local epmty_sel_name =""
|
||||
if name_item_fluid=="mcl_buckets:bucket_water" or name_item_fluid=="mcl_buckets:bucket_river_water" then
|
||||
fluid_indef="mcl_water"
|
||||
fluid_indef="mcl_core:water_source"
|
||||
epmty_sel_name= "mcl_buckets:bucket_empty"
|
||||
elseif name_item_fluid=="mcl_buckets:bucket_lava" then
|
||||
fluid_indef="mcl_lava"
|
||||
fluid_indef="mcl_core:lava_source"
|
||||
epmty_sel_name= "mcl_buckets:bucket_empty"
|
||||
end
|
||||
local can_return_buck= false
|
||||
|
@ -145,10 +145,12 @@ function owl_tech.add_fluid_in_pull_from_itemslot(meta,itemstak_buck,inv,itemsta
|
|||
local item ={name=epmty_sel_name, count=1, wear=0, metadata=""}
|
||||
itemstak_dst:add_item(item)
|
||||
inv:set_stack(slot_name_dst, 1, itemstak_dst)
|
||||
return true
|
||||
elseif not itemstak_dst:is_empty() then
|
||||
local item ={name=epmty_sel_name, count=itemstak_dst:get_count()+1, wear=0, metadata=""}
|
||||
itemstak_dst:add_item(item)
|
||||
inv:set_stack(slot_name_dst, 1, itemstak_dst)
|
||||
return true
|
||||
end
|
||||
else
|
||||
itemstak_buck:clear()
|
||||
|
@ -157,9 +159,11 @@ function owl_tech.add_fluid_in_pull_from_itemslot(meta,itemstak_buck,inv,itemsta
|
|||
local item ={name=epmty_sel_name, count=itemstak_dst:get_count()+1, wear=0, metadata=""}
|
||||
itemstak_dst:add_item(item)
|
||||
inv:set_stack(slot_name_dst, 1, itemstak_dst)
|
||||
return true
|
||||
elseif not itemstak_dst:is_empty() then
|
||||
itemstak_dst:set_count(itemstak_dst:get_count()+1)
|
||||
inv:set_stack(slot_name_dst, 1, itemstak_dst)
|
||||
return true
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
local name = minetest.get_current_modname()
|
||||
local path = minetest.get_modpath(name)
|
||||
|
||||
minetest.register_node("owl_tech:base_battery", {
|
||||
description = S("Base baattery"),
|
||||
_doc_items_longdesc = S("Contains electricity"), -- owl_tech_base_battary_side.png
|
||||
tiles = {
|
||||
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_battary_side.png",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_battary_side.png",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_battary_side.png",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_battary_side.png",
|
||||
},
|
||||
is_ground_content = false,
|
||||
stack_max = 64,
|
||||
groups = {pickaxey=2, owl_tech_machine=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,2)
|
||||
owl_tech:add_electro(pos,32,64000)
|
||||
local timer =minetest.get_node_timer(pos)
|
||||
meta:set_string("infotext",owl_tech.get_pull_volume(meta,1))
|
||||
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,"fluid_pipe") then --sand in pipe
|
||||
local meta_up = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta,1)
|
||||
local can_do ,inde_pull =owl_tech.test_add_fluid_in_any_pulls(meta_up,fluid_name_to_send,owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
local can_do2 ,inde_pull_2 , remove_amount =owl_tech.test_remove_fluid_in_any_pulls(meta,fluid_name_to_send,owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
if can_do and can_do2 then
|
||||
owl_tech.add_fluid_in_node_pull(meta_up,fluid_name_to_send,remove_amount,inde_pull)
|
||||
local pull_curent_volume = owl_tech.get_pull_volume(meta,1)
|
||||
local difer = pull_curent_volume-remove_amount
|
||||
owl_tech.set_pull_volume(meta,2,difer)
|
||||
end
|
||||
end]]
|
||||
meta:set_string("infotext",owl_tech:get_charge(meta))
|
||||
timer:start(0.2)
|
||||
end
|
||||
})
|
||||
--Crafte iron fluid pipe
|
||||
minetest.register_craft({
|
||||
type = "shaped",
|
||||
output = "owl_tech:bronze_tank",
|
||||
recipe = {
|
||||
{"owl_tech:bronze_plate","owl_tech:bronze_plate","owl_tech:bronze_plate"},
|
||||
{"owl_tech:bronze_plate","mcl_core:glass","owl_tech:bronze_plate"},
|
||||
{"owl_tech:bronze_plate","owl_tech:bronze_fluid_pipe","owl_tech:bronze_plate"}
|
||||
}
|
||||
})
|
|
@ -29,14 +29,14 @@ end
|
|||
|
||||
minetest.register_node("owl_tech:base_steam_turbin", {
|
||||
description = S("Base turbine"),
|
||||
_doc_items_longdesc = S("First generate electro"),
|
||||
_doc_items_longdesc = S("First generate electro"),-- owl_tech_base_electro_turbine.png
|
||||
tiles = {
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#a35900:128)^owl_tech_steam_output.png",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#a35900:128",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#a35900:128",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#a35900:128",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#a35900:128",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#a35900:128)^owl_tech_boiler_face.png",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
|
||||
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_electro_turbine.png",
|
||||
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_electro_turbine.png",
|
||||
},
|
||||
is_ground_content = false,
|
||||
stack_max = 64,
|
||||
|
@ -58,62 +58,37 @@ minetest.register_node("owl_tech:base_steam_turbin", {
|
|||
|
||||
timer:start(0.2)
|
||||
end,
|
||||
--[[on_timer = function(pos, elapsed)
|
||||
on_timer = function(pos, elapsed)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local fluid_its = inv:get_stack('fluid_in', 1)
|
||||
local fuel_its = inv:get_stack('fuel', 1)
|
||||
local dst_its = inv:get_stack('dst', 1)
|
||||
if not fluid_its:is_empty() then --Load fluid from buckets
|
||||
owl_tech.add_fluid_in_pull_from_itemslot(meta,fluid_its,inv,dst_its,'fluid_in','dst')
|
||||
inv:set_size("battari_slot", 1)
|
||||
if owl_tech:get_charge_max(meta)-owl_tech:get_charge(meta)>0 and owl_tech.get_pull_volume(meta,1)>=owl_tech:get_voltage(meta)*2 then
|
||||
owl_tech.set_pull_volume(meta,1, owl_tech.get_pull_volume(meta,1)-owl_tech:get_voltage(meta)*2 )
|
||||
owl_tech:set_charge(meta,owl_tech:get_charge(meta)+owl_tech:get_voltage(meta))
|
||||
end
|
||||
if owl_tech.get_fuel_time(meta)>0 then --burn process
|
||||
owl_tech.fuel_burning(meta)
|
||||
end
|
||||
if owl_tech.get_curent_heat(meta)>0 and owl_tech.get_fuel_time(meta)==0 then --coling boiler if not burn
|
||||
owl_tech.cooling_boiler(meta)
|
||||
end
|
||||
if owl_tech.get_curent_heat(meta)>100
|
||||
and owl_tech.get_pull_volume(meta,2)+owl_tech.get_water_in_steam(meta)*5<=owl_tech.get_pull_max_volume(meta,2)
|
||||
and owl_tech.get_pull_volume(meta,1)-owl_tech.get_water_in_steam(meta)>=0 then --make steam
|
||||
owl_tech.gen_steam_in_node_pull(meta,1,2,owl_tech.get_water_in_steam(meta))
|
||||
if owl_tech.get_pull_fluid_name(meta,2)~="owl_tech_steam" then
|
||||
owl_tech.set_pull_fluid_name(meta,2,"owl_tech_steam")
|
||||
end
|
||||
end
|
||||
if not fuel_its:is_empty() and owl_tech.get_fuel_time(meta)==0 then --Load fluid from buckets
|
||||
local out_fuel= minetest.get_craft_result({method = "fuel", width = 1, items = {fuel_its}})
|
||||
if out_fuel.time>0 then
|
||||
owl_tech.load_fuel_in_boiler(meta,inv,'fuel',out_fuel,fuel_its)
|
||||
end
|
||||
end
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})).name,"fluid_pipe") then --sand in pipe
|
||||
local meta_up = minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
local can_do ,inde_pull =owl_tech.test_add_fluid_in_any_pulls(meta_up,"owl_tech_steam",owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
local can_do2 ,inde_pull_2 , remove_amount =owl_tech.test_remove_fluid_in_any_pulls(meta,"owl_tech_steam",owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
if can_do and can_do2 then
|
||||
owl_tech.add_fluid_in_node_pull(meta_up,"owl_tech_steam",remove_amount,inde_pull)
|
||||
local pull_curent_volume = owl_tech.get_pull_volume(meta,2)
|
||||
local difer = pull_curent_volume-remove_amount
|
||||
owl_tech.set_pull_volume(meta,2,difer)
|
||||
end
|
||||
end
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})).name,"fluid_pipe")
|
||||
and owl_tech.get_pull_fluid_name(minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z}),1)=="mcl_core:water_source" then --get from pipe water
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})).name,"fluid_pipe") then --get from pipe steam
|
||||
local meta_up = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta_up,1)
|
||||
local can_do ,inde_pull =owl_tech.test_add_fluid_in_any_pulls(meta,fluid_name_to_send,owl_tech.get_fluid_sand_in_tick(meta))
|
||||
local can_do2 ,inde_pull_2 , remove_amount =owl_tech.test_remove_fluid_in_any_pulls(meta_up,fluid_name_to_send,owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
local can_do ,inde_pull =owl_tech.test_add_fluid_in_any_pulls(meta,"owl_tech_steam",owl_tech.get_fluid_sand_in_tick(meta))
|
||||
local can_do2 ,inde_pull_2 , remove_amount =owl_tech.test_remove_fluid_in_any_pulls(meta_up,"owl_tech_steam",owl_tech.get_fluid_sand_in_tick(meta_up))
|
||||
if can_do and can_do2 then
|
||||
owl_tech.add_fluid_in_node_pull(meta,fluid_name_to_send,remove_amount,inde_pull)
|
||||
owl_tech.add_fluid_in_node_pull(meta,"owl_tech_steam",remove_amount,inde_pull)
|
||||
owl_tech.remove_fluid_in_node_pull(meta_up,remove_amount,inde_pull)
|
||||
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") then --send electro in wire
|
||||
local meta_up = minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(meta_up) and
|
||||
owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta) and
|
||||
owl_tech:get_charge_max(meta_up)-owl_tech:get_charge(meta_up)>=owl_tech:get_voltage(meta) then
|
||||
owl_tech:set_charge(meta,owl_tech:get_charge(meta)-owl_tech:get_voltage(meta))
|
||||
owl_tech:set_charge(meta_up,owl_tech:get_charge(meta_up)+owl_tech:get_voltage(meta_up))
|
||||
end
|
||||
end
|
||||
owl_tech.delit_name_fluid_if_0(meta)
|
||||
set_formspect_base_boiler(meta)
|
||||
set_formspect_base_steam_turbine(meta)
|
||||
timer:start(0.2)
|
||||
end]]
|
||||
end
|
||||
})
|
||||
--Crafte bronze boiler
|
||||
minetest.register_craft({
|
||||
|
|
|
@ -33,10 +33,8 @@ end
|
|||
---------------------------------------
|
||||
--Prepear vire
|
||||
function owl_tech:prepear_vire(pos,voltage)
|
||||
local meta=minetest.get_meta(pos)
|
||||
owl_tech:add_electro(pos,voltage,voltage*6)
|
||||
owl_tech.reset_connection_wire_meta(pos)
|
||||
meta:set_string("infotext", meta:get_int(voltage).."--voltage")
|
||||
end
|
||||
---------------------------------------
|
||||
--Reset connection meta
|
||||
|
@ -69,8 +67,8 @@ function owl_tech:can_send_electro(pos,pos_send)
|
|||
local meta = minetest.get_meta(pos)
|
||||
local meta_send = minetest.get_meta(pos_send)
|
||||
if owl_tech:get_voltage(meta)== owl_tech:get_voltage(meta_send)then-- if == voltage
|
||||
if owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta)
|
||||
and owl_tech:get_charge(meta_send)+owl_tech:get_voltage(meta_send)<=owl_tech:get_charge_max(meta_send) then
|
||||
if owl_tech:get_charge(meta)>0
|
||||
and owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)>=owl_tech:get_voltage(meta_send) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
|
@ -79,136 +77,195 @@ function owl_tech:can_send_electro(pos,pos_send)
|
|||
return false
|
||||
end
|
||||
end
|
||||
-----------------------------------------
|
||||
--Send electro in pos
|
||||
function owl_tech:send_electro(pos,pos_send)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta_send = minetest.get_meta(pos_send)
|
||||
owl_tech:set_charge(meta,owl_tech:get_voltage(meta)-owl_tech:get_voltage(meta))--sender
|
||||
owl_tech:set_charge(meta_send,owl_tech:get_voltage(meta_send)+owl_tech:get_voltage(meta_send))--resiver
|
||||
end
|
||||
----------------------------------------
|
||||
--node in pos ?in list
|
||||
local conetc_to={
|
||||
"group:owl_tech_electro_wire","owl_tech_electro_mashine","owl_tech_electro_gen"
|
||||
}
|
||||
|
||||
function owl_tech.node_in_pos_connect_to_electro_wire(pos)
|
||||
local conetc_to={
|
||||
"owl_tech_electro_wire"
|
||||
}
|
||||
--node in pos ?in list
|
||||
function owl_tech.node_in_pos_connect_to_wire(pos)
|
||||
local ret=0
|
||||
for index, value in ipairs(conetc_to) do
|
||||
if minetest.get_item_group((minetest.get_node(pos)).name,value)>0 then
|
||||
if minetest.get_item_group((minetest.get_node(pos)).name,"owl_tech_electro_wire")>0 then
|
||||
ret=1
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
-------------------------------------------
|
||||
--look around for wire
|
||||
function owl_tech:look_around_for_wire(pos)
|
||||
owl_tech.reset_connection_wire_meta(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}),"group:owl_tech_electro_wire") then --+Y
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("+Y", 1)
|
||||
end
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}),"group:owl_tech_electro_wire") then ---Y
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("-Y", 1)
|
||||
end
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+1}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}),"group:owl_tech_electro_wire") then --+Z
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("+Z", 1)
|
||||
end
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z-1}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}),"group:owl_tech_electro_wire") then ---Z
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("-Z", 1)
|
||||
end
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x+1,y=pos.y,z=pos.z}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}),"group:owl_tech_electro_wire") then --+X
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("+X", 1)
|
||||
end
|
||||
if owl_tech:get_voltage(meta)==owl_tech:get_voltage(minetest.get_meta({x=pos.x-1,y=pos.y,z=pos.z}))
|
||||
and minetest.get_node_group(minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}),"group:owl_tech_electro_wire") then ---X
|
||||
owl_tech.add_1_conection_amount_wire(pos)
|
||||
meta:set_int("-X", 1)
|
||||
end
|
||||
end
|
||||
----------------------------------------------------------------------
|
||||
--select side to sand
|
||||
function owl_tech:select_side_to_sande_wire(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local side_table ={ -- +y-1 -y-2 +x-3 -x-4 +z-5 -z-5
|
||||
math.huge,math.huge,math.huge,math.huge,math.huge,math.huge
|
||||
--update pipe around
|
||||
function owl_tech.update_wire_around(pos)
|
||||
local mass_pos ={
|
||||
{x=pos.x,y=pos.y+1,z=pos.z},
|
||||
{x=pos.x,y=pos.y-1,z=pos.z},
|
||||
{x=pos.x+1,y=pos.y,z=pos.z},
|
||||
{x=pos.x-1,y=pos.y,z=pos.z},
|
||||
{x=pos.x,y=pos.y,z=pos.z+1},
|
||||
{x=pos.x,y=pos.y,z=pos.z-1}
|
||||
}
|
||||
if meta:get_int("+Y")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
side_table[1]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
if meta:get_int("-Y")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
side_table[2]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
if meta:get_int("+X")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x+1,y=pos.y,z=pos.z})
|
||||
side_table[3]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
if meta:get_int("-X")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x-1,y=pos.y,z=pos.z})
|
||||
side_table[4]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
if meta:get_int("+Z")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+1})
|
||||
side_table[5]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
if meta:get_int("-Z")~=0 then
|
||||
local meta_send= minetest.get_meta({x=pos.x,y=pos.y,z=pos.z-1})
|
||||
side_table[6]=owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)
|
||||
end
|
||||
local adres_min =-1
|
||||
local table_min= math.huge
|
||||
for i = 1, #side_table, 1 do
|
||||
if table_min>side_table[i] then
|
||||
table_min=side_table[i]
|
||||
adres_min=i
|
||||
for i, value in ipairs(mass_pos) do
|
||||
if minetest.get_item_group((minetest.get_node(mass_pos[i])).name,"owl_tech_electro_wire")>0 then
|
||||
local meta = minetest.get_meta(mass_pos[i])
|
||||
owl_tech.check_all_side_for_fluid_work(mass_pos[i],meta)
|
||||
end
|
||||
end
|
||||
return adres_min
|
||||
end
|
||||
-------------------------------------------------------------------------
|
||||
--Send to side electro
|
||||
function owl_tech:send_to_side_electro(pos)
|
||||
------------------------------
|
||||
--Chek all side for work and set it
|
||||
function owl_tech.check_all_side_for_wire_work(pos,meta)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number_side_to_sand = owl_tech:select_side_to_sande_wire(pos)
|
||||
if number_side_to_sand ==1 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x,y=pos.y+1,z=pos.z}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x,y=pos.y+1,z=pos.z})
|
||||
owl_tech:set_connection_amount_wire(pos,0) --reset conection amount
|
||||
|
||||
owl_tech.set_side_info_y_p(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y+1,z=pos.z}))--y+
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y+1,z=pos.z}))
|
||||
|
||||
owl_tech.set_side_info_y_m(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y-1,z=pos.z}))--y-
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y-1,z=pos.z}))
|
||||
|
||||
owl_tech.set_side_info_x_p(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x+1,y=pos.y,z=pos.z}))--x+
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x+1,y=pos.y,z=pos.z}))
|
||||
|
||||
owl_tech.set_side_info_x_m(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x-1,y=pos.y,z=pos.z}))--x-
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x-1,y=pos.y,z=pos.z}))
|
||||
|
||||
owl_tech.set_side_info_z_p(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y,z=pos.z+1}))--z+
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y,z=pos.z+1}))
|
||||
|
||||
owl_tech.set_side_info_z_m(meta,owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y,z=pos.z-1}))--z-
|
||||
owl_tech.set_conection_amount_fluid(meta,owl_tech.get_conection_amount_fluid(meta)+owl_tech.node_in_pos_connect_to_wire({x=pos.x,y=pos.y,z=pos.z-1}))
|
||||
end
|
||||
elseif number_side_to_sand ==2 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x,y=pos.y-1,z=pos.z}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
elseif number_side_to_sand ==3 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x+1,y=pos.y,z=pos.z}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x+1,y=pos.y,z=pos.z})
|
||||
end
|
||||
elseif number_side_to_sand ==4 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x-1,y=pos.y,z=pos.z}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x-1,y=pos.y,z=pos.z})
|
||||
end
|
||||
elseif number_side_to_sand ==5 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x,y=pos.y,z=pos.z+1}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x,y=pos.y,z=pos.z+1})
|
||||
end
|
||||
elseif number_side_to_sand ==6 then
|
||||
if owl_tech:can_send_electro(pos,{x=pos.x,y=pos.y,z=pos.z-1}) then
|
||||
owl_tech:send_electro(pos,{x=pos.x,y=pos.y,z=pos.z-1})
|
||||
end
|
||||
elseif number_side_to_sand ==-1 then
|
||||
return
|
||||
-------------------------------------------
|
||||
--chek can send fluid in pipe\mashine
|
||||
function owl_tech.can_send_electro_in_node(meta,pos_send)
|
||||
local meta_send = minetest.get_meta(pos_send)
|
||||
if owl_tech:get_voltage(meta)== owl_tech:get_voltage(meta_send)then-- if == voltage
|
||||
if owl_tech:get_charge(meta)>0
|
||||
and owl_tech:get_charge_max(meta_send)-owl_tech:get_charge(meta_send)>=owl_tech:get_voltage(meta_send) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
-------------------------------------------
|
||||
--send fluid in pos by pipe
|
||||
function owl_tech.send_electro_from_wire_in_pos(meta,pos_send)
|
||||
local meta_send = minetest.get_meta(pos_send)
|
||||
owl_tech:set_charge(meta,owl_tech:get_charge(meta)-owl_tech:get_voltage(meta))--sender
|
||||
owl_tech:set_charge(meta_send,owl_tech:get_charge(meta_send)+owl_tech:get_voltage(meta_send))--resiver
|
||||
end
|
||||
-------------------------------------------
|
||||
--send for all sides in 1 tick
|
||||
function owl_tech.send_for_all_sides_wire_electro(meta,pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local side_andres = owl_tech.get_need_wire_to_sand_electro(pos,meta)
|
||||
--+Y
|
||||
if side_andres==1 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y+1,z=pos.z})
|
||||
end
|
||||
end
|
||||
---Y
|
||||
if side_andres==2 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y-1,z=pos.z})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
end
|
||||
--+X
|
||||
if side_andres==3 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x+1,y=pos.y,z=pos.z})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x+1,y=pos.y,z=pos.z})
|
||||
end
|
||||
end
|
||||
---X
|
||||
if side_andres==4 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x-1,y=pos.y,z=pos.z})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x-1,y=pos.y,z=pos.z})
|
||||
end
|
||||
end
|
||||
--+Z
|
||||
if side_andres==5 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y,z=pos.z+1})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y,z=pos.z+1})
|
||||
end
|
||||
end
|
||||
---Z
|
||||
if side_andres==6 then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y,z=pos.z-1})
|
||||
if can_do then
|
||||
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y,z=pos.z-1})
|
||||
end
|
||||
end
|
||||
end
|
||||
-------------------------------------------
|
||||
--get need pipe to send
|
||||
function owl_tech.get_need_wire_to_sand_electro(pos,meta)
|
||||
local all_sede_table ={}
|
||||
all_sede_table[1]=math.huge
|
||||
all_sede_table[2]=math.huge
|
||||
all_sede_table[3]=math.huge
|
||||
all_sede_table[4]=math.huge
|
||||
all_sede_table[5]=math.huge
|
||||
all_sede_table[6]=math.huge
|
||||
--+Y
|
||||
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(minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[1]= owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z}))
|
||||
end
|
||||
end
|
||||
---Y
|
||||
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(minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y-1,z=pos.z})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[2]= owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z}))
|
||||
end
|
||||
end
|
||||
--+X
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})).name,"owl_tech_electro_wire")>0
|
||||
and owl_tech:get_charge(minetest.get_meta({x=pos.x+1,y=pos.y,z=pos.z}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x+1,y=pos.y,z=pos.z})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[3]= owl_tech:get_charge(minetest.get_meta({x=pos.x+1,y=pos.y,z=pos.z}))
|
||||
end
|
||||
end
|
||||
---X
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})).name,"owl_tech_electro_wire")>0
|
||||
and owl_tech:get_charge(minetest.get_meta({x=pos.x-1,y=pos.y,z=pos.z}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x-1,y=pos.y,z=pos.z})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[4]= owl_tech:get_charge(minetest.get_meta({x=pos.x-1,y=pos.y,z=pos.z}))
|
||||
end
|
||||
end
|
||||
--+Z
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})).name,"owl_tech_electro_wire")>0
|
||||
and owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+1}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y,z=pos.z+1})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[5]= owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+1}))
|
||||
end
|
||||
end
|
||||
---Z
|
||||
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})).name,"owl_tech_electro_wire")>0
|
||||
and owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z-1}))<owl_tech:get_charge(meta) then
|
||||
local can_do =owl_tech.can_send_electro_in_node(meta,{x=pos.x,y=pos.y,z=pos.z-1})
|
||||
if can_do then -- remove_amount
|
||||
all_sede_table[6]= owl_tech:get_charge(minetest.get_meta({x=pos.x,y=pos.y,z=pos.z-1}))
|
||||
end
|
||||
end
|
||||
local side_andres =-1
|
||||
local min = math.huge
|
||||
for i = 1, #all_sede_table do
|
||||
if min > all_sede_table[i] then
|
||||
min = all_sede_table[i]
|
||||
side_andres =i
|
||||
end
|
||||
end
|
||||
return side_andres
|
||||
end
|
|
@ -24,49 +24,31 @@ minetest.register_node("owl_tech:copper_electro_wire",{
|
|||
connect_back = {-0.125,-0.125,-0.125,0.125,0.125,0.5} ,
|
||||
connect_right = {-0.125,-0.125,-0.125,0.5,0.125,0.125} ,
|
||||
},
|
||||
connects_to = {"group:owl_tech_electro_wire","owl_tech_electro_mashine","owl_tech_electro_gen"},
|
||||
connects_to = {"group:owl_tech_electro_wire","group:owl_tech_electro_mashine","group:owl_tech_electro_gen"},
|
||||
sounds = mcl_sounds.node_sound_wool_defaults(),
|
||||
_mcl_hardness = 0.1,
|
||||
_mcl_blast_resistance = 0.1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
owl_tech:prepear_vire(pos,32)
|
||||
owl_tech.check_all_side_for_wire_work(pos,meta)
|
||||
owl_tech.update_wire_around(pos)
|
||||
local timer =minetest.get_node_timer(pos)
|
||||
owl_tech:look_around_for_wire(pos)
|
||||
--update wire around
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
end
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x,y=pos.y,z=pos.z+1})
|
||||
end
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x,y=pos.y,z=pos.z-1})
|
||||
end
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x+1,y=pos.y,z=pos.z})
|
||||
end
|
||||
if minetest.get_node_group(minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}),"group:owl_tech_electro_wire") then
|
||||
owl_tech:look_around_for_wire({x=pos.x-1,y=pos.y,z=pos.z})
|
||||
end
|
||||
--------------------
|
||||
|
||||
meta:set_string("infotext", owl_tech:get_charge(meta))
|
||||
timer:start(0.2)
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
owl_tech:look_around_for_wire(pos)
|
||||
|
||||
if meta:get_int("connect_amount")>0 then
|
||||
owl_tech:send_to_side_electro(pos)
|
||||
if owl_tech:get_charge(meta)>0 then
|
||||
owl_tech.send_for_all_sides_wire_electro(meta,pos)
|
||||
end
|
||||
|
||||
|
||||
meta:set_string("infotext", owl_tech:get_charge(meta))
|
||||
local timer =minetest.get_node_timer(pos)
|
||||
timer:start(0.2)
|
||||
end
|
||||
end,
|
||||
--[[after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
|
||||
end]]
|
||||
})
|
||||
--Crafte iron fluid pipe
|
||||
minetest.register_craft({
|
||||
|
|
|
@ -109,7 +109,6 @@ minetest.register_node("owl_tech:crops",{
|
|||
meta:set_string('crop1',string.gsub(meta:get_string("crop1"),"owl_tech:",''))
|
||||
meta:set_string('crop2',string.gsub(meta:get_string("crop2"),"owl_tech:",''))
|
||||
|
||||
minetest.chat_send_all(meta:get_string("crop1").." "..meta:get_string("crop2"))
|
||||
if CROPS_BREED[meta:get_string("crop1")..meta:get_string("crop2")] then
|
||||
meta:set_int("state",3)
|
||||
meta:set_string("grow_in",CROPS_BREED[meta:get_string("crop1")..meta:get_string("crop2")][2])
|
||||
|
|
3
init.lua
3
init.lua
|
@ -20,5 +20,6 @@ if i3_name~=nil then
|
|||
end
|
||||
dofile(path .. "/multiblocks/init.lua") --Multi-nodes
|
||||
dofile(path .. "/farming/init.lua") --Farming
|
||||
dofile(path .. "/electro_wire/init.lua")--electro_vire electro_generator/init.lua
|
||||
dofile(path .. "/electro_wire/init.lua")--electro_vire
|
||||
dofile(path .. "/electro_generator/init.lua")--electro generator
|
||||
dofile(path .. "/battery/init.lua")-- all electro battaries
|
|
@ -165,7 +165,6 @@ minetest.register_node("owl_tech:bronze_pump", {
|
|||
owl_tech.reset_z_pump(meta)
|
||||
owl_tech.add_y_pump(meta)
|
||||
end
|
||||
--minetest.chat_send_all(minetest.get_node(new_pos).name)
|
||||
if (minetest.get_node(new_pos).name)=="mclx_core:river_water_source" or (minetest.get_node(new_pos).name)=="mcl_core:water_source" or (minetest.get_node(new_pos).name)=="mcl_core:lava_source" then
|
||||
if (owl_tech.get_pull_fluid_name(meta,2)=='none' or owl_tech.get_pull_fluid_name(meta,2)=='mcl_core:water_source' or owl_tech.get_pull_fluid_name(meta,2)=='mclx_core:river_water_source' or (minetest.get_node(new_pos).name)=="mcl_core:lava_source")
|
||||
and owl_tech.get_pull_max_volume(meta,2)-owl_tech.get_pull_volume(meta,2)>=1000 then
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 816 B |
Binary file not shown.
After Width: | Height: | Size: 816 B |
Loading…
Reference in New Issue