Jump to content
The simFlight Network Forums

How can I verify the existence of a macro in LUA?


Recommended Posts

Hello!

For a LUA plug-in I need a method to determine if a macro with a name provided in a variable really exists:

I want to call macros not only by a fixed name like - ipc.macro("MyMacroFile:MyMacroName") - but also by a string variable (which contains a string transferred from an hardware device) like - ipc.macro(VarMacroFilename .. ":" .. VarMacroName)

But in the case that no macro with that name is defined, the LUA plug-in should execute some alternate actions (like transferring the string to the original hardware driver).

Some solution can be writing a constant value to one of the FSUIPC offsets for general purpose (0x66D0 … 0x66FF) before calling the macro, then implement writing another constant value to the same offset in every defined macro and checking the offset in the code after the macro call - that should work, but I think that is not what I mean with "good coding" ;)

Is there any other way to verify the existence of a FSUIPC macro in LUA?

The best way I think would be getting a return value from the ipc.macro() function that tells me if a macro with that name has been executed or not. Any chance to implement that in future? (if already implemented, I didn't find any hint neither in the documentation nor in the examples provided)

Thanks and greetings,

Jörg

Link to comment
Share on other sites

Is there any other way to verify the existence of a FSUIPC macro in LUA?

No. FSUIPC is not aware of what macros exist until they are called. All it has is a numbered list of macro filenames, You can read that in the INI file. Then you'd have to read the macro file and scan the macro names, same as FSUIPC has to do in any case when you access one.

Pete

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.