Accurate YI Switch Block Behavior (Fix included)
Posted: Mon Nov 28, 2022 6:30 am
The YI Switch blocks in SMBX2 work on a P-switch-activated toggle, when their behavior from the original game has them set to an invisible timer (like the effects of a traditional P-switch). A similar thread on the subject was made a while back explaining the same thing:
viewtopic.php?t=27548
For anyone similar looking for a solution, check deice's post below.
Include his script in a custom lua file, then drop it in "levelname"/blocks/ai, where "levelname" is the folder for the level you want to use the blocks in.
Make two custom blocks with adjacent ID numbers, then copy the code from block-689.lua & block-690.lua into them. Copy the sprites for the blocks too, rename them to the IDs of your custom blocks, and everything should work fine.
Old topic:
viewtopic.php?t=27548
For anyone similar looking for a solution, check deice's post below.
Include his script in a custom lua file, then drop it in "levelname"/blocks/ai, where "levelname" is the folder for the level you want to use the blocks in.
Make two custom blocks with adjacent ID numbers, then copy the code from block-689.lua & block-690.lua into them. Copy the sprites for the blocks too, rename them to the IDs of your custom blocks, and everything should work fine.
Old topic:
I don't know much about lua or coding but I figured a fix for this behavior wouldn't be too hard. The scripts for the relevant blocks both seem to only have one line in them of note.
block-689.luablock-690.luaCode: Select all
pswitch.registerSet(blockID + 1, blockID) return block
I gather it means that when a p-switch (or another object that uses p-switch behavior) is activated, the blocks just increment their IDs so that they change into the other.Code: Select all
pswitch.registerSet(blockID - 1, blockID) return block
I tried looking for other p-switch related code in different scripts, but most of the new features in SMBX2 that revolve around p-switch use are toggle-based instead of timer-based. What should I be doing here, is this something easy to change or a bit more complicated? Could someone give me an example of code that uses the typical timer-based P-switch behavior?