owl_tech/farming/crops.lua

63 lines
2.6 KiB
Lua
Raw Normal View History

2023-01-04 10:27:40 +01:00
local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
--Crops
--[[minetest.register_node("owl_tech:crops",{
description = "Crops",
_tt_help = S("Crops for grow crops"),
_doc_items_longdesc = S("Fence gates can be opened or closed and can't be jumped over. Fences will connect nicely to fence gates."),
_doc_items_usagehelp = S("Right-click the fcrops to put a seed and begin grow"),
tiles = {"mcl_core_log_big_oak.png"},
paramtype = "light",
is_ground_content = false,
stack_max = 64,
sunlight_propagates = true,
walkable = true,
groups = {owl_tech_fluid_pipe=1},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed ={{-0.45,-0.5,-0.45,-0.4,0.5,-0.4},
{-0.45,-0.5,-0.45,-0.4,0.5,-0.4},
{-0.45,-0.5,0.45,-0.4,0.5,0.4},
{0.45,-0.5,0.45,0.4,0.5,0.4}
},
},
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_string("infotext", "crops")
meta:set_int("look_around",1)
meta:set_string("pos-x", 'none')
meta:set_string("pos+x", 'none')
meta:set_string("pos-z", 'none')
meta:set_string("pos+z", 'none')
local timer =minetest.get_node_timer(pos)
timer:start(0.2)
end,
on_timer = function (pos, elapsed)
local meta = minetest.get_meta(pos)
local timer =minetest.get_node_timer(pos)
if meta:get_int("look_around") then
for i = 1, #LIST_ALL_CROPS ,1 do
if minetest.get_node({x=pos.x-1 ,y=pos.y,z=pos.z}).name == LIST_ALL_CROPS[i] then
meta:set_string("pos-x",minetest.get_node({x=pos.x-1 ,y=pos.y,z=pos.z}).name)
end
if minetest.get_node({x=pos.x+1 ,y=pos.y,z=pos.z}).name == LIST_ALL_CROPS[i] then
meta:set_string("pos+x",minetest.get_node({x=pos.x+1 ,y=pos.y,z=pos.z}).name)
end
if minetest.get_node({x=pos.x ,y=pos.y,z=pos.z-1}).name == LIST_ALL_CROPS[i] then
meta:set_string("pos-z",minetest.get_node({x=pos.x ,y=pos.y,z=pos.z-1}).name)
end
if minetest.get_node({x=pos.x ,y=pos.y,z=pos.z+1}).name == LIST_ALL_CROPS[i] then
meta:set_string("pos+z",minetest.get_node({x=pos.x ,y=pos.y,z=pos.z+1}).name)
end
end
end
timer:start(0.2)
end
})]]