Add fluid separator

This commit is contained in:
ConfidentOwl 2023-02-16 21:06:54 +03:00
parent f2bef40bea
commit 33f7fd586b
5 changed files with 276 additions and 10 deletions

View File

@ -17,6 +17,18 @@ function owl_tech.can_macaerat_recips_go_in_this_mashien(meta,name,dst_its,dst_a
return ret
end
--------------------------------
-- Fluid separator recips func
function owl_tech.can_fluid_separator_recips_go_in_this_mashien(meta,name,fluid1_amount,fluid2_name,fluid2_amount,fluid3_name,fluid3_amount,pull_max2,pull_max3) -- chek for tire , and slots for free space for res and add res
local ret =false
if FLUID_SEPARATOR[name][2]<=owl_tech.get_mashine_tire(meta)
and (FLUID_SEPARATOR[name][1]<=fluid1_amount)
and (fluid2_name=="none" or(fluid2_name==FLUID_SEPARATOR[name][3] and fluid2_amount+FLUID_SEPARATOR[name][4]<=pull_max2))
and (fluid3_name=="none" or(fluid3_name==FLUID_SEPARATOR[name][7] and fluid3_amount+FLUID_SEPARATOR[name][8]<=pull_max3)) then
ret =true
end
return ret
end
--------------------------------
-- sieve recips func
function owl_tech.can_siev_recips_go_in_this_mashien(meta,name,dst_its,dst_add_its) -- chek for tire , and slots for free space for res and add res
local ret =false

View File

@ -27,6 +27,7 @@ local ingot_duration = 4
local smel_metal_duration = 4
local biomassa_duration =4
local mixer_durtation= 2
local fluid_separatopr = 2
-- key-input_name ----1)input_amount 2)recip_tire 3)output_name 4)output_amount 5)duration(use for 100) 6)seconds_chanse(0-100) 7)output_name_second 8)output_amount_second 9)Input full name
-- minus 10 key
@ -67,6 +68,10 @@ MACERATO_RECIPS = {
birchtree = {(1),(1),("owl_tech:wood_dust"),(1),(biomassa_duration),(25),("owl_tech:biomassa"),(0),("mcl_core:birchtree")},
jungletree = {(1),(1),("owl_tech:wood_dust"),(1),(biomassa_duration),(25),("owl_tech:biomassa"),(0),("mcl_core:jungletree")},
}
FLUID_SEPARATOR={
tar_source = {(100),(2),("owl_tech:metan_source"),(75),(fluid_separatopr),(0),("none"),(0),("mcl_core:tar_source")},
}
-- key-input_name ----1)1 input amount 2)2 input amount 3)output name 4)output amount 5)recipt tire 6)duration(use for 100) 7)name 1 input 8)name 2 input
SMELTER_RECIPS={
tin_ingotcopper_ingot={(1),(3),("owl_tech:bronze_ingot"),(4),(1),(smel_metal_duration),'owl_tech:tin_ingot','owl_tech:copper_ingot'},

View File

@ -4,11 +4,11 @@ local path = minetest.get_modpath(name)
--[[USE for get tire machine 1)Name 2)name 3)voltage 4)max_charge 5)color_code 6)metal name for crafte 7)has_macerator 8)help item list 9)has_alloy_smeter
10)has_siev 11)has_furnance 12)forge hammer 13)has vertical miner 14)delay verticalminer 15)has quarry 16 )distance quarry 17)wood planter 18)wood_chopper 19)distance
20)seed planter 21)seed harvester 22)has mixer]]
20)seed planter 21)seed harvester 22)has mixer 23)Fluid separartor]]
local table_all_machines={
{"Base","base",32,1600,"#575757","steel",true,{"owl_tech:diamond","owl_tech:copper_heat_element","owl_tech:steel_mesh","mesecons_pistons:piston_normal_off","owl_tech:bronze_sharp_blade"},true,true
,true,true,true,18,true,16,true,true,2,true,true,true}
,true,true,true,18,true,16,true,true,2,true,true,true,true}
}
for i = 1, #table_all_machines, 1 do
@ -1380,4 +1380,260 @@ for i = 1, #table_all_machines, 1 do
}
})
end
if table_all_machines[i][23]then
local function set_formspect_base_fluid_separator(meta)
local max_charge = owl_tech:get_charge_max(meta)
local curent_charge = owl_tech:get_charge(meta)
local redines = owl_tech.get_item_redines(meta)
local fluid_1_name = owl_tech.get_pull_fluid_name(meta,1)
local fluid_2_name = owl_tech.get_pull_fluid_name(meta,2)
local fluid_3_name = owl_tech.get_pull_fluid_name(meta,3)
local fluid_1_volume = owl_tech.get_pull_volume(meta,1)
local fluid_2_volume = owl_tech.get_pull_volume(meta,2)
local fluid_3_volume = owl_tech.get_pull_volume(meta,3)
local formspec = "size[9,8.75]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.25,0;"..minetest.formspec_escape(minetest.colorize("#313131", S( table_all_machines[i][1].." fluid separator"))).."]"..
"label[0,2;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_1_name.."--"..fluid_1_volume))).."]"..
"label[0,3;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_2_name.."--"..fluid_2_volume))).."]"..
"label[4,2;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_3_name.."--"..fluid_3_volume))).."]"..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", (max_charge.."--"..curent_charge.."--"..table_all_machines[i][3]))).."]"..
"label[8,2;"..minetest.formspec_escape(minetest.colorize("#313131", (redines.." / 100"))).."]"..
"listring[current_player;main]"..
"listring[current_player;main]"..
"listring[current_player;main]"
meta:set_string("formspec", formspec)
end
--base macerator
minetest.register_node("owl_tech:"..table_all_machines[i][2].."_fluid_separtor", {
description = S(table_all_machines[i][1].."fluid separator"),
_doc_items_longdesc = S("Separate fluid and gas (tire"..i..") ,main output - botom ,second output - left and right"),
tiles = {
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^owl_tech_steam_input.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^owl_tech_steam_output.png",
"owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128^owl_tech_steam_output.png",
"owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128^owl_tech_steam_output.png",
"owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128^owl_tech_steam_input.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^owl_tech_macerator_face.png",
},
is_ground_content = false,
stack_max = 64,
groups = {pickaxey=2, owl_tech_machine=1,dst=1,dst_add=1,owl_tech_electro_mashine=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:add_electro(pos,table_all_machines[i][3],table_all_machines[i][4])
owl_tech.set_mashine_tire(meta,i+1) --all steam mishine has 1 tire
owl_tech.reset_item_redines(meta)
meta:set_int("eat_in_tick",0)
meta:set_int("bonus",0)
owl_tech.add_new_pull(meta,table_all_machines[i][4],1,0) --1 input
owl_tech.add_new_pull(meta,table_all_machines[i][4],0,1) --2 output
owl_tech.add_new_pull(meta,table_all_machines[i][4],0,1) --3 add output
set_formspect_base_fluid_separator(meta)
local timer =minetest.get_node_timer(pos)
timer:start(0.2)
end,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
local fluid_1_name = owl_tech.get_pull_fluid_name(meta,1)
local fluid_2_name = owl_tech.get_pull_fluid_name(meta,2)
local fluid_3_name = owl_tech.get_pull_fluid_name(meta,3)
local fluid_1_volume = owl_tech.get_pull_volume(meta,1)
local fluid_2_volume = owl_tech.get_pull_volume(meta,2)
local fluid_3_volume = owl_tech.get_pull_volume(meta,3)
if fluid_1_name~="none" then -- chek for item in slots
local name =string.sub(fluid_1_name, 10)
if FLUID_SEPARATOR[name]~=nil and owl_tech.get_item_redines(meta)>0 and owl_tech.get_item_redines(meta)<100 then --recipt real
if owl_tech.can_fluid_separator_recips_go_in_this_mashien(meta,name,fluid_1_volume,fluid_2_name,fluid_2_volume,fluid_3_name,fluid_3_volume,table_all_machines[i][4],table_all_machines[i][4]) then-- chek for all itemslot and machine tire
local steam_new =owl_tech:get_charge(meta)-meta:get_int("eat_in_tick")
owl_tech:set_charge(meta,steam_new)
owl_tech.add_item_redines(meta,meta:get_int("bonus"))
end
elseif FLUID_SEPARATOR[name]~=nil and owl_tech.get_item_redines(meta)>=100 then
if owl_tech.can_fluid_separator_recips_go_in_this_mashien(meta,name,fluid_1_volume,fluid_2_name,fluid_2_volume,fluid_3_name,fluid_3_volume,table_all_machines[i][4],table_all_machines[i][4]) then-- chek for all itemslot and machine tire
owl_tech.set_pull_volume(meta,1,fluid_1_volume-FLUID_SEPARATOR[name][1])
if fluid_2_name~='none' then--main fluid
owl_tech.set_pull_volume(meta,2,fluid_2_volume+FLUID_SEPARATOR[name][4])
else
owl_tech.set_pull_volume(meta,2,fluid_2_volume+FLUID_SEPARATOR[name][4])
owl_tech.set_pull_fluid_name(meta,2,FLUID_SEPARATOR[name][3])
end
local random = math.random(1,100)
if FLUID_SEPARATOR[name][6]>random then --second output
if fluid_3_name~='none' then
owl_tech.set_pull_volume(meta,3,fluid_3_volume+FLUID_SEPARATOR[name][8])
else
owl_tech.set_pull_volume(meta,3,fluid_3_volume+FLUID_SEPARATOR[name][8])
owl_tech.set_pull_fluid_name(meta,3,FLUID_SEPARATOR[name][7])
end
end
meta:set_int("eat_in_tick",0)
meta:set_int("bonus",0)
owl_tech.reset_item_redines(meta)
end
elseif FLUID_SEPARATOR[name]~=nil and 100/FLUID_SEPARATOR[name][5]*12<= owl_tech:get_charge(meta) and owl_tech.get_item_redines(meta)==0 then --begin for work
local amount=owl_tech.calculate_recipe_tire_bonus(meta,FLUID_SEPARATOR[name][2],FLUID_SEPARATOR[name][5])
meta:set_int("eat_in_tick",((100/FLUID_SEPARATOR[name][5]*12)/(100/amount)))
meta:set_int("bonus",amount)
local steam_new =owl_tech:get_charge(meta)-meta:get_int("eat_in_tick")
owl_tech:set_charge(meta,steam_new)
owl_tech.add_item_redines(meta,meta:get_int("bonus"))
end
else
owl_tech.reset_item_redines(meta)
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_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
local rotation = minetest.get_node(pos).param2 % 32 --get rotattion ( return int )
if rotation==0 then --z+1
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})).name,"fluid_pipe") then --get from pipe steam
local meta_up = minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+1})
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))
if can_do and can_do2 and inde_pull==1 then
owl_tech.add_fluid_in_node_pull(meta,fluid_name_to_send,remove_amount,inde_pull)
owl_tech.remove_fluid_in_node_pull(meta_up,remove_amount,inde_pull)
end
end
for i = -1, 1, -1 do
if minetest.get_item_group((minetest.get_node({x=pos.x+i,y=pos.y,z=pos.z})).name,"fluid_pipe") then --sand in pipe
local meta_up = minetest.get_meta({x=pos.x+i,y=pos.y,z=pos.z})
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta,3)
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
end
end
if rotation==2 then --z-1
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})).name,"fluid_pipe") then --get from pipe steam
local meta_up = minetest.get_meta({x=pos.x,y=pos.y,z=pos.z-1})
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))
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.remove_fluid_in_node_pull(meta_up,remove_amount,inde_pull)
end
end
for i = -1, 1, -1 do
if minetest.get_item_group((minetest.get_node({x=pos.x+i,y=pos.y,z=pos.z})).name,"fluid_pipe") then --sand in pipe
local meta_up = minetest.get_meta({x=pos.x+i,y=pos.y,z=pos.z})
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta,3)
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
end
end
if rotation==3 then --x+1
if minetest.get_item_group((minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})).name,"fluid_pipe") then --get from pipe steam
local meta_up = minetest.get_meta({x=pos.x-1,y=pos.y,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))
if can_do and can_do2 and inde_pull==1 then
owl_tech.add_fluid_in_node_pull(meta,fluid_name_to_send,remove_amount,inde_pull)
owl_tech.remove_fluid_in_node_pull(meta_up,remove_amount,inde_pull)
end
end
for i = -1, 1, -1 do
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z+i})).name,"fluid_pipe") then --sand in pipe
local meta_up = minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+i})
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta,3)
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
end
end
if rotation==1 then --x-1
if minetest.get_item_group((minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})).name,"fluid_pipe") then --get from pipe steam
local meta_up = minetest.get_meta({x=pos.x+1,y=pos.y,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))
if can_do and can_do2 and inde_pull==1 then
owl_tech.add_fluid_in_node_pull(meta,fluid_name_to_send,remove_amount,inde_pull)
owl_tech.remove_fluid_in_node_pull(meta_up,remove_amount,inde_pull)
end
end
for i = -1, 1, -1 do
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y,z=pos.z+i})).name,"fluid_pipe") then --sand in pipe
local meta_up = minetest.get_meta({x=pos.x,y=pos.y,z=pos.z+i})
local fluid_name_to_send = owl_tech.get_pull_fluid_name(meta,3)
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
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,3)
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,1,difer)
end
end
owl_tech.delit_name_fluid_if_0(meta)
meta:set_string("infotext",owl_tech:get_charge(meta))
set_formspect_base_fluid_separator(meta)
timer:start(0.2)
end
})
--Crafte
minetest.register_craft({
type = "shaped",
output = "owl_tech:"..table_all_machines[i][2].."_fluid_separtor",
recipe = {
{table_all_machines[i][8][2],table_all_machines[i][8][2],table_all_machines[i][8][2]},
{"owl_tech:"..table_all_machines[i][6].."_plate","owl_tech:"..table_all_machines[i][6].."_frames","owl_tech:"..table_all_machines[i][6].."_plate"},
{"owl_tech:"..table_all_machines[i][6].."_plate","owl_tech:circuit_tire_"..i,"owl_tech:"..table_all_machines[i][6].."_plate"}
}
})
end
end

View File

@ -1,13 +1,6 @@
local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
--[[
multinode = 3x5x3
frames - "owl_tech:steel_big_tiles"
entrails - "owl_tech:copper_grid"
other nodes(can replace bu hatch) - "owl_tech:tin_tiles"
need 1 input item hatch ,1 output item hatch , 1 input energy hatch , 1 output fluid hatch
]]
local function set_formspect_wood_pyrolis(meta)
local redines = owl_tech.get_item_redines(meta)

View File

@ -91,7 +91,7 @@ minetest.register_node("owl_tech:bronze_tank", {
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)
owl_tech.set_pull_volume(meta,1,difer)
end
end