Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: zpaolo11x on May 21, 2020, 01:08:40 AM

Title: Help with fe.get_input_state and number keys
Post by: zpaolo11x on May 21, 2020, 01:08:40 AM
It seems that fe.get_input_state works fine with letter keys, like "A", "B" ecc, but has some issues with numbers like "1", "2" etc. When the string to check is a number the input states turns to true at the layout load even when no key is pressed.

I've put together a simple layout to test this: there's a string where you can add the letters/numbers you want to check, and the result state is shown on the display.

Code: [Select]
local displaybutton = fe.add_text("TEST",0,0,fe.layout.width,fe.layout.height*0.1)

fe.add_ticks_callback( this, "tick" )

local stringkeys = "12AB"

local keys = {}
foreach(letter in stringkeys){
   keys[letter.tochar()] <- false
}

function tick( tick_time ) {
   displaybutton.msg = ""
   foreach (key, value in keys) {
      keys[key] = fe.get_input_state(key)
      displaybutton.msg = displaybutton.msg + key + ":" + value + " "
   }
}

Has anyone had the same issue? Is there a different way to pass a check on number keys?
Title: Re: Help with fe.get_input_state and number keys
Post by: zpaolo11x on May 21, 2020, 01:42:03 AM
Ok, found the answer myself: fe.get_input_state("Num1") works fine!