Page 1 of 1

Don't really understand the main loop

Posted: Wed Nov 29, 2023 4:47 pm
by stupor-mundi
My previous FreePIE script was using a MIDI controller, now I'm trying a script that only reads from keyboard and writes to VJoy.

According to the docs, all devices APART from keyboard and mouse, such as the MIDI controller I was using, need polling set up in this way:

Code: Select all

if starting:
    midi[0].update += update
This gave me the opportunity to write the update() function and use globals.

But now, without the MIDI device, I have no idea how to correctly initiate the main loop.
I tried to do it without using globals, without a function, assuming the entire code gets executed repeatedly, like this:

Code: Select all

v_speed = vJoy[0].x

v_down = keyboard.getKeyDown(Key.A)

v_up = keyboard.getKeyDown(Key.S)

if v_down:
	v_speed = v_speed - 10
if v_up:
	v_speed = v_speed + 10
vJoy[0].x = v_speed
but nothing seems to happen, no diagnostic values are shown.
Nothing seems to happen when I press keys.

Re: Don't really understand the main loop

Posted: Sat Dec 02, 2023 7:17 am
by Jabberwock
The function diagnostic.debug just dumps the values into the console, so it might be not displaying what you want at all. Use - I did that with your script and everything works fine (you can watch the values in the 'watch' tab on the right).