jtothebell / fake-08

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

Indexing into strings returns NIL #198

Open flexiondotorg opened 1 year ago

flexiondotorg commented 1 year ago

While adapting my game to work with fake-08 text control codes, I also discovered fake-08 returns NIL when indexing into a string. I worked around the issue using sub(), but since PICO-08 0.2.5, using string indexes is preferred. Here's my patch:

https://github.com/wimpysworld/antsy-alien-attack-pico/commit/2aeed80b41819b1454284b2ee8eb8cd870aa4cfe

Here is a sample .p8 to reproduce the bug:

function _init()
 test="this is a test" 
end

function _draw()
 cls(0)
 print(test)
 print(sub(test,1,1))
 print(test[1])
end
jtothebell commented 1 year ago

I haven't merged this into master yet, but I think I have this working and in the mean time you're welcome to check it out in the branch: https://github.com/jtothebell/fake-08/tree/string-indexing

There are also binaries built off of that branch in the actions: https://github.com/jtothebell/fake-08/actions/runs/4716430813