bpcw001 Posted June 5, 2013 Report Posted June 5, 2013 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?
Pete Dowson Posted June 5, 2013 Report Posted June 5, 2013 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
bpcw001 Posted June 5, 2013 Author Report Posted June 5, 2013 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now