Add copper input pipe for sorting item

This commit is contained in:
ConfidentOwl 2023-02-05 15:23:27 +03:00
parent cbb6f6cfcd
commit e173a6e1f7
5 changed files with 105 additions and 8 deletions

View File

@ -1,5 +1,4 @@
--all logick of item (pipe for item dont puy hear)
--list for input itemslot
--all logick of item
--settera and geters for calculate item_redines (always max -100)
function owl_tech.get_item_redines(meta)
return meta:get_int("_redines")
@ -25,7 +24,6 @@ function owl_tech.set_item_pipe_logick(meta)
inv:set_size("pipe_inv", 1)
end
----------------------------------------------
--get item from inventory to pipe
function owl_tech.finde_inventory_slot_for_removing_item_around(pos)
local mass_pos ={
@ -44,11 +42,19 @@ function owl_tech.finde_inventory_slot_for_removing_item_around(pos)
local meta_source = minetest.get_meta(mass_pos[i])
local inv_sourc = meta_source:get_inventory()
if inv:is_empty("pipe_inv") and not inv_sourc:is_empty(OUTPUT_SLOT_NAME[j]) then
if inv:room_for_item("pipe_inv", inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1)) then
if inv:room_for_item("pipe_inv", inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1)) and meta:get_int("has_filte")==0 then-- no filters
inv:add_item("pipe_inv", inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1))
inv_sourc:set_stack(OUTPUT_SLOT_NAME[j],1,'')
do return end
end
if inv:room_for_item("pipe_inv", inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1)) and meta:get_int("has_filte")==1 then-- filters
local filte_stack = inv:get_stack("filte_itemsteack", 1)
if filte_stack:get_name()== (inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1)):get_name() then
inv:add_item("pipe_inv", inv_sourc:get_stack(OUTPUT_SLOT_NAME[j], 1))
inv_sourc:set_stack(OUTPUT_SLOT_NAME[j],1,'')
do return end
end
end
end
end
end
@ -94,7 +100,6 @@ function owl_tech.finde_pipe_and_send_item(pos)
}
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
--for i, value in ipairs(mass_pos) do
local rand = math.random(1,6)
if minetest.get_item_group((minetest.get_node(mass_pos[rand])).name,"owl_tech_can_pipe_output")>0 then
local meta_source = minetest.get_meta(mass_pos[rand])

View File

@ -877,11 +877,11 @@ for i = 1, #table_all_machines, 1 do
"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].."wood planter"))).."]"..
"list[context;sapling;5.5,1.5;1,1;]"..
"list[context;it_sapling;5.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(5.5,1.5,1,1)..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", (max_charge.."--"..curent_charge.."--"..table_all_machines[i][3]))).."]"..
"label[0,2.5;"..minetest.formspec_escape(minetest.colorize("#313131", (delay.."--delay"))).."]"..
"listring[context;sapling]"..
"listring[context;it_sapling]"..
"listring[current_player;main]"..
"listring[current_player;main]"..
"listring[current_player;main]"
@ -923,7 +923,7 @@ for i = 1, #table_all_machines, 1 do
local inv = meta:get_inventory()
local fluid_its = inv:get_stack('it_sapling', 1)
if meta:get_int("work_delay")==0 and owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta)
and minetest.get_item_group((fluid_its:get_name()),"it_sapling")>0 then
and minetest.get_item_group((fluid_its:get_name()),"sapling")>0 then
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)
owl_tech:set_charge(meta,steam_new)
owl_tech.look_for_place_new_sapling(pos)

View File

@ -31,6 +31,7 @@ minetest.register_node("owl_tech:iron_item_pipe_input",{
_mcl_blast_resistance = 0.1,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("has_filte",0)
local inv= meta:get_inventory()
local itemstack = inv:get_stack("pipe_inv", 1)
owl_tech.set_item_pipe_logick(meta)
@ -194,4 +195,95 @@ minetest.register_craft({
{"","",""},
{"","",""}
}
})
-----------------------------------------------------------
-- Copper item pipe ( add simple filter )
local function set_formspect_copper_pipe(meta)
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)..
"list[context;filte_itemsteack;2.5,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,2.5,1,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Copper pipe"))).."]"..
"label[0,0.5;"..minetest.formspec_escape(minetest.colorize("#313131", ("Filte - input only this item"))).."]"..
"listring[context;filte_itemsteack]"..
"listring[current_player;main]"..
"listring[current_player;main]"..
"listring[current_player;main]"
meta:set_string("formspec", formspec)
end
minetest.register_node("owl_tech:copper_item_pipe_input",{
description = "Item input pipe tire 2",
_tt_help = S("Input items in pipe systems and simple filter by name (name take from item in inventory)"),
_doc_items_longdesc = S("Use for input items in pipe "),
_doc_items_usagehelp = S("Put it in the world to start pulling items from inventory."),
tiles = {"(owl_tech_base_fluid_pipe.png^[colorize:#0066ff:128)^owl_tech_base_fluid_pipe_copper_parts.png"},
paramtype = "light",
is_ground_content = false,
stack_max = 64,
sunlight_propagates = true,
walkable = true,
groups = {owl_tech_item_pipe=1},
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {-0.125,-0.125,-0.125,0.125,0.125,0.125} ,
connect_top = {-0.125,-0.125,-0.125,0.125,0.5,0.125} ,
connect_bottom = {-0.125,-0.5,-0.125,0.125,0.125,0.125} ,
connect_front = {-0.125,-0.125,-0.5,0.125,0.125,0.125} ,
connect_left = {-0.5,-0.125,-0.125,0.125,0.125,0.125} ,
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_item_pipe","group:owl_tech_generator","group:owl_tech_machine","mcl_chests:chest_small"},
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)
meta:set_int("has_filte",1)
local inv= meta:get_inventory()
local itemstack = inv:get_stack("pipe_inv", 1)
local filte_itemstack = inv:get_stack("filte_itemsteack",1)
owl_tech.set_item_pipe_logick(meta)
local info_set =("empty")
if not itemstack:is_empty() and not filte_itemstack:is_empty() then
info_set = (itemstack:get_name().."-"..itemstack:get_count())
end
meta:set_string("infotext", info_set)
set_formspect_copper_pipe(meta)
inv:set_size("filte_itemsteack",1)
local timer =minetest.get_node_timer(pos)
timer:start(0.2)
end,
on_timer = function (pos, elapsed)
local meta = minetest.get_meta(pos)
local inv= meta:get_inventory()
local itemstack = inv:get_stack("pipe_inv", 1)
local filte_itemstack = inv:get_stack("filte_itemsteack",1)
local timer =minetest.get_node_timer(pos)
owl_tech.finde_pipe_and_send_item(pos)
local info_set =("empty")
if not itemstack:is_empty() then
info_set = (itemstack:get_name().."-"..itemstack:get_count())
end
owl_tech.finde_inventory_slot_for_removing_item_around(pos)
set_formspect_copper_pipe(meta)
meta:set_string("infotext", info_set)
timer:start(0.2)
end
})
--Crafte input pipe
minetest.register_craft({
type = "shaped",
output ="owl_tech:iron_item_pipe_input",
recipe = {
{"owl_tech:copper_plate","mesecons_pistons:piston_normal_off","owl_tech:copper_plate"},
{"","",""},
{"","",""}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB