Skip to content

support every paramtype2 #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2025
Merged

Conversation

The4codeblocks
Copy link
Contributor

No description provided.

end
rotation = rotation % 24

new_param2 = aux * 32 + rotation
end
Copy link
Member

@SmallJoker SmallJoker May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: You could move this code up such that a final else case could be used for return. It would effectively deduplicate the lines L38-47.

Admittedly this code does not look great (magic numbers and many different cases) but I don't see much that could be done to improve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be done

if mode == ROTATE_FACE then
rotation = rotation + 1
elseif mode == ROTATE_AXIS then
rotation = rotation + 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I use paramtype2 = "degrotate", in the nodedef of "default:aspen_sapling" (nodes.lua), the rotation oddly jumps in this case. There is no such anomaly with paramtype2 = "degrotate",.
Is it because you're using modulo 32 in L94, but modulo 24 in L101?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe the jump
(%32 is bitwise extraction, %24 is rotation modulo)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I meant that colordegorate jumps oddly whereas degrotate works well.
It turns out this code is not flawed but my perception. It simply turned too far to notice at a stationary viewing position. When following the node around in its rotation, there is no such "glitch" or "jump".
Resolved.

local axisdir = math.floor(rotationPart / 4)
local rotation = rotationPart - axisdir * 4
if mode == ROTATE_FACE then
rotationPart = axisdir * 4 + nextrange(rotation, 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luacheck is yet unhappy technic/tools/sonic_screwdriver.lua:11:16: unused function nextrange
To fix that, you could ignore the warning (I hope it's the correct code) or remove the function.

-- luacheck: push ignore 211
local function foobar()
end
-- luacheck: pop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the function

done: 150e738

@SmallJoker
Copy link
Member

Thanks. Looks good. Will merge in a few days unless there are objections.

@SmallJoker SmallJoker merged commit 85e342c into minetest-mods:master May 14, 2025
1 check passed
@The4codeblocks The4codeblocks deleted the patch-1 branch May 14, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants