Add wood chopper

This commit is contained in:
ConfidentOwl 2023-02-04 20:50:53 +03:00
parent 0a06d5ea20
commit fbcc13009e
6 changed files with 223 additions and 13 deletions

View File

@ -7,6 +7,7 @@
"mcl_formspec", "mcl_formspec",
"owl_tech", "owl_tech",
"i3", "i3",
"mcl_vars" "mcl_vars",
"owl_tech_x_ray_look"
] ]
} }

View File

@ -44,7 +44,7 @@ function owl_tech.prepear_for_sapling_plant(pos,distance)
local meta= minetest.get_meta(pos) local meta= minetest.get_meta(pos)
meta:set_int("distance",distance) meta:set_int("distance",distance)
end end
---------------------------------------------- -----------------------------------------------
--looking for new sapling --looking for new sapling
function owl_tech.look_for_place_new_sapling(pos) function owl_tech.look_for_place_new_sapling(pos)
local meta= minetest.get_meta(pos) local meta= minetest.get_meta(pos)
@ -54,14 +54,94 @@ function owl_tech.look_for_place_new_sapling(pos)
for j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z for j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
if owl_tech.can_plant_sapling({x=pos.x+i,y=pos.y,z=pos.z+j}) and fluid_its:get_count()>0 if owl_tech.can_plant_sapling({x=pos.x+i,y=pos.y,z=pos.z+j}) and fluid_its:get_count()>0
and not fluid_its:is_empty() then and not fluid_its:is_empty() then
minetest.place_node({x=pos.x+i,y=pos.y+1,z=pos.z+j}, {name=fluid_its:get_name()}) minetest.set_node({x=pos.x+i,y=pos.y+1,z=pos.z+j}, {name=fluid_its:get_name()})
local inv=meta:get_inventory() local inv=meta:get_inventory()
local fluid_its = inv:get_stack('sapling', 1) local fluid_its = inv:get_stack('sapling', 1)
fluid_its:set_count(fluid_its:get_count()-1) fluid_its:set_count(fluid_its:get_count()-1)
inv:set_stack('sapling', 1, fluid_its) inv:set_stack('sapling', 1, fluid_its)
return -- plant 1 plant for each( if plant vore - hase bug) return -- plant 1 plant for each( if plant vore - hase bug1)
end end
end end
end end
end end
------------------------------------------------ ------------------------------------------------
--get wood or leavs in slot
function owl_tech.get_wood_or_leaves(pos,inv,wood_its,leaves_its)
if owl_tech.is_wood_in_pos(pos)
and (minetest.get_node(pos).name== wood_its:get_name() or wood_its:is_empty())
and wood_its:get_count()<64 then
local cut_wood = minetest.get_node(pos).name
if not wood_its:is_empty() then-- Add main output
wood_its:set_count(wood_its:get_count()+1)
inv:set_stack('wood', 1, wood_its)
else
local item ={name=cut_wood, count=1, wear=0, metadata=""}
wood_its:add_item(item)
inv:set_stack('wood', 1, wood_its)
end
minetest.remove_node(pos)
end
if owl_tech.is_leaf_in_pos(pos)
and( minetest.get_node(pos).name== leaves_its:get_name() or leaves_its:is_empty())
and leaves_its:get_count()<64 then
local cut_leaf = minetest.get_node(pos).name
if not leaves_its:is_empty() then-- Add main output
leaves_its:set_count(leaves_its:get_count()+1)
inv:set_stack('leaves', 1, leaves_its)
else
local item ={name=cut_leaf, count=1, wear=0, metadata=""}
leaves_its:add_item(item)
inv:set_stack('leaves', 1, leaves_its)
end
minetest.remove_node(pos)
end
end
------------------------------------------------
--looking frp trees
function owl_tech:look_for_trees(pos)
local meta =minetest.get_meta(pos)
local inv = meta:get_inventory()
local wood_its = inv:get_stack('wood', 1)
local leaves_its = inv:get_stack('leaves', 1)
local rotation = minetest.get_node(pos).param2 % 32 --get rotattion ( return int )
if wood_its:is_empty()or (wood_its:get_count()<64) and leaves_its:is_empty()or (leaves_its:get_count()<64) then
if rotation==0 then --z-1
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x
for j = 1,(meta:get_int("distance")*2)+1, 1 do--z
for k = 32,0, -1 do--y
owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z-j},inv,wood_its,leaves_its)
end
end
end
end
if rotation==2 then --z+1
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x
for j = 1,(meta:get_int("distance")*2)+1, 1 do--z
for k =32,0, -1 do--y
owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its)
end
end
end
end
if rotation==0 then --x-1
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x
for j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
for k = 32 ,0, -1 do--y
owl_tech.get_wood_or_leaves({x=pos.x-i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its)
end
end
end
end
if rotation==1 then --x+1
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x
for j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
for k = 32,0,-1 do--y
owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its)
end
end
end
end
end
end

View File

@ -3,10 +3,10 @@ GLOBAL_FLUID_LIST ={
"mcl_core:lava_source","mcl_core:water_source","mclx_core:river_water_source" "mcl_core:lava_source","mcl_core:water_source","mclx_core:river_water_source"
} }
INPUT_SLOT_NAME= { INPUT_SLOT_NAME= {
"fluid_in","fuel",'input_in' "fluid_in","fuel",'input_in',"sapling"
} }
OUTPUT_SLOT_NAME={ OUTPUT_SLOT_NAME={
'dst_add','dst' 'dst_add','dst',"wood","leaves"
} }

View File

@ -6,7 +6,7 @@ local path = minetest.get_modpath(name)
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 ]] 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 ]]
local table_all_machines={ 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"},true,true {"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,18,true,16,true,true,2}
} }
@ -888,11 +888,11 @@ for i = 1, #table_all_machines, 1 do
meta:set_string("formspec", formspec) meta:set_string("formspec", formspec)
end end
minetest.register_node("owl_tech:"..table_all_machines[i][2].."_wood_planter", { minetest.register_node("owl_tech:"..table_all_machines[i][2].."_wood_planter", {
description = S(table_all_machines[i][1].." quarry"), description = S(table_all_machines[i][1].." tree planter"),
_doc_items_longdesc = S("Dig the Hole"), _doc_items_longdesc = S("Dig the Hole"),
tiles = { 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_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128", "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)^default_sapling.png", "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_sapling.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_sapling.png", "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_sapling.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_sapling.png", "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_sapling.png",
@ -932,9 +932,9 @@ for i = 1, #table_all_machines, 1 do
if meta:get_int("work_delay")>0 then if meta:get_int("work_delay")>0 then
meta:set_int("work_delay",meta:get_int("work_delay")-1) meta:set_int("work_delay",meta:get_int("work_delay")-1)
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 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 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}) 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 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) owl_tech.send_electro_from_wire_in_pos(meta_up,pos)
end end
@ -955,4 +955,111 @@ for i = 1, #table_all_machines, 1 do
} }
}) })
end end
if table_all_machines[i][18] then
local function set_formspect_wood_chopper(meta)
local max_charge = owl_tech:get_charge_max(meta)
local curent_charge = owl_tech:get_charge(meta)
local delay = meta:get_int("work_delay")
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("Steam vertical miner"))).."]"..
"list[context;wood;5.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(5.5,1.5,1,1)..
"list[context;leaves;5.5,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(5.5,2.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;wood]"..
"listring[context;leaves]"..
"listring[current_player;main]"..
"listring[current_player;main]"..
"listring[current_player;main]"
meta:set_string("formspec", formspec)
end
minetest.register_node("owl_tech:"..table_all_machines[i][2].."_wood_chopper", {
description = S(table_all_machines[i][1].." tree chopper"),
_doc_items_longdesc = S("Set over a tree plantation"),
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_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_tool_steelaxe.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_tool_steelaxe.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^default_tool_steelaxe.png",
"(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)",
},
is_ground_content = false,
stack_max = 64,
groups = {pickaxey=2, owl_tech_machine=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
set_formspect_wood_chopper(meta)
owl_tech.prepear_for_sapling_plant(pos,table_all_machines[i][19])
local timer =minetest.get_node_timer(pos)
local inv = meta:get_inventory()
inv:set_size("wood", 1)
inv:set_size("leaves", 1)
timer:start(2)
end,
on_timer = function(pos, elapsed)
local meta = minetest.get_meta(pos)
local timer = minetest.get_node_timer(pos)
local inv = meta:get_inventory()
local fluid_its = inv:get_stack('wood', 1)
local fluid_its = inv:get_stack('leaves', 1)
if owl_tech:get_charge(meta)>=(owl_tech:get_voltage(meta)/16 ) then
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
local rotation = minetest.get_node(pos).param2 % 32 --get rotattion ( return int )
owl_tech:look_for_trees(pos)
--[[if rotation==1 then
minetest.place_node({x=pos.x-1,y=pos.y,z=pos.z},{name="mcl_core:ice"})
end
if rotation==2 then
minetest.place_node({x=pos.x,y=pos.y,z=pos.z+1},{name="mcl_core:ice"})
end
if rotation==3 then
minetest.place_node({x=pos.x+1,y=pos.y,z=pos.z},{name="mcl_core:ice"})
end
if rotation==0 then
minetest.place_node({x=pos.x,y=pos.y,z=pos.z-1},{name="mcl_core:ice"})
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_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
meta:set_string("infotext",owl_tech:get_charge(meta))
set_formspect_wood_chopper(meta)
timer:start(0.2)
end
})
--Crafte controller
minetest.register_craft({
type = "shaped",
output = "owl_tech:"..table_all_machines[i][2].."_wood_chopper",
recipe = {
{"owl_tech:"..table_all_machines[i][6].."_plate","owl_tech:circuit_tire_"..i,"owl_tech:"..table_all_machines[i][6].."_plate"},
{"owl_tech:"..table_all_machines[i][6].."_plate","owl_tech:"..table_all_machines[i][6].."_frames","owl_tech:"..table_all_machines[i][6].."_plate"},
{table_all_machines[i][8][5],"owl_tech:circuit_tire_"..i,table_all_machines[i][8][5],}
}
})
end
end end

View File

@ -198,7 +198,29 @@ for i, value in ipairs(metals_ore_array) do
{"owl_tech:work_mortar","owl_tech:work_mortar"}, {"owl_tech:work_mortar","owl_tech:work_mortar"},
} }
}) })
--lamp --Sharp blade
minetest.register_craftitem("owl_tech:"..metals_ore_array[i][1].."_sharp_blade", {
description = S(metals_ore_array[i][2].. " sharp blade"),
_doc_items_longdesc = S("simple and reliable sharp blade element"),
inventory_image = "owl_tech_sharp_blade.png^[colorize:"..metals_ore_array[i][5]..":128",
stack_max = 64,
groups = { craftitem=1 },
})
--Cafte Sharp blade
minetest.register_craft({
type = "shaped",
output = "owl_tech:"..metals_ore_array[i][1].."_sharp_blade 3",
recipe = {
{"owl_tech:work_hammer","owl_tech:"..metals_ore_array[i][1].."_ingot","owl_tech:"..metals_ore_array[i][1].."_ingot"},
{"owl_tech:work_file","owl_tech:"..metals_ore_array[i][1].."_ingot","owl_tech:"..metals_ore_array[i][1].."_ingot"},
{"","",""}
},
replacements = {
{"owl_tech:work_hammer", "owl_tech:work_hammer"},
{"owl_tech:work_file", "owl_tech:work_file"},
}
})
--lamp owl_tech_sharp_blade.png
minetest.register_craftitem("owl_tech:"..metals_ore_array[i][1].."_lamp", { minetest.register_craftitem("owl_tech:"..metals_ore_array[i][1].."_lamp", {
description = S(metals_ore_array[i][2].. " lamp"), description = S(metals_ore_array[i][2].. " lamp"),
_doc_items_longdesc = S("simple and reliable electrical circuit element"), _doc_items_longdesc = S("simple and reliable electrical circuit element"),

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B