jtothebell / fake-08

A Pico-8 player/emulator for console homebrew
Other
563 stars 49 forks source link

Slipways game not loading due to use of local with compound assignment #148

Closed nckstwrt closed 1 year ago

nckstwrt commented 2 years ago

So the game SlipWays (https://www.lexaloffle.com/bbs/?tid=30978) has the line (at 319 in the .p8):

function jb:ol(om,a)local h=#self*8+2
local om-=h*a

^ as you can see it creates a function called ol which has parameters om and a. It then runs local om-=h*a. This will fail as local (which causes localstat to be called in lparser.c) can only handle assignment and not the new pico8 compound assignment. (Also the local variable om already exists as it's been passed as a parameter, although that should not matter)

I have tried to fix this, but utterly failed to do it nicely. Seeing as I believe the "local" here is in error and superfluous, SlipWays can be fixed by removing it (so the line will simply be "om-=h*a"). This is the only cart I've seen that does this - so might not be worth fixing - but I add this here in case anyone wants to get it running.

jtothebell commented 2 years ago

Yeah, I already have an issue for this (see #91 ) as well as a modified cart attached to it with the fix. I basically came to the same conclusion that there isn't a great way to fix it with the way compound operators are implemented in z8lua. I'm fairly sure it works in Pico-8 because it uses a preprocessor for compound operators instead of implementing them in lua. There are a couple other issues that I suspect are also because of the preprocessor (the way Pico-8 handles multiline comments, and allowing if do instead of if then) but all of these don't affect very many carts so I've been putting off fixing them.