marquise wrote: ↑Wed Sep 11, 2019 4:06 am
Thank you, that code got it working. I've mostly been finding out what code is what by looking at the documentation and haven't seen that code at all.
Some very good points you've made there. I shall take that on board. Thank you again.
For ducking in particular, one other solution to all these conditionals could be to use the "is ducking?" flag directly:
if player:mem(0x12E, FIELD_BOOL) then (as per
the docs)
If you're in a scenario where there's a 1:1 overlap in functionality between a source frame number and a desired frame number, you can also remap the frame directly. While for ducking there's a simple offset that can be used, too, there are other states that don't have this luxury. Consider, for example, the skidding state (where the player tries to move the opposite direction to which they previously moved. They only do it on the ground and under specific conditions, so it would be easier to just kinda cheat a little and piggyback off SMBX's decision of what frame to set:
local frameRemappingTable = {
[6] = 12, --remaps the skidding frame location from sheet position 6 to 12
[1] = 10, --another random example to showcase that this table can be expanded
}
function onTickEnd()
if frameRemappingTable[player.frame] then
player.frame = frameRemappingTable[player.frame] -- If a remap is desired, do it.
end
end