Jump to content
The simFlight Network Forums

The Tall Guy

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by The Tall Guy

  1. OK, I've tested the new release, and, as expected, the new features work very well. Whatever you did to the timer code seems to have fixed my issue. And the expansion to "testbutton" also did the trick, which allows me to remove the timer code altogether. (I haven't tested the "readPOV" method, but since "testbutton" works across all buttons, I probably won't.) Once again, thank you for your quick turnaround. That's wonderful! I noticed something else that isn't a bug in FSUIPC, but I'm not totally sure it's a feature, either. I was puzzling over this part of the log: 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524937 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 524953 LUA: Button.pressOrRelease: Button '0 is state '1' 525187 LUA: Button.pressOrRelease: Button '0 is state '0' What this shows is that when you press button 0, the "Button.pressOrRelease" method is called 17 times. Why? Well, I did some really sloppy re-factoring in the button initialization code, and forgot to change a variable name: event.button( joystick, buttonNo, 3, "Button.pressOrRelease" ) "buttonNo" is actually undefined in the new code (should have been "self.buttonNo"), making it that every time you assign any button, it adds an additional capture onto button 0. Hence the 17 calls, as there are 17 buttons defined. Is this the designed behavior of "event.button"? My first thought was that subsequent captures of button 0 should have simply replaced earlier ones, so that only the last "event.button" call actually takes effect. After thinking about it some more, though, I realized how cool it was that I could actually assign multiple button handlers to a button, and they all would be called when the button is pressed. If that's actually what you planned, it's worth documenting that next time you update the docs, as it could come in pretty handy for someone. Best, Michael
  2. Wow, that's great! Thanks for the new functions. I will try them hopefully tonight. (I have a big project to finish today... Sigh!) Thanks for the bug fixes. I caught a couple yesterday, too, so I'll merge them all together. I love the fact that you also chose to extend testbutton, which makes my code easier. Michael
  3. Ouch! I hope the rebuild goes fast and well. If you feel like building a "readPOV" function, I certainly won't complain -- that's more than I hoped. Thank you! And it seems too predictable to be a weird timer interaction. But I'm just guessing. No rush! I need it for FSUIPC3. I'm going to try to figure out another bit of weirdness with it. If/when I fix bugs with my script, I'll post a revised version to you. Best regards, Michael
  4. 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
  5. Hi, Pete! I'm new to FSUIPC but I'm loving it! The Lua libraries, in particular, are great, and allowing me to really improve my sim experience. I am working on a Lua script that overloads the functions of the buttons on my game controller. (I sim on my laptop, and when I'm not at my desk rig, I use a game controller.) This script, inspired by your "tripleuse.lua" example, lets me assign functions that are invoked on button down, button up and button hold, and can be repeating or "only once". This is all on Windows XP SP3 and FS 9.1 using FSUIPC 3.989y (version verified on the main window). I'm noticing some odd behavior, and I can't tell if they are mistakes I'm making or bugs in FSUIPC. I thought I should bring them to your attention. 1. My initial approach was to capture button presses and test for button releases using ipc.testbutton, as in "tripleuse". This worked brilliantly for the normal buttons (0-31). For the POV buttons, however, this didn't work well. The capture events happened as expected, but ipc.testbutton always returned false, even when the POV button was down. Is this the correct behavior? The docs aren't specific on it one way or another. 2. Since I couldn't get "testbutton" to do what I needed, I changed the code to use event.timer instead; I track presses/releases myself, and on button press I start a timer. The timer function checks to see if buttons are still down, and performs the button "hold" functions. When the button is released, I use "event.cancel" to terminate the timer. However, i get what looks like a low-level Lua error in the script's log. Here's the code to start the timer: function ActionButton.startTimer() ActionButton.timerCount = ActionButton.timerCount and ActionButton.timerCount + 1 or 1 -- how many buttons we're watching if ActionButton.timerCount == 1 then -- no timer running yet event.timer( ActionButton.timerInterval, "ActionButton.timerEvent" ) print( "ActionButton.startTimer: Timer started" ) end end and the code to cancel it: function ActionButton.endTimer() ActionButton.timerCount = ActionButton.timerCount - 1 if ActionButton.timerCount < 1 then -- no more keys to monitor... event.cancel( "ActionButton.timerEvent" ) -- so shut down the timer print( "ActionButton.endTimer: Timer stopped" ) end end And this is the error that shows up in the log later on: 39234500 *** LUA Error: attempt to call a nil value Note the lack of line numbers. When I comment out the event.cancel, the error goes away. Thanks in advance for any insight you can provide into these. I'm happy to provide the entire script if you like, but it's quite long so I thought I'd start with small fragments. Best, Michael
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.