From c8d97788c64d8cf0d43d617bb42cdd691ccb4c0b Mon Sep 17 00:00:00 2001 From: ConfidentOwl Date: Sun, 12 Feb 2023 22:18:06 +0300 Subject: [PATCH] Add seed planter --- README.md | 3 ++ api/farming.lua | 25 +++++++++- lists_of_all.lua | 26 +++++++--- mashins/electro_machins.lua | 97 ++++++++++++++++++++++++++++++++++++- 4 files changed, 141 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 53fe261..28c30ea 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,10 @@ There is a mechanics of item pipes. Item transfer only works with regular chests ## Mashins Add base steam mashine and electrick mashins ( like generators , furnance , alliy smelters and etc)The higher the level of the machine, the more new recipes are available and the machine works faster - but the consumption of energy and attracted resources also rises, which is necessary for the creation. + +all mechanisms have red and blue marks for - these are inputs and outputs for energy / liquid / items *** + ## Automation All electrical machines can be automated with the help of pipes, cables. diff --git a/api/farming.lua b/api/farming.lua index 9db5097..031179f 100644 --- a/api/farming.lua +++ b/api/farming.lua @@ -24,7 +24,8 @@ end ---------------------------------------------- --can plant plant in pos function owl_tech.can_plant_plant(pos) - if (minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})).name== "mcl_farming:soil_wet"then + if (minetest.get_node(pos)).name== "mcl_farming:soil_wet" + and minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name =="air"then return true end return false @@ -143,5 +144,25 @@ function owl_tech:look_for_trees(pos) end end - end +------------------------------------------------------------- +--Look for pos to plant +function owl_tech:look_for_place_new_sids(pos) + local meta= minetest.get_meta(pos) + local inv = meta:get_inventory() + local fluid_its = inv:get_stack('it_sapling', 1) -- + local name_seed =string.gsub(fluid_its:get_name(),"owl_tech:","") + name_seed = string.gsub(name_seed,"mcl_farming:","") + for i = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--x + for j = (meta:get_int("distance")*-1), meta:get_int("distance"), 1 do--z + if owl_tech.can_plant_plant({x=pos.x+i,y=pos.y,z=pos.z+j}) and fluid_its:get_count()>0 then + minetest.set_node({x=pos.x+i,y=pos.y+1,z=pos.z+j}, {name=CROPS_VALID[name_seed][1]}) + local inv=meta:get_inventory() + local fluid_its = inv:get_stack('it_sapling', 1) + fluid_its:set_count(fluid_its:get_count()-1) + inv:set_stack('it_sapling', 1, fluid_its) + return -- plant 1 plant for each( if plant vore - hase bug1) + end + end + end +end \ No newline at end of file diff --git a/lists_of_all.lua b/lists_of_all.lua index a10c110..ec81e9c 100755 --- a/lists_of_all.lua +++ b/lists_of_all.lua @@ -102,10 +102,24 @@ CROPS_BREED={ beetrootbeetroot={100,"owl_tech:plant_copgrow1"},--copper carrotcarrot={100,"owl_tech:plant_coaltus1"},--coal potato_itempotato_item={100,"owl_tech:plant_ironmaiden1"},--iron - plant_ironmaidenplant_coaltus={100,"owl_tech:steel_ball1"},--steel - plant_coaltusplant_ironmaiden={100,"owl_tech:steel_ball1"}, - plant_coaltusplant_coaltus={100,"owl_tech:diamond_king1"},--diamond - plant_ironmaidenplant_copgrow={100,"owl_tech:tin_plague1"},--tin - plant_copgrowplant_ironmaiden={100,"owl_tech:tin_plague1"}, - tin_plaguetin_plague={100,"owl_tech:silverr_char1"} + plant_ironmaidenplant_coaltus={100,"owl_tech:plant_steel_ball1"},--steel + plant_coaltusplant_ironmaiden={100,"owl_tech:plant_steel_ball1"}, + plant_coaltusplant_coaltus={100,"owl_tech:plant_diamond_king1"},--diamond + plant_ironmaidenplant_copgrow={100,"owl_tech:plant_tin_plague1"},--tin + plant_copgrowplant_ironmaiden={100,"owl_tech:plant_tin_plague1"}, + tin_plaguetin_plague={100,"owl_tech:plant_silverr_char1"} +} +CROPS_VALID={ + seeds_steel_ball={"owl_tech:plant_steel_ball1"}, + seeds_silverr_char={"owl_tech:plant_silverr_char1"}, + seeds_tin_plague={"owl_tech:plant_tin_plague1"}, + seeds_diamond_king={"owl_tech:plant_diamond_king1"}, + seeds_iron_maiden={"owl_tech:plant_ironmaiden1"}, + seeds_copgrow={"owl_tech:plant_copgrow1"}, + seeds_coaltus={"owl_tech:plant_coaltus1"}, + seeds_ruber_wheat={"owl_tech:plant_ruber_wheat1"}, + wheat_seeds={"mcl_farming:wheat_1"}, + beetroot_seeds={"mcl_farming:beetroot_1"}, + carrot={"mcl_farming:carrot_1"}, + potato_item={"mcl_farming:mcl_farming:potato_1"}, } \ No newline at end of file diff --git a/mashins/electro_machins.lua b/mashins/electro_machins.lua index dec48b8..ebcc047 100644 --- a/mashins/electro_machins.lua +++ b/mashins/electro_machins.lua @@ -3,11 +3,12 @@ local name = minetest.get_current_modname() 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 ]] + 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 ]] 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,18,true,16,true,true,2,true} } for i = 1, #table_all_machines, 1 do @@ -1058,4 +1059,96 @@ for i = 1, #table_all_machines, 1 do } }) end + if table_all_machines[i][20] then + local function set_formspect_seed_planter(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(table_all_machines[i][1].."seed planter"))).."]".. + "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;it_sapling]".. + "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].."_seed_planter", { + description = S(table_all_machines[i][1].." seed planter"), + _doc_items_longdesc = S("Plant seed"), + tiles = { + "(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^mcl_farming_wheat_seeds.png", + "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^mcl_farming_wheat_seeds.png", + "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^mcl_farming_wheat_seeds.png", + "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^mcl_farming_wheat_seeds.png", + "(owl_tech_base_meshanism_side.png^[colorize:"..table_all_machines[i][5]..":128)^mcl_farming_wheat_seeds.png", + }, + is_ground_content = false, + stack_max = 64, + groups = {pickaxey=2, owl_tech_machine=1,owl_tech_electro_mashine=1,it_sapling=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 + meta:set_int("work_delay",0) + set_formspect_seed_planter(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("it_sapling", 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('it_sapling', 1) + local name_seed =string.gsub(fluid_its:get_name(),"owl_tech:","") + 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) + 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:set_charge(meta,steam_new) + owl_tech:look_for_place_new_sids(pos) + meta:set_int("work_delay",table_all_machines[i][14]) + end + if meta:get_int("work_delay")>0 then + meta:set_int("work_delay",meta:get_int("work_delay")-1) + 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_seed_planter(meta) + timer:start(0.2) + end + }) + --Crafte controller + minetest.register_craft({ + type = "shaped", + output = "owl_tech:"..table_all_machines[i][2].."_wood_planter", + 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][4],"owl_tech:circuit_tire_"..i,table_all_machines[i][8][4],} + } + }) + end end \ No newline at end of file