Jump to content
The simFlight Network Forums

FSUIPC, LUA och HIDmacros


Recommended Posts

Hi,

I have a L:MasterCaution variable as I will set to 0 at some time.

I wrote this LUA.script and assign it to a key everything works perfekt.

 ipc.writeLvar("L:MasterCaution", 0)[/CODE]

The script is this single line and nothing more.

For HIDmacro I have wrote this LUA-script:

[CODE]function sendmybutton()
ipc.writeLvar("L:MasterCaution", 0)
ipc.writeUW(0x66C0,-1)
end

ipc.writeUW(0x66C0,-1)
event.offset(0x66C0, "UW", "sendmybutton")[/CODE]

and named it to ipcReady.lua and it is placed i Modules folder.

I did almost as you wrote in http://forum.simflig...pc/#entry419638

and in HIDmacro the macro is:

[CODE]HIDMacros.SetFSUIPCInt &H66C0, 2, 0[/CODE]

When I press the key in HIDmacro the macro sends to FSUIPC and strange thing happens: the whole FSim freeze for a second or two and I can see an affect at the MasterCaution but it is not reset as in the script from the key. FSim starts working again and I have to press the key in the first scrip and Caution resets.

What is wrong? Any help is appreciated.

Jonny

Link to comment
Share on other sites

When I press the key in HIDmacro the macro sends to FSUIPC and strange thing happens: the whole FSim freeze for a second or two and I can see an affect at the MasterCaution but it is not reset as in the script from the key. FSim starts working again and I have to press the key in the first scrip and Caution resets.

What is wrong? Any help is appreciated.

I think you might have a loop because you are writing to 66C0 different values. You surely missed out actually testing the value of 66C0. You only want to do this thing when you've set 66C0 to 0 don't you?

function sendmybutton(offset, val)
if val == 0 then
ipc.writeLvar("L:MasterCaution", 0)
ipc.writeUW(0x66C0,-1)
end
end

ipc.writeUW(0x66C0,-1)
event.offset(0x66C0, "UW", "sendmybutton")[/CODE]

BTW, I also think choosing -1 for "nothing" and 0 for "do something" is not good. Offsets default to 0, so why not choose 0 for "do nothing, then different non-zero values for action?

Pete

Link to comment
Share on other sites

Hi Pete!

Excuse me for my previous answer.

I change my script as your example.

After some experiment I think it works OK now.

First I think I hade some fault in med Notepad++ editor, causing the script to not works.

When I rewrote the Lua script in Notepad the script works but only one time after each FSX start. It seems like the script stop working after one execution. Has it to do with -1 and 0 I used in the first script. Or does ipcReady.lua stop working when I land and the arcraft has stopped. Because when I start the fligth again the script doesn't work. It doesn't work after a restore of the fligt eigter.

When I change -1 and 0 to 0 and 1 it seems working much better. Now when I start and stop a fligth or when I restore a flight the script is working all the time.

Does this description sounds OK or have I run into garbage mixing?

Jonny

Edited by jonny
Link to comment
Share on other sites

Besides my first problem with the loop, the secon problem depend on wrong variable.

ipc.writeUW(0x66C0,-1) variable UW is for Unsigned variables and -1 is a Signed variable.

By change to ipc.writeSW(0x66C0,-1) -1 works fine.

In the first case I had to use 0 and 1 as numbers.

Now it works OK!

Jonny

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.