Jump to content
The simFlight Network Forums

Wrong offset?


Fabix
 Share

Recommended Posts

Hi,

I just bought the FSUIPC7 and started doing some first experiments with LUA. I tried to write in an offset, but strangely when I read the log, I see that it wrote in another offset. What am I doing wrong?

My LUA script:
 

ipc.writeUB("66C0", 1)

But in the log it shows written "0D6C" 🤔

What i am trying to do is write a value of 1 or 0 in a custom offset.

Thank you,
Fabio

Link to comment
Share on other sites

24 minutes ago, Fabix said:

Yes I had already tried it, but it always writes inside the wrong offset. Some idea?

Well, using either 0x66C0 or "66C0" should work. This is a free user offset used by many folks (including me) for years without issue, so something else must be happening...

Please activate logging for lua plugins, as well as offset logging for 0x66C0, and generate a log file running the lua, and show me that as well as your lua script.

Link to comment
Share on other sites

This is what happen in the log when the lua script was executed:

   517719 WRITE0[19376]  0D6C,   4 bytes: 01 00 00 00                                      ....
   517719 WRITE0[19376]  0D70,  40 bytes: 52 61 64 69 6F 53 77 69 74 63 68 4F 6E 00 00 00  RadioSwitchOn...
   517719                           00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   517719                           00 00 00 00 00 00 00 00                          ........

I don't know why two writing operations are performed, and above all on those offsets that I have not entered. I call the Macro with MobiFlight, I don't know if this could affect it:

radio.jpg

Link to comment
Share on other sites

Ah, you are using MobiFlight....! You didn't mention this. I cannot support MobiFlight, you need their support (or Discord channel).
However, that log extract is an IPC write log, which is showing the MF is writing to that offset area, which is the offset area for macro (and lua) requests. So that seems correct.


Try logging offset 0x66C0 using the FSUIPC offset logging facility. You will probably see that that offset is also changing. IPC write log will only log the changes to offsets via IPC calls, not from macro or lua scripts, which are internal. You need to use FSUIPC's offset logging facility to see those.

 

 

Link to comment
Share on other sites

I came to the conclusion that the lua code I wrote just doesn't run. That log remains unchanged whatever I write in the lua code. At this point I am probably wrong to declare the file.

I created a file called RadioSwitchOn.lua and placed it in the FSUIPC installation directory. After running FSUIPC the FSUIPC7.ini file shows:

[LuaFiles]
1=RadioSwitchOn

Is all this enough? Or am I wrong something? Maybe I have to call it with .mcro extension?

Thank you,
Fabio

Link to comment
Share on other sites

2 hours ago, Fabix said:

Is all this enough? Or am I wrong something? Maybe I have to call it with .mcro extension?

No, macro files are not Lua plug-ins.

If you want a Lua plug-in to run then you have to actually tell FSUIPC to run it. Its listing in [LuaFiles] is merely to give it an index number(1 in this case) for when you assign a button or keypress to it (via the assignment dropdowns -- look there, you will see "Lua RadioSwitchOn" listed, among others. That's exactly simiar to using macros by assigning buttons or keypresses to them. Both plug-ins and macros increase the nmuber of different things you can assign to.

The other way to run them, which would normally apply if your plug-in is "event" driven (i.e. stays running and does things based on events), is to load then via an [Auto] section containing a Lua RadioSwitchOn instruction.

Please refer to the Lua documents provided, and also to the FSUIPC user documentation about [Auto] sections.

Pete

 

Link to comment
Share on other sites

2 hours ago, Fabix said:

Is all this enough?

Thats enough for it to be recognised by FSUIPC. If you enabled lua plugin logging and didn't see anything, then it didn't run.

Have you tried to assign in fsuipc, to a button or key press? If not, try that. I'm sure it will work. 

And as I said before, try logging the offset.

Of course, you need a registered version of fsuipc to run lua scripts.

Link to comment
Share on other sites

2 minutes ago, John Dowson said:

Thats enough for it to be recognised by FSUIPC. If you enabled lua plugin logging and didn't see anything, then it didn't run.

Have you tried to assign in fsuipc, to a button or key press? If not, try that. I'm sure it will work. 

And as I said before, try logging the offset.

Of course, you need a registered version of fsuipc to run lua scripts.

Yes, I have the registered version of FSAUPC 🙂 And yes if I assign the lua plugin to a button it works. Probably the problem is how I try to have it run through MobiFlight since it is actually a plugin and not a macro.

Link to comment
Share on other sites

7 minutes ago, Pete Dowson said:

The other way to run them, which would normally apply if your plug-in is "event" driven (i.e. stays running and does things based on events), is to load then via an [Auto] section containing a Lua RadioSwitchOn instruction.

Please refer to the Lua documents provided, and also to the FSUIPC user documentation about [Auto] sections.

 

Yes, I'm trying to navigate the various documentations. It would be great if there was a youtube video showing a simple example from start to finish. Hope for the future.

Link to comment
Share on other sites

I finally succeeded. I publish the solution so that in the future it can be of help to someone.

Instead of the simple "filename", you have to write "Lua filename" in the MobiFlight menu like this screen:

final.png

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.