kaha Posted April 22, 2023 Report Posted April 22, 2023 I want to set the pedestral lights for the Asobo classic C172. I got word from someone (not using FSUIPC but something else) that the event PEDESTRAL_LIGHTS_POWER_SETTING_SET works, but needs two parameters. One parameter is the number 1 and the other is the percentage of the light intensity. Now, with FSUIPC I can only give one parameter: ipc.control(67211, x) where x is the percentage. Regardless what value I use for x, the pedestral lights get always switched off. Same goes for GLARESHIELD_LIGHTS_POWER_SETTING_SET (67212). Is there something I miss? Karl
John Dowson Posted April 22, 2023 Report Posted April 22, 2023 You can only have one parameter to events with FSUIPC. The events with 2 parameters were recently introduced (in the simconnect SDK) and I have not looked into making these available with FSUIPC yet - and am not sure if I will do this at the moment. This may be possible using calculator code - although I am also not sure on how to set two parameters for an event with calc. code either. However, the MF preset for the pedestal lights in the C172 classic uses the following calculator code: @ 655.35 / 0 max 100 min (>K:LIGHT_POTENTIOMETER_6_SET) So this takes an axis value parameter, converts that to a percentage (between 0 and 100) and then uses the LIGHT_POTENTIOMETER_6_SET event. So you could try just using that control instead, i.e. ipc.control(66910, x) where x is the percentage. The glareshield is similar - that uses LIGHT_POTENTIOMETER_5_SET which is ipc.control(66909, x). John
kaha Posted April 23, 2023 Author Report Posted April 23, 2023 Thank you John, I will give this a try. Karl
kaha Posted April 23, 2023 Author Report Posted April 23, 2023 Can't get it to work. I'll do it using the other software, but I would prefer to be able to do it with FSUIPC as I love the possibilities lua scripting gives me. Maybe you consider to implement this in the future, that would be great. Karl
John Dowson Posted April 23, 2023 Report Posted April 23, 2023 9 minutes ago, kaha said: Can't get it to work. Thats strange...I will take a look when I get a chance... 10 minutes ago, kaha said: Maybe you consider to implement this in the future, that would be great. I think that it would overcomplicate things considerably to allow two parameters for controls. However, I could possibly allow for this in lua scripts using either ipc.control or possibly a new lua function to distinguish the two (e.g. ipc.control2). I will look into this also, when time permits. John
John Dowson Posted April 23, 2023 Report Posted April 23, 2023 What aircraft are you actually using? Is it the Asobo 172 Skyhawk? If so, those won;y work, as they are for the C172 Classic by WB Sim. For the Asobo 172 Skyhawk, the preset for the pedestal is called C172 DIMMING PEDESTAL Knob Set, which uses the following calculator code: @ 15 - 10 / near 0 max 100 min s0 (>L:LIGHTING_PEDESTRAL_1) l0 1 (>K:2:PEDESTRAL_LIGHTS_POWER_SETTING_SET) l2 ! 1 l0 (>K:2:PEDESTRAL_LIGHTS_SET) I adapted this to my axis range (-16284 = + 16384) and created the following preset (in the myevents.txt file): C172 DIMMING PEDESTAL Knob Set#@ 16384 + 32768.0 / 100 * near 0 max 100 min s0 (>L:LIGHTING_PEDESTRAL_1) l0 1 (>K:2:PEDESTRAL_LIGHTS_POWER_SETTING_SET) l2 ! 1 l0 (>K:2:PEDESTRAL_LIGHTS_SET) And then when I assign my axis to that preset, it works to control the pedestal lights. You could try something similar - if you want to do this in lua, you need to build the calc code string from your axis value and use the ipc.execCalcCode function. [Note I have use the @ symbol in my preset code for the parameter placeholder - for the current release, you need to use $Param instead. @ is what MF use and this will be accepted in the next FSUIPC release, 7.3.20, once I get time to release it....) There are similar presets for panels and avionics, but nothing yet for glareshield. However, I created a similar preset for the glareshield, based upon the pedestal one: C172 DIMMING GLARESHIELD Knob Set#@ 16384 + 32768.0 / 100 * near 0 max 100 min s0 (>L:LIGHTING_GLARESHIELD_1) l0 1 (>K:2:GLARESHIELD_LIGHTS_POWER_SETTING_SET) l2 ! 1 l0 (>K:2:GLARESHIELD_LIGHTS_SET) and this also works as expected. John
kaha Posted April 23, 2023 Author Report Posted April 23, 2023 John, this works. For the WBsim 172 I had all 4 lights working already. It was the Asobo classic 172 I was struggeling with. I use a switch to switch the light on (to 75%) and off: local light = math.floor(ipcPARAM / 1000) local percent = ipcPARAM - light * 1000 local n if light < 1 or light > 30 then return end local function rtrim(s) n = #s while n > 0 and string.byte(s:sub(n, n)) < 32 or string.byte(s:sub(n, n)) > 127 do n = n - 1 end return s:sub(1, n) end local aircraft_name = ipc.readSTR(0x3D00, 256) aircraft_name = rtrim(aircraft_name) --ipc.log("Aircraft = " .. aircraft_name) if aircraft_name:find("Cessna Skyhawk Asobo", 1, true) and not aircraft_name:find("WB", 1, true) then if light == 5 then -- pedestral lights calc_code = percent .. " s0 (>L:LIGHTING_PEDESTRAL_1) l0 1 (>K:2:PEDESTRAL_LIGHTS_POWER_SETTING_SET) l2 ! 1 l0 (>K:2:PEDESTRAL_LIGHTS_SET)" ipc.execCalcCode(calc_code) end end
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