Energy eat fix

This commit is contained in:
ConfidentOwl 2023-02-17 21:43:22 +03:00
parent 216b65da25
commit c79ee075cf
3 changed files with 82 additions and 29 deletions

View File

@ -47,7 +47,7 @@ function owl_tech.prepear_for_sapling_plant(pos,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,meta)
local meta= minetest.get_meta(pos) local meta= minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local fluid_its = inv:get_stack('it_sapling', 1) local fluid_its = inv:get_stack('it_sapling', 1)
@ -60,6 +60,8 @@ function owl_tech.look_for_place_new_sapling(pos)
local fluid_its = inv:get_stack('it_sapling', 1) local fluid_its = inv:get_stack('it_sapling', 1)
fluid_its:set_count(fluid_its:get_count()-1) fluid_its:set_count(fluid_its:get_count()-1)
inv:set_stack('it_sapling', 1, fluid_its) inv:set_stack('it_sapling', 1, fluid_its)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
return -- plant 1 plant for each( if plant vore - hase bug1) return -- plant 1 plant for each( if plant vore - hase bug1)
end end
end end
@ -67,7 +69,7 @@ function owl_tech.look_for_place_new_sapling(pos)
end end
------------------------------------------------ ------------------------------------------------
--get wood or leavs in slot --get wood or leavs in slot
function owl_tech.get_wood_or_leaves(pos,inv,wood_its,leaves_its) function owl_tech.get_wood_or_leaves(pos,inv,wood_its,leaves_its,meta)
if owl_tech.is_wood_in_pos(pos) if owl_tech.is_wood_in_pos(pos)
and (minetest.get_node(pos).name== wood_its:get_name() or wood_its:is_empty()) and (minetest.get_node(pos).name== wood_its:get_name() or wood_its:is_empty())
and wood_its:get_count()<64 then and wood_its:get_count()<64 then
@ -81,6 +83,8 @@ function owl_tech.get_wood_or_leaves(pos,inv,wood_its,leaves_its)
inv:set_stack('wood', 1, wood_its) inv:set_stack('wood', 1, wood_its)
end end
minetest.remove_node(pos) minetest.remove_node(pos)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
end end
if owl_tech.is_leaf_in_pos(pos) if owl_tech.is_leaf_in_pos(pos)
and( minetest.get_node(pos).name== leaves_its:get_name() or leaves_its:is_empty()) and( minetest.get_node(pos).name== leaves_its:get_name() or leaves_its:is_empty())
@ -95,11 +99,13 @@ function owl_tech.get_wood_or_leaves(pos,inv,wood_its,leaves_its)
inv:set_stack('leaves', 1, leaves_its) inv:set_stack('leaves', 1, leaves_its)
end end
minetest.remove_node(pos) minetest.remove_node(pos)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
end end
end end
------------------------------------------------ ------------------------------------------------
--looking fop trees --looking fop trees
function owl_tech:look_for_trees(pos) function owl_tech:look_for_trees(pos,meta)
local meta =minetest.get_meta(pos) local meta =minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local wood_its = inv:get_stack('wood', 1) local wood_its = inv:get_stack('wood', 1)
@ -110,7 +116,7 @@ function owl_tech:look_for_trees(pos)
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x 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 j = 1,(meta:get_int("distance")*2)+1, 1 do--z
for k = 32,0, -1 do--y 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) owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z-j},inv,wood_its,leaves_its,meta)
end end
end end
end end
@ -119,7 +125,7 @@ function owl_tech:look_for_trees(pos)
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x 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 j = 1,(meta:get_int("distance")*2)+1, 1 do--z
for k =32,0, -1 do--y 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) owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its,meta)
end end
end end
end end
@ -128,7 +134,7 @@ function owl_tech:look_for_trees(pos)
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x 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 j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
for k = 32 ,0, -1 do--y 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) owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its,meta)
end end
end end
end end
@ -137,7 +143,7 @@ function owl_tech:look_for_trees(pos)
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x 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 j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
for k = 32,0,-1 do--y 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) owl_tech.get_wood_or_leaves({x=pos.x+i,y=pos.y+k,z=pos.z+j},inv,wood_its,leaves_its,meta)
end end
end end
end end
@ -146,7 +152,7 @@ function owl_tech:look_for_trees(pos)
end end
------------------------------------------------------------- -------------------------------------------------------------
--Look for pos to plant --Look for pos to plant
function owl_tech:look_for_place_new_sids(pos) function owl_tech:look_for_place_new_sids(pos,meta)
local meta= minetest.get_meta(pos) local meta= minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local fluid_its = inv:get_stack('it_sapling', 1) -- local fluid_its = inv:get_stack('it_sapling', 1) --
@ -160,6 +166,8 @@ function owl_tech:look_for_place_new_sids(pos)
local fluid_its = inv:get_stack('it_sapling', 1) local fluid_its = inv:get_stack('it_sapling', 1)
fluid_its:set_count(fluid_its:get_count()-1) fluid_its:set_count(fluid_its:get_count()-1)
inv:set_stack('it_sapling', 1, fluid_its) inv:set_stack('it_sapling', 1, fluid_its)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
return -- plant 1 plant for each( if plant vore - hase bug1) return -- plant 1 plant for each( if plant vore - hase bug1)
end end
end end
@ -167,28 +175,77 @@ function owl_tech:look_for_place_new_sids(pos)
end end
----------------------------------------------------------------- -----------------------------------------------------------------
--Get redy plant in pos --Get redy plant in pos
function owl_tech:get_ready_plant_in_pos(pos,inv)--ready_to_harvest function owl_tech:get_ready_plant_in_pos(pos,inv,meta)--ready_to_harvest
local wood_its = inv:get_stack('wood', 1) local wood_its = inv:get_stack('wood', 1)
local leaves_its = inv:get_stack('leaves', 1) local leaves_its = inv:get_stack('leaves', 1)
local vanila_plants= {"wheat","beetroot","potato"} local vanila_plants= {"wheat","beetroot","potato"}
local crop_node=minetest.get_node(pos) local crop_node=minetest.get_node(pos)
for i = 1, #vanila_plants, 1 do for i = 1, #vanila_plants, 1 do
if minetest.get_node(pos).name ==vanila_plants[i] then if minetest.get_node(pos).name ==vanila_plants[i] then
local cut_wood = owl_tech.get_node_drop(crop_node.name,"toolname") local cut_wood = owl_tech.get_node_drop(crop_node.name,"toolname")
if ( cut_wood== wood_its:get_name() or wood_its:is_empty()) if ( cut_wood== wood_its:get_name() or wood_its:is_empty())
and wood_its:get_count()<64 then and wood_its:get_count()<64 then
if not wood_its:is_empty() then-- Add main output if not wood_its:is_empty() then-- Add main output
wood_its:set_count(wood_its:get_count()+1) wood_its:set_count(wood_its:get_count()+1)
inv:set_stack('wood', 1, wood_its) inv:set_stack('wood', 1, wood_its)
minetest.remove_node(pos)
else else
local item ={name=cut_wood, count=1, wear=0, metadata=""} local item ={name=cut_wood, count=1, wear=0, metadata=""}
wood_its:add_item(item) wood_its:add_item(item)
inv:set_stack('wood', 1, wood_its) inv:set_stack('wood', 1, wood_its)
end
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
minetest.remove_node(pos)
end
if minetest.get_node(pos).name== "wheat"then
if ("mcl_farming:wheat_item"== leaves_its:get_name() or leaves_its:is_empty())
and leaves_its:get_count()+1<=64 then
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="mcl_farming:wheat_item", count=1, wear=0, metadata=""}
leaves_its:add_item(item)
inv:set_stack('leaves', 1, leaves_its)
end
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
minetest.remove_node(pos) minetest.remove_node(pos)
end end
end end
if minetest.get_node(pos).name== "beetroot" then
if ("mcl_farming:beetroot_item"== leaves_its:get_name() or leaves_its:is_empty())
and leaves_its:get_count()+1<=64 then
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="mcl_farming:beetroot_item", count=1, wear=0, metadata=""}
leaves_its:add_item(item)
inv:set_stack('leaves', 1, leaves_its)
end
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
minetest.remove_node(pos)
end
end
if minetest.get_node(pos).name== "potato" then
if ("mcl_farming:potato_item"== leaves_its:get_name() or leaves_its:is_empty())
and leaves_its:get_count()+1<=64 then
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="mcl_farming:potato_item", count=1, wear=0, metadata=""}
leaves_its:add_item(item)
inv:set_stack('leaves', 1, leaves_its)
end
minetest.remove_node(pos)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
end
end
minetest.remove_node(pos)
@ -227,13 +284,15 @@ function owl_tech:get_ready_plant_in_pos(pos,inv)--ready_to_harvest
inv:set_stack('leaves', 1, leaves_its) inv:set_stack('leaves', 1, leaves_its)
end end
minetest.remove_node(pos) minetest.remove_node(pos)
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new)
end end
minetest.remove_node(pos) minetest.remove_node(pos)
end end
end end
------------------------------------------------------------------ ------------------------------------------------------------------
--look for plants --look for plants
function owl_tech:look_for_plants(pos) function owl_tech:look_for_plants(pos,meta)
local meta =minetest.get_meta(pos) local meta =minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local wood_its = inv:get_stack('wood', 1) local wood_its = inv:get_stack('wood', 1)
@ -243,28 +302,28 @@ function owl_tech:look_for_plants(pos)
if rotation==0 then --z-1 if rotation==0 then --z-1
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x 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 j = 1,(meta:get_int("distance")*2)+1, 1 do--z
owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z-j},inv) owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z-j},inv,meta)
end end
end end
end end
if rotation==2 then --z+1 if rotation==2 then --z+1
for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x 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 j = 1,(meta:get_int("distance")*2)+1, 1 do--z
owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z+j},inv) owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z+j},inv,meta)
end end
end end
end end
if rotation==3 then --x-1 if rotation==3 then --x-1
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x 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 j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z+j},inv) owl_tech:get_ready_plant_in_pos({x=pos.x+i,y=pos.y,z=pos.z+j},inv,meta)
end end
end end
end end
if rotation==1 then --x+1 if rotation==1 then --x+1
for i = 1,(meta:get_int("distance")*2)+1, 1 do--x 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 j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z
owl_tech:get_ready_plant_in_pos({x=pos.x-i,y=pos.y,z=pos.z-j},inv) owl_tech:get_ready_plant_in_pos({x=pos.x-i,y=pos.y,z=pos.z-j},inv,meta)
end end
end end
end end

View File

@ -940,11 +940,9 @@ for i = 1, #table_all_machines, 1 do
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local fluid_its = inv:get_stack('it_sapling', 1) 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) if meta:get_int("work_delay")==0 and owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta)/16
and minetest.get_item_group((fluid_its:get_name()),"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.look_for_place_new_sapling(pos,meta)
owl_tech:set_charge(meta,steam_new)
owl_tech.look_for_place_new_sapling(pos)
meta:set_int("work_delay",table_all_machines[i][14]) meta:set_int("work_delay",table_all_machines[i][14])
end end
if meta:get_int("work_delay")>0 then if meta:get_int("work_delay")>0 then
@ -1034,7 +1032,7 @@ for i = 1, #table_all_machines, 1 do
if owl_tech:get_charge(meta)>=(owl_tech:get_voltage(meta)/16 ) then 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 local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)/16
owl_tech:set_charge(meta,steam_new) owl_tech:set_charge(meta,steam_new)
owl_tech:look_for_trees(pos) owl_tech:look_for_trees(pos,meta)
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
@ -1118,11 +1116,9 @@ for i = 1, #table_all_machines, 1 do
local fluid_its = inv:get_stack('it_sapling', 1) local fluid_its = inv:get_stack('it_sapling', 1)
local name_seed =string.gsub(fluid_its:get_name(),"owl_tech:","") local name_seed =string.gsub(fluid_its:get_name(),"owl_tech:","")
name_seed = string.gsub(name_seed,"mcl_farming:","") name_seed = string.gsub(name_seed,"mcl_farming:","")
if meta:get_int("work_delay")==0 and owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta) if meta:get_int("work_delay")==0 and owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta)/16
and CROPS_VALID[name_seed]~=nil and CROPS_VALID[name_seed]~="" then and CROPS_VALID[name_seed]~=nil and CROPS_VALID[name_seed]~="" then
local steam_new =owl_tech:get_charge(meta)-owl_tech:get_voltage(meta) owl_tech:look_for_place_new_sids(pos,meta)
owl_tech:set_charge(meta,steam_new)
owl_tech:look_for_place_new_sids(pos)
meta:set_int("work_delay",table_all_machines[i][14]) meta:set_int("work_delay",table_all_machines[i][14])
end end
if meta:get_int("work_delay")>0 then if meta:get_int("work_delay")>0 then
@ -1210,8 +1206,6 @@ for i = 1, #table_all_machines, 1 do
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)
if owl_tech:get_charge(meta)>=(owl_tech:get_voltage(meta)/16 ) then 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)
owl_tech:look_for_plants(pos) owl_tech:look_for_plants(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 if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})).name,"owl_tech_electro_wire")>0

View File

@ -1065,7 +1065,7 @@ minetest.register_craftitem("owl_tech:water_cell", {
groups = { craftitem=1,load_cell=1 }, groups = { craftitem=1,load_cell=1 },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
minetest.place_node(pointed_thing.above,{name="owl_tech:water_source"}) minetest.place_node(pointed_thing.above,{name="mcl_core:water_source"})
itemstack:set_count(itemstack:get_count()-1) itemstack:set_count(itemstack:get_count()-1)
return itemstack return itemstack
end end
@ -1079,7 +1079,7 @@ minetest.register_craftitem("owl_tech:lava_cell", {
groups = { craftitem=1,load_cell=1 }, groups = { craftitem=1,load_cell=1 },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
minetest.place_node(pointed_thing.above,{name="owl_tech:lava_source"}) minetest.place_node(pointed_thing.above,{name="mcl_core:lava_source"})
itemstack:set_count(itemstack:get_count()-1) itemstack:set_count(itemstack:get_count()-1)
return itemstack return itemstack
end end