According to the documentation, if on_rotate( ) returns true, the screwdriver performs the usual action. But I've attempted returning both true and false, and the screwdriver still doesn't do anything. In fact, I've even deleted everything from the callback function, returning immediately with true and no luck.If defined, called when the node is rotated using the screwdriver (from minetest_game / screwdriver mod). Screwdriver only rotates facedir nodes.Code: Select all
on_rotate = function(pos, node, player, mode, new_param2)
Returns false to avoid screwdriver actually perform the rotation (if rotation is rejected/disallowed or if on_rotate performs the rotation itself). Returns true to let screwdriver perform the rotation.
- pos — Position of the node that is being rotated.
- node — Node definition of the node that is being rotated.
- player — Reference to the Player who is using the screwdriver.
- mode — Screwdriver mode (1=Rotate face, 2=Rotate axis)
- new_param2 — New node param2 proposed by the screwdriver mod.
Briefly perusing the code, it appears (and correct me if I'm wrong) that the screwdriver definitely short circuits on false. But something very strange seems to happen otherwise: the variable should_rotate is set to false. I'm frankly not sure what purpose this variable serves since the screwdriver routine short circuits on false, so why is should_rotate even set to false when the callback returns true?
https://github.com/minetest/minetest_ga ... t.lua#L106
Code: Select all
if ndef.on_rotate then
-- Copy pos and node because callback can modify it
local result = ndef.on_rotate(vector.new(pos),
{name = node.name, param1 = node.param1, param2 = node.param2},
user, mode, new_param2)
if result == false then -- Disallow rotation
return itemstack
elseif result == true then
should_rotate = false
end
end