Jump to content
The simFlight Network Forums

Recommended Posts

Posted

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?

Posted

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

Posted

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.

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.