Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keypress detection needed for Lua scripts #422

Closed
ThChicken opened this issue Jan 21, 2024 · 9 comments
Closed

Keypress detection needed for Lua scripts #422

ThChicken opened this issue Jan 21, 2024 · 9 comments

Comments

@ThChicken
Copy link

There is no means using Lua to detect keypresses to provide inputs into vessel scripts.

There was a module developed that allowed keypress detection in Lua for Orbiter 2016:

https://www.orbiter-forum.com/threads/trying-to-implement-keypress-detection-in-lua-solved.41000/

but it does not appear to work for OpenOrbiter builds.

@schnepe2
Copy link
Contributor

That (C++) code needs to be build against OpenOrbiter ABI to work for OpenOrbiter.
Resulting in an "OpenOrbiter Version" of the keystate.dll. The Lua-side should be compatible, I believe.
The source is very simple so it's more a matter of "when" than a matter of "if" 😁

That keystate Lua lib (C++ code to build keystate.dll) could be included into OpenOrbiter (provided that the original author likes that).
Please ask the original author whether it's O.K. with him/her. It's not much of a secret code, but still asking is the right way to do it.

@ThChicken
Copy link
Author

As far as I can tell keystate.dll it was a collaboration between dgatsoulis and martin:

https://www.orbiter-forum.com/threads/trying-to-implement-keypress-detection-in-lua-solved.41000/

@TheGondos
Copy link
Contributor

Wouldn't it be cleaner to expose the "clbkConsume*Key" methods to the lua side? (if you're using a ScriptVessel)

@ThChicken
Copy link
Author

Wouldn't it be cleaner to expose the "clbkConsume*Key" methods to the lua side? (if you're using a ScriptVessel)

Probably, but right now there isn't anything for Lua in OpenOrbiter at all. Beggars can't be choosers; I'll take whatever we can get done. But yes, it would probably be best to continue trying to get more callbacks exposed so we can make some add-ons without version control becoming a nightmare.

@TheGondos
Copy link
Contributor

I'm willing to take a shot at upgrading the ScriptVessel to VESSEL4 and add some callbacks (the easy ones at first) if nobody is working on this already

@ThChicken
Copy link
Author

Right now Lua has only the following vessel callbacks:

  • clbk_setclasscaps
  • clbk_postcreation
  • clbk_prestep
  • clbk_poststep

The clbkConsume*Key callbacks would allow functional add-ons to be made without the need for a special module.

I submitted Issue #421 for Lua equivalents to clbkSaveState and clbkLoadStateEx. These I think are pretty critical to making Lua usable for add-ons as they would permit vessel states to be read/written from/to scenario files, and so I'd suggest that they get some priority too.

If we could get the clbkSaveState and clbkLoadStateEx vessel callbacks and just enough clbkConsume*Key callbacks sufficient to process basic key events for for animation events etc., it will become possible to make some basic vessel add-ons with similar behavior to C++ module add-ons. People probably will start squawking for callbacks to enable staging events and more complicated stuff, but I think the above would be the best place to start.

@TheGondos
Copy link
Contributor

I've started just that on PR #427

@schnepe2
Copy link
Contributor

schnepe2 commented Jan 27, 2024

Hi, it seems you are experiencing the same "test-issues" as I did in #414 ...
It's a real pain to not know exactly where the problem is.
A possiblility to get the Orbiter.log from a FAILED Test is really needed.

By the way: Did you read these instructions?
https://github.com/orbitersim/orbiter/blob/main/Tests/README.md
especially this point:
"[...]Call oapi.exit(code) when test is finished, pass non-zero return code in case of failed test, and 0 - if all tests are successful[...]"

@TheGondos
Copy link
Contributor

Hi, it seems you are experiencing the same "test-issues" as I did in #414 ... It's a real pain to not know exactly where the problem is. A possiblility to get the Orbiter.log from a FAILED Test is really needed.

By the way: Did you read these instructions? https://github.com/orbitersim/orbiter/blob/main/Tests/README.md especially this point: "[...]Call oapi.exit(code) when test is finished, pass non-zero return code in case of failed test, and 0 - if all tests are successful[...]"

Oh no it's just because I'm stupid, this file is not supposed to be used for CI but to do manual tests with a lua version of the HST that I'm making along to figure out what's needed most.
I didn't know it would be executed in this context. I will have to move it somewhere else...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants