add wallTool
[df_scaffold.git] / autofarm.lua
blob124761c54249ca113f454dfb5d589ee3ae59f6ae
1 -- CC0/Unlicense Emilia 2020
3 local seeds = {
4 "mcl_farming:wheat_seeds",
5 "mcl_farming:beetroot_seeds",
6 "mcl_farming:carrot_item",
7 "mcl_farming:potato_item"
10 local nodeseeds = {
11 "mcl_farming:melon_seeds",
12 "mcl_farming:pumpkin_seeds"
15 local tillable = {
16 "mcl_core:dirt",
17 "mcl_core:dirt_with_grass",
18 "mcl_farming:soil"
21 local hoes = {
22 "mcl_farming:hoe_wood",
23 "mcl_farming:hoe_stone",
24 "mcl_farming:hoe_iron",
25 "mcl_farming:hoe_gold",
26 "mcl_farming:hoe_diamond"
29 local water = {
30 "mcl_core:water_source",
31 "mcl_buckets:bucket_water",
32 "mcl_buckets:bucket_river_water"
35 scaffold.register_template_scaffold("AutoFarm", "scaffold_farm", function(below)
36 local lp = vector.round(minetest.localplayer:get_pos())
38 -- farmland
39 if below.x % 5 ~= 0 or below.z % 5 ~= 0 then
40 if scaffold.place_if_needed(tillable, below) then
41 if scaffold.can_place_at(lp) then
42 if scaffold.find_any_swap(hoes) then
43 minetest.interact("place", below)
44 scaffold.place_if_needed(seeds, lp)
45 end
46 end
47 end
48 -- water
49 else
50 scaffold.place_if_needed(water, below)
51 end
52 end)
54 scaffold.register_template_scaffold("AutoMelon", "scaffold_melon", function(below)
55 local lp = vector.round(minetest.localplayer:get_pos())
57 local x = below.x % 5
58 local z = below.z % 5
60 -- water
61 if x == 0 and z == 0 then
62 scaffold.place_if_needed(water, below)
63 -- dirt
64 elseif z == 2 or z == 4 or ((x == 2 or x == 4) and z == 0) then
65 scaffold.place_if_needed(tillable, below)
66 -- farmland
67 elseif (x == 1 or z == 1) or (x == 3 or z == 3) then
68 if scaffold.place_if_needed(tillable, below) then
69 if scaffold.can_place_at(lp) then
70 if scaffold.find_any_swap(hoes) then
71 minetest.interact("place", below)
72 scaffold.place_if_needed(nodeseeds, lp)
73 end
74 end
75 end
76 end
77 end)