Non-deterministic facedir for craft output

Craft output nodes are rotate in a random (but still
upright) direction if they're facedir, and the param2
is not specified by the recipe.  Currenly only affects
optic prisms.
This commit is contained in:
Aaron Suen 2022-04-30 22:04:26 -04:00
parent 952c1bc63e
commit 4ea48c025c
2 changed files with 9 additions and 5 deletions

View File

@ -17,9 +17,6 @@ ISSUES-GAME: Gameplay-affecting issues
rather than pre-material? rather than pre-material?
- https://discord.com/channels/507234450615042048/507234451085066248/963498043708178522 - https://discord.com/channels/507234450615042048/507234451085066248/963498043708178522
- Facedir nodes should get a random facedir (top-up, random cardinal
orientation) after crafting.
- /snuff should probably snuff torches too - /snuff should probably snuff torches too
- General snuffable/on_snuff API? - General snuffable/on_snuff API?
- Merge with growtrees for a general on_cheat API? - Merge with growtrees for a general on_cheat API?

View File

@ -144,8 +144,15 @@ local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
nodecore.stack_set(p, ItemStack("")) nodecore.stack_set(p, ItemStack(""))
end end
if r then if r then
local n = minetest.get_node(p) if not r.param2 then
r.param2 = n.param2 local rd = minetest.registered_nodes[r.name]
if rd and rd.paramtype2 == "facedir" then
r.param2 = math_random(0, 3)
else
local n = minetest.get_node(p)
r.param2 = n.param2
end
end
nodecore.set_loud(p, r) nodecore.set_loud(p, r)
nodecore.fallcheck(p) nodecore.fallcheck(p)
end end