
shorthauler
Members-
Posts
116 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Gallery
Downloads
Everything posted by shorthauler
-
Dear John, I am working on a Lua script for the mode knob on an A320 EFIS. The knob has five positions which are five separate buttons. Each button calls a LuaValue function and assigns a parameter, "0" for the left most position (ILS), "10" for the next (VOR) etc. until "40" for the right most position (PLAN). This moves the button as planned but does not change the display on the ND. The display can only be changed by sending rotor brake codes for decreasing and increasing. My script sends four decreasing ipc.control commands for the left most and four increasing for the right most position. This syncs the display with the knob, but only in these positions. I would like to send a decreasing or increasing command for the positions in between, but I can't get it to work. Could you have a look at my script? function modeKnob(param) old_param = ipc.readLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob") -- reads the position of the knob from the Lvar before the new param is written and names it "old_param" ipc.writeLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob", ipcPARAM) -- writes the new param into the Lvar new_param = ipc.readLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob") -- names the new param as global function if ipcPARAM == 0 then -- four decreasing inputs for the left most position ipc.control(66587,71021) ipc.control(66587,71024) ipc.control(66587,71021) ipc.control(66587,71024) ipc.control(66587,71021) ipc.control(66587,71024) ipc.control(66587,71021) ipc.control(66587,71024) elseif ipcPARAM == 40 then -- four increasing inputs for the right most position ipc.control(66587,71025) ipc.control(66587,71022) ipc.control(66587,71025) ipc.control(66587,71022) ipc.control(66587,71025) ipc.control(66587,71022) ipc.control(66587,71025) ipc.control(66587,71022) elseif (old_param < new_param) then -- compare old and new param and increase of decrease setting of ND accordingly ipc.control(66587,71021) ipc.control(66587,71024) else ipc.control(66587,71022) ipc.control(66587,71025) end end event.param("modeKnob") ------------------ Extract from the log: 811109 LUA: Waiting for an event in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 811890 LUA: ipcPARAM event: calling "modeKnob" in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 811890 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:2 811890 LUA: Global: ipcPARAM = 20 811890 LUA: Local: param = 20 811890 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:3 811906 LUA: Global: old_param = 30 811953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:4 811953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:5 811953 LUA: Global: new_param = 20 811953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:14 811953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:23 811968 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:27 812015 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:28 812031 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:30 812031 LUA: Waiting for an event in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 813156 LUA: ipcPARAM event: calling "modeKnob" in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 813156 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:2 813156 LUA: Global: ipcPARAM = 10 813156 LUA: Local: param = 10 813156 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:3 813156 LUA: Global: old_param = 20 813218 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:4 813218 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:5 813218 LUA: Global: new_param = 10 813218 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:14 813218 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:23 813218 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:27 813265 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:28 813265 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:30 813265 LUA: Waiting for an event in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 813609 LUA: ipcPARAM event: calling "modeKnob" in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua" 813609 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:2 813625 LUA: Global: ipcPARAM = 0 813625 LUA: Local: param = 0 813625 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:3 813625 LUA: Global: old_param = 10 813765 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:4 813765 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:5 813765 LUA: Global: new_param = 0 813781 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:6 813781 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:7 813781 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:8 813781 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:9 813937 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:10 813937 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:11 813953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:12 813953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:13 813953 LUA: E:\FSX\Flight Simulator X\Modules\A320 Mode.lua:30 813953 LUA: Waiting for an event in "E:\FSX\Flight Simulator X\Modules\A320 Mode.lua"
-
trying to send value to LVAR by button
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
I found my mistake - Notepad++ does not save files on exit. However, it will show the modified file when you open it again. So I assumed my script was saved, but it was not. It all works fine now. Thanks a lot for your help! -
trying to send value to LVAR by button
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
(I might have a mistake there, I will check later today and report.) Hi John, You recommend setting the buttons to the LuaValue command, but for me it only works with the normal Lua command. I wonder what I am doing wrong. Best regards -shorthauler -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thank you, now everything works. I am consulting lua fora, but I was under the impression that event.offset was specific to FSUIPC. I misread the lua library document - the term offset is not between quotation marks, so it should indeed be written offset. I wrote the actual offset, silly me. Thank you so much again -shorthauler -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thank you, I was not aware of this. I replaced offset 66C1 by 66C0. The values stored in 66C0 still "leak" into 66C1. I am not sure how I should apply "event.offset" to 0xABCD here. I made a line event.offset (0x54C4, "STR", 9, "getnumbersfromtext") and put it in front of everything else as first line. But this does not work. If the format is event.offset(offset, "STR", length, "function-name") what should I use as function name? Best - shorthauler -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thanks a lot, *100 and then /100 in MobiFlight works great! I am using free offset 66C1 for the speed and it occupies 66C2 as well, but not 66C3 and beyond. For "speed100" I am logging U16 in the simulator and a 2 byte integer in MobiFlight. This is the final script. It works well. There is, however, a noticeable delay between the digit changes in the simulator and the digit changes in my FCU. I am using "repeat ... until condition" to have the script constantly run over the string and check for changes. Maybe this can be done more efficiently. - shorthauler repeat spdstate = ipc.readSTR(0xABCD, 9) function getnumbersfromtext(spdstate) return tonumber(spdstate:match"%d+[%d.,]*") end if (string.find(spdstate, "%-") and string.find(spdstate, "%*")) then ipc.writeUB(0x66C5,1) ipc.writeUB(0x66C6,1) elseif string.find(spdstate, "%-") then ipc.writeUB(0x66C5,1) ipc.writeUB(0x66C6,0) elseif string.find(spdstate, "%*") then ipc.writeUB(0x66C5,0) ipc.writeUB(0x66C6,1) else ipc.writeUB(0x66C5,0) ipc.writeUB(0x66C6,0) end if string.find(spdstate, "SPD") then ipc.writeUB(0x66C7,1) else ipc.writeUB(0x66C7,0) end if string.find(spdstate, "MACH") then ipc.writeUB(0x66C8,1) else ipc.writeUB(0x66C8,0) end if string.find(spdstate, "%-") then ipc.writeSW(0x66C1, 0) -- speed hast to be forced to 0, when the dashes appear in managed mode, otherwise there will be interferences with the dashes else speed = getnumbersfromtext(spdstate) speed100 = speed*100 ipc.writeUW(0x66C1, speed100) -- logging "speed100" with U16 in the simulator and a 2 byte integer in MobiFlight end until condition -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Update: I was able to solve this with the "transform" function in Mobiflight using "Round($*100, 0)". "Truncate" did not work for some reason, but "Round" did the trick. I will now do a few flights to see if everything really works and then report back. -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
I think I may have the correct code now: spdstate = ipc.readSTR(0xABCD, 9) function getnumbersfromtext(spdstate) return tonumber(spdstate:match"%d+[%d.,]*") end speed = getnumbersfromtext(spdstate) -- everything works until here, I get a correct Mach number such as 0.59 ipc.writeFLT(0x66C1, speed) -- I get 0.590000000000... as an output value that I read via the logging window or in Mobiflight As per the log below, I am getting the correct results for "speed". But how do I write them best to the offset? If I use "writeFLT" for writing and "FLT32" for monitoring, I get a number with a seemingly infinite number of zeroes after the Mach value. I only need the two digits after the decimal, just like in the log. Am I using the wrong format to write to the offset? Best regards, - shorthauler ********* LUA: "A320 SPD split" Log [from FSUIPC version 4.977] ********* 529704 System time = 24/09/2023 09:09:22, Simulator time = 13:20:07 (12:20Z) 529704 LUA: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 529719 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:1 529719 LUA: Global: ipcPARAM = 0 529719 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 529719 LUA: Global: spdstate = MACH 0.56 529719 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 529735 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:13 529735 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:6 fn: getnumbersfromtext 529735 LUA: Local: spdstate = MACH 0.56 529735 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:14 529735 LUA: Global: speed = 0.56 529766 >>> Thread forced exit (ipc.exit or os.exit) <<< 529766 System time = 24/09/2023 09:09:22, Simulator time = 13:20:09 (12:20Z) ********* LUA execution terminated: Log Closed ********* -
Hi folks, This seems to be a new (and interesting) problem, so I am opening a new thread. I am searching a string for certain characters, and depending on whether they are found or not, a free offset is either set to 1 or 0. The string is either SPD plus a number or MACH or a number ("SPD245" or "MACH 0.78"). Or, in managed mode, it is "---*". spdstate = ipc.readSTR(0xABCD, 9) if (string.find(spdstate, "%-") and string.find(spdstate, "%*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,1) elseif string.find(spdstate, "%-") then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,0) elseif string.find(spdstate, "%*") then ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,1) else ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,0) end This works well. Now the conundrum: I am also monitoring (FS Window) free offset 66C1 which in an older script was used to extract other elements of the string. This offset is not used anymore in any of my lua scripts. Still, in managed mode, when offets 66C2 and 66C3 both show "1", 66C1 it shows the value of 256 in signed 16-bit value (S16) or 65792 in signed 16-bit value (S32). In selected mode, when the string shows either a SPD or MACH value, it is 0. As this seems to be an FSUIPC related question rather than a Lua question, I am posting it here. Any input appreciated! -shorthauler Log: ********* LUA: "A320 SPD split" Log [from FSUIPC version 4.977] ********* 1712937 System time = 23/09/2023 13:45:07, Simulator time = 13:23:27 (12:23Z) 1712937 LUA: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 1712937 LUA: Global: ipcPARAM = 0 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 1712937 LUA: Global: spdstate = SPD 250 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:14 1712953 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:17 1712953 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:21 1713000 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:22 1713000 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:23 1713000 >>> Thread forced exit (ipc.exit or os.exit) <<< 1713000 System time = 23/09/2023 13:45:07, Simulator time = 13:23:27 (12:23Z) ********* LUA execution terminated: Log Closed ********* ********* LUA: "A320 SPD split" Log [from FSUIPC version 4.977] ********* 1729640 System time = 23/09/2023 13:45:24, Simulator time = 13:23:39 (12:23Z) 1729640 LUA: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 1729640 LUA: Global: ipcPARAM = 0 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 1729640 LUA: Global: spdstate = SPD ---* 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:12 1729718 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:13 1729718 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:23 1729718 >>> Thread forced exit (ipc.exit or os.exit) <<< 1729718 System time = 23/09/2023 13:45:24, Simulator time = 13:23:39 (12:23Z) ********* LUA execution terminated: Log Closed *********
-
having multiple if-statements in one file
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Apologies for the separate threads, but one is to extract the numbers from a string and write it into an offset, the other one (this one) is to learn how to find a certain character in a string and write 0 or 1 into an offset accordingly. I though it would be less confusing to separate the threads. Best regards, Holger -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thank you, so adapted to my variables, this would look like this? spdstate = ipc.readSTR(0xABCD, 9) function getnumbersfromtext(spdstate) local str = "" string.gsub(txt,"([%d.]+)",function(e) str = str .. e end) return tonumber(str); end speed = getnumbersfromtext ipc.writeSW(0x66C1, speed) -
having multiple if-statements in one file
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
This is a snippet of the log file, with my commments: 2750813 LUA.0: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" => The script is started, airplane is in managed mode with dashes and dot displayed. 2750813 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 2750813 LUA.0: Global: ipcPARAM = 0 => I do not know which parameter this refers to. Line 3 is spdstate = ipc.readSTR(0xABCD, 9) 2750813 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:5 2750828 LUA.0: Global: spdstate = SPD ---* => I am puzzeled - there is a line change. The string seems to work in two lines. I wonder whether this makes the string difficult to read. 2750828 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:6 2750875 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:7 2750875 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:19 2750875 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:20 2750891 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:21 => Airplane has been changed to selected mode, knots. Then the script is called again. 2756047 LUA.0: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 2756047 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 2756047 LUA.0: Global: ipcPARAM = 0 2756063 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:5 2756063 LUA.0: Global: spdstate = SPD 289 => Again, a line change. 2756063 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:8 2756078 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 2756078 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:15 2756109 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:16 2756125 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:19 2756125 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:20 2756125 LUA.0: Global: speed_str = 289 => Speed as characters, extracted correctly from string. 2756125 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:21 2756125 LUA.0: Global: speed = 289 => Speed as number. => Airplane is in managed mode, speed changed to Mach. 2759688 LUA.0: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 2759688 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 2759703 LUA.0: Global: ipcPARAM = 0 2759703 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:5 2759703 LUA.0: Global: spdstate = MACH 0.54 => Mach number read correctly from string. 2759703 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:8 2759719 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 2759719 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:15 2759766 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:16 2759766 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:19 2759766 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:20 2759781 LUA.0: Global: speed_str = 0. => This should be only the numbers from the string. See other post on the Mach number. 2759781 LUA.0: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:21 2759781 LUA.0: Global: speed = 0 -
having multiple if-statements in one file
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Yes, you were right, thank you very much. I realize that "*" is a "magic character". It can be escaped by putting "\" in front. Same goes for the hyphen / minus. In the script I have reduced the number of hyphens to one. Because there will always be three hyphens in the string or none. So it's enough to only find one. But still the same problem. When 66C2 should be set to one, it is set to 0 and vice versa. The script now looks like this, with line numbers: 1 -- dashes C2, dot C3 2 3 spdstate = ipc.readSTR(0xABCD, 9) 4 5 if (string.find(spdstate, "\-") and string.find(spdstate, "\*")) then 6 ipc.writeUB(0x66C2,1) 7 ipc.writeUB(0x66C3,1) 8 elseif string.find(spdstate, "\-") then 9 ipc.writeUB(0x66C2,1) 10 ipc.writeUB(0x66C3,0) 11 elseif string.find(spdstate, "\*") then 12 ipc.writeUB(0x66C2,0) 13 ipc.writeUB(0x66C3,1) 14 else 15 ipc.writeUB(0x66C2,0) 16 ipc.writeUB(0x66C3,0) 17 end 18 19 speed_str = string.match(spdstate, "%d+[%d.,]") -- speed as string 20 speed = tonumber(speed_str) -- converting speed from string to number 21 ipc.writeSW(0x66C1, speed) -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
The Mach number in the string is seperated with a full stop, not with a comma. - shorthauler -
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Yes, I was also surprised, but it only works in SPD mode, not in MACH. SPD is an integer, MACH a rational number < 1. For MACH I only get a zero. This may be the zero in front of the decimal, and the value after the decimal is cut off. I have tried to make use of the tonumber function - did I do this correctly? For the value after the decimal, I tried this "[%d.,]". But it does not do the trick. I have used "ipc.writeSW" (signed word value). -- dashes C2, dot C3 spdstate = ipc.readSTR(0xABCD, 9) if (string.find(spdstate, "---") and string.find(spdstate, "*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,1) elseif (string.find(spdstate, "---") and not string.find(spdstate, "*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,0) elseif (string.find(spdstate, "*") and not string.find(spdstate, "---")) then ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,1) else ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,0) end speed_str = string.match(spdstate, "%d%d[%d.,]") -- speed as string speed =tonumber(speed_str) -- converting speed from string to number ipc.writeSW(0x66C1, speed) -
having multiple if-statements in one file
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thanks a lot, John. This is the file, as it stands now. I have changed it a bit. We are looking at two elements here, dashes and dots, and I think it is necessary to explicitly add the "not string.find" part (I hope my syntax is ok). The conundrum is that The 0x66C2 offset is always 1 where it should be 0 and vice versa. Even if I swap the ones and the zeroes in the code! -- dashes C2, dot C3 spdstate = ipc.readSTR(0xABCD, 9) if (string.find(spdstate, "---") and string.find(spdstate, "*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,1) elseif (string.find(spdstate, "---") and not string.find(spdstate, "*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,0) elseif (string.find(spdstate, "*") and not string.find(spdstate, "---")) then ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,1) else ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,0) end speed = string.match(spdstate, "%d+") ipc.writeSW(0x66C1, speed) -
Hi folks, I have these two scripts which work seperately from each other: spdstate = ipc.readSTR(0xABCD, 9) if string.find(spdstate, "---") then ipc.writeUB(0x66C2,1) else ipc.writeUB(0x66C2,0) end ---------------------------- spdstate = ipc.readSTR(0xABCD, 9) if string.find(spdstate, "*") then ipc.writeUB(0x66C3,1) else ipc.writeUB(0x66C3,0) end I would like to fuse both of them into one script. I don't see how I should use the function expression for this. I could do a nested if statement with all possible four combinations, but I don't know how to code "not find". Best regards -shorthauler
-
trying to extract numbers from string
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thsnk you for directing me to these links. This now works: spdstate = ipc.readSTR(0xABCD, 9) speed = string.match(spdstate, "%d+") ipc.writeSW(0x66C1, speed) It was essential to define the lenght of the string (the ", 9" in the first line). Best regards, -shorthauler -
Hi folks, I am trying to extract numbers from a string. The string corresponds to the full FCU message, for example SPD240 or MACH 0,78. Let's call the offset where the string can be found 0xABCD. The result shall be written to offset 066C1. As the MACH number is not an integer, I think I should be working with floats. As SPD and MACH have different lengths, I cannot extract from specific positions of the string. spdstate = ipc.readSTR(0xABCD) local speed = string.match(spdstate, "%d+") ipc.writeFLT(0x66C1, speed) end I would like to show the resulting value in a window in FSX, I think I shoud use U32 as a type for logging. But I only receive a 0. Any input is much appreciated. I am reluctant to use the tonumber function as I am afraid I will mess up. Best regards -shorthauler
-
trying to send value to LVAR by button
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Thank you for your comment. I seem to have a lack of understanding - I set up the script in a way that it is triggered only when the button is actuated. I thought this would be more efficient than having ths script running in the background the whole time. Seems I am wrong? Holger -
trying to send value to LVAR by button
shorthauler replied to shorthauler's topic in FSUIPC Support Pete Dowson Modules
Dear John, Problem solved - I had the Lua scrip running continuously due to a faulty Auto entry in FSUIPC.INI My sincere apologies for taking your time! Best regards, Holger -
Hi folks, I have an 8-position-switch (A320 EFIS mode selector), so this corresponds to 8 seperate buttons. I have set up these buttons to call a Lua script ("Control sent when button pressed"). Every button calls the same Lus script but sends different parameters (0, 10, 20, 30, 40). The parameters are supposed to set an Lvar state that will select the respective mode (LSm VOR, NAV, ARC, PLAN). This is for FSUIPC4. Ths Lua script consist of one single line: ipc.writeLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob", ipcPARAM) This is where I started. I have read up on parameters in the Advanced Users, Library and Plug-In documents and all kinds of variations, but to no avail. I am probably missing something very simple here, so apologies in advance. Any input will be much appreciated. Best regards, - shorthauler
-
I might have used the term "virtual buttons" incorrectly. My hardware is connected to an Arduino Mega. As far as I know, there is no direct communication between FSUIPC and Arduino (or at least, it is very cumbersome), so the ways I know to trigger Lua scripts is either by buttons or by way of Mobiflight.