jsbasic
jsbasic copied to clipboard
Sample adventure crashes; not completable
To repro: https://www.calormen.com/jsbasic/
- Click the Select a sample… drop down
- In the Games section, select "Text Adventure (Floyd McWilliams)"
- Click Run
- Run these commands:
- e
- u
- n
- take key
- s
- w
- w
- unlock door
- open left door (it doesn't matter which door you open)
A JS alert appears, "Illegal quantity in line 7130"

Hi, when you type "OPEN LEFT DOOR" (27 31 57) line 7120 calculates ARG using the second word number stored in INPTK(2) = 31 (LEFT) or 31 (CENTER) or 33 (RIGHT) subtracted by ITEMOFF = 33 (line 700) which translates to: ARG = 31 - 33 = -2 this happens because INPTK(2) will always be lower than ITEMOFF (=33) and it will fail on line 7130 because ILOC(ARG) translates to ILOC(-2) and arrays can't have negative indexes.
I am still debbugging it because lines 7120 and 7130 deal with both actions:
- OPEN (LEFT|CENTER|RIGHT) DOOR
- OIL DUMBWAITER OILCAN
I will submit a Pull Request when it is done. thanks
Yeah, a PR is welcome.