voidderef / sgl

Cross-platform scriptable game loader for selecting applications/games on dedicated machines with custom IO hardware
The Unlicense
9 stars 3 forks source link

SGL crashes when adding a 2nd key/button for a function #6

Closed BoomDivX closed 2 years ago

BoomDivX commented 2 years ago

Summary

When the user adds a 2nd button for a function in isp-attract.lua or isp-operator.lua, SGL will crash on launch with the error "unexpected symbol near |"

Expected behavior

SGL should not crash and the 2nd button should do the same function as the 1st one.

Current behavior

SGL crashes on launch.

Detailed Description

When the user adds a 2nd button for a function in isp-attract.lua or isp-operator.lua, SGL will crash on launch with the error "unexpected symbol near |". Using version 1.03 (the one on GDrive).

Steps to reproduce

  1. Edit data\lua\io\keyboard\sdl2\isp-attract.lua
  2. Find the line "dest.digital[SCREEN_ATTRACT_DI_SELECT_NEXT] = iop_input_state_is_pushed(IO_KEYBOARD_SDL2_DI_RIGHT, src, src_prev)"
  3. Add " || iop_input_state_is_pushed(IO_KEYBOARD_SDL2_DI_UP, src, src_prev)" to that line and save the file.
  4. Launch SGL.

Context (Environment)

Windows 10

Log output

https://pastebin.com/f9vwZb8P

Configuration files

data\lua\io\keyboard\sdl2\isp-attract.lua https://pastebin.com/Agds2iTC

OS version

Windows 10 19042.1237

voidderef commented 2 years ago

Thanks for reporting. Since this is lua, have a look at its language documentation. I haven't looked into this in a while, but I assume that || is not valid and instead, you have to use or.

This is another snippet from isp-atract.lua from the piumk6 module/driver which actually uses the or operator:

dest.digital[SCREEN_ATTRACT_DI_SELECT_NEXT] =
    iop_input_state_is_pushed(IO_PIUMK6_DI_P1_RD, src, src_prev) or
    iop_input_state_is_pushed(IO_PIUMK6_DI_P2_RD, src, src_prev)

So, in your case, I'd suggest the following:

dest.digital[SCREEN_ATTRACT_DI_SELECT_NEXT] =
    op_input_state_is_pushed(IO_KEYBOARD_SDL2_DI_RIGHT, src, src_prev) or
    iop_input_state_is_pushed(IO_KEYBOARD_SDL2_DI_UP, src, src_prev)
BoomDivX commented 2 years ago

Indeed, it works perfectly with "or" instead of " ||". I did a pull request with the change in the readme file.