WohlSoft / LunaLua

LunaLua - LunaDLL with Lua, is a free extension mod for SMBX 1.3 game engine, core of the X2 project.
https://codehaus.moe/
GNU General Public License v3.0
33 stars 12 forks source link

The key presses of cloned players can be modified with Player.keys #29

Closed Supermario1313 closed 3 years ago

Supermario1313 commented 3 years ago

For some reason, the keys of cloned players are set to the first player's keys in the clown car subroutine, which happens after onTick. Because of that, the cloned players will always mimic player 1, even if their keys are modified during onInputUpdate. To fix this issue, I patched the clown car subroutine to skip the key updating code and I rewrote it in the UpdateInputFinishHook procedure to make sure it is executed right before onInputUpdate.

Example using the supermario4 cheat code and the following lua code:

function onInputUpdate()
    if Player.count() > 2 then
        Player(3).keys.right = KEYS_PRESSED
    end
end

Before: 2021-08-01_03_54_36

After: 2021-08-01_04_04_11

Bluenaxela commented 3 years ago

Nice work, this looks good. Only super minor issue in the changes looks to be it's using tab characters in place of spaces, mixing the indentation types in the files.

Supermario1313 commented 3 years ago

Fixed