Jump to content
The simFlight Network Forums

event.intercept


Recommended Posts

Hi,

I tried to make a simple test script, TestScript.lua, for FSUIPC in FSX SP2.

Running FSUIPC version 4.904.

function fsuipc_T1(offs, val)

ipc.control(64104, val)

end

event.intercept(0x66C8, "SW", "fsuipc_T1")

in FSUIPC.ini, I have the following:

[Auto]

1 = LUA DynamicFriction

2 = LUA TestScript

Now, in FSUIPC, I assigned an axis to "Offset Word Set" its values to x66C8.

On moving the axis, I'd expect the fsuipc_T1 function to trigger and send the param to control 64104 (FSUIPC calib throttle), which should move the throttle.

However, nothing happens.

I tried the same using a "while 1 do" construct and that works, however I thought using events might be more elegant than a polling loop.

Seems I have not grasped the event stuff yet.

What am I doing wrong here?

Link to comment
Share on other sites

Now, in FSUIPC, I assigned an axis to "Offset Word Set" its values to x66C8.

On moving the axis, I'd expect the fsuipc_T1 function to trigger and send the param to control 64104 (FSUIPC calib throttle), which should move the throttle.

However, nothing happens.

The event.intercept function only does what it is documented as doing -- intercepts any write to the nominated offset by any client application, module or gauge. The write internal to FSUIPC from your assignment is not going to be seen as it is not from an outside agency!

All you need to do to accomplish exactly what you are trying to do there is assign the axis directly to Lua TestScript and have that simply do this:

ipc.control(64104, ipcPARAM)

because the axis value is passed as ipcPARAM.

Of course it would be more efficient to assign it directly to that control in the first place, but I'm assuming here that you are experimenting in order to do something more ambitious?

Also, it isn't clear why you might want to stop 66C8 from receiving the value, it being a free user offset in any case. The normal reason for an intercept is to prevent something doing something, or modifying it first.

To use an event you'd be better off allowing the offset to be written and use event.offset to call your function each time it is changed.

Regards

Pete

Link to comment
Share on other sites

The event.intercept function only does what it is documented as doing -- intercepts any write to the nominated offset by any client application, module or gauge. The write internal to FSUIPC from your assignment is not going to be seen as it is not from an outside agency!

All you need to do to accomplish exactly what you are trying to do there is assign the axis directly to Lua TestScript and have that simply do this:

ipc.control(64104, ipcPARAM)

because the axis value is passed as ipcPARAM.

Of course it would be more efficient to assign it directly to that control in the first place, but I'm assuming here that you are experimenting in order to do something more ambitious?

Also, it isn't clear why you might want to stop 66C8 from receiving the value, it being a free user offset in any case. The normal reason for an intercept is to prevent something doing something, or modifying it first.

To use an event you'd be better off allowing the offset to be written and use event.offset to call your function each time it is changed.

Regards

Pete

OMG - facepalm. Thanks a lot! I was working up something insanely complex while the only solution I needed was assigning a lua directly to the axis.

Anyway, that way I got to toy around a little with the event lib.

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.