Farming: Add support for meshoptions
parent
3012b0117d
commit
0d3ac2c55b
|
@ -30,6 +30,7 @@ These are the arguments (note that most arguments are required):
|
|||
* `tooltip_stage_1`: Translatable tooltip for the stage 1 node (describe here how the seed grows)
|
||||
* `description_general`: Description for other stage nodes (2-4). This string must have "@1" in it which will be replaced with the stage number.
|
||||
The recommended writing style is `"Whatever Plant (stage @1)"`.
|
||||
* `meshoptions`: If set, set the `paramtype2` to `"meshoptions"` and `place_param2` to the value of this argument
|
||||
* `drop_stages`: Optional. Table indexed by stage. Each of these keys has a value which is an optional node drop definition table.
|
||||
* `stage_extras`: Optional. Table indexed by stage numbers. Each of these keys has a table as a value. In that table, you can list
|
||||
things you would like to add to a node definition table for that stage, for example, adding `walkable = true`.
|
||||
|
|
|
@ -62,6 +62,11 @@ function farming.register_plant_nodes(name, def)
|
|||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5+(4/16), 0.5}
|
||||
}
|
||||
local paramtype2, place_param2
|
||||
if def.meshoptions then
|
||||
paramtype2 = "meshoptions"
|
||||
place_param2 = def.meshoptions
|
||||
end
|
||||
|
||||
local defs = {}
|
||||
defs[1] = {
|
||||
|
@ -72,6 +77,8 @@ function farming.register_plant_nodes(name, def)
|
|||
inventory_image = def.texture_prefix.."_seed.png",
|
||||
wield_image = def.texture_prefix.."_seed.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = paramtype2,
|
||||
place_param2 = place_param2,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
floodable = true,
|
||||
|
@ -92,6 +99,8 @@ function farming.register_plant_nodes(name, def)
|
|||
inventory_image = def.texture_prefix.."_"..s..".png",
|
||||
wield_image = def.texture_prefix.."_"..s..".png",
|
||||
paramtype = "light",
|
||||
paramtype2 = paramtype2,
|
||||
place_param2 = place_param2,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
floodable = true,
|
||||
|
@ -190,15 +199,16 @@ end
|
|||
-- Returns true if plant has grown, false if not (e.g. because of max stage)
|
||||
function farming.next_stage(pos, plant_name)
|
||||
local my_node = minetest.get_node(pos)
|
||||
local p2 = my_node.param2
|
||||
|
||||
if my_node.name == plant_name .. "_1" then
|
||||
minetest.set_node(pos, {name = plant_name .. "_2"})
|
||||
minetest.set_node(pos, {name = plant_name .. "_2", param2 = p2})
|
||||
return true
|
||||
elseif my_node.name == plant_name .. "_2" then
|
||||
minetest.set_node(pos, {name = plant_name .. "_3"})
|
||||
minetest.set_node(pos, {name = plant_name .. "_3", param2 = p2})
|
||||
return true
|
||||
elseif my_node.name == plant_name .. "_3" then
|
||||
minetest.set_node(pos, {name = plant_name .. "_4"})
|
||||
minetest.set_node(pos, {name = plant_name .. "_4", param2 = p2})
|
||||
|
||||
-- Stop the timer on the node so no more growing occurs until needed
|
||||
|
||||
|
|
Loading…
Reference in New Issue