Yeah, I noticed that the "testbutton" docs didn't mention POV buttons, but I wondered if it was a simple mistake, since "event.button" can capture them. Does FSUIPC+Lua provide any way to read the POV state? Without either of us going to a ton of work, I mean? I didn't see anything in the docs beyond "event.button". I ask because tracking the button press/release and adding the whole timer thing makes the code harder to follow and probably more prone to errors. (My errors, at least.)
Yes, that was a great addition on your part! It allows for coding libraries, which hopefully means that people can publish libraries of useful function that other non-programmers can benefit from. I admit that I'm trying to code this particular script that way, so that it can be used by others.
Nothing obvious comes to mind, but it's often hardest to spot your own bugs. As you point out, both timer statements should either work or fail together. The fact the timer function is set up without issue means that the code for referencing functions within tables is working correctly. Unless that same code is somehow not being used for the timer cancel, it should continue to work there, too. It seems, though, that the reference to the timer function is being zero'd (NIL'd) out, but it still thinks that the timer is being captured. I wonder if the code clears the current outstanding timer? The fact that I get one and only one error makes me wonder if the cancel doesn't clear the _next_ timer interrupt, which goes off as planned but encounters an error when the designated function is nil? (Otherwise, I'd expect to get lots of errors as the nil'd function is called every 50 msec.)
Anyway, I'm attaching my scripts. There are two -- "gameControler.lue" which is the one that's got the issue, and "middleclass.lue" which is a pseudo-class library for object-oriented coding goodness. (I'm using it for the first time here, but I don't know much about it. I don't see why it would be causing the error, since everything is ultimately just a function in a table, but you never know.) If you have time to look at it, I'd appreciate it. If it is a bug in FSUIPC, I'm happy to help test the fixed code for you. And if it's my bug -- and aren't they usually? :) -- I apologize in advance for wasting your time.
Best,
Michael
PS: To test the script, I just assign it to an unused key and start it. It then runs in the background. It's assigned to joystick 2, but you can change that right at the top of the script. I get the timing error when I press button0, which in the script is assigned to Auto-Throttle Arm/Disarm. (You can see all the key assignments at the very bottom.) The script generates reams and reams of logs, which may be useful. It's a long script, and not super documented, so if it's taking too long to read through, I can give you the general gist of each function and what it's trying to do.
gameController.zip