FSlikerX Posted August 26, 2015 Author Report Posted August 26, 2015 Sorry, I've no idea whatsoever what the names in that SDK section refer to. If they are Lvars (local panel variables, often named with L: beforehand), then, yes, Lua can read the values But names are strings, so it should look like ALT_value = ipc.readLvar("AB_AP_ALT_Select") You'll need to read and understand the SDK to decide, I think. Pete Okay thank you soooo much :)Is it possible to convert this LUA-script-final-value to an FSUIPC Offset?
Pete Dowson Posted August 26, 2015 Report Posted August 26, 2015 Okay thank you soooo much :) Is it possible to convert this LUA-script-final-value to an FSUIPC Offset? You'd need to write it to a User Offset (one in the range 66C0-66FF). There are Lua ipc Library functions for writing to offsets. Pete
FSlikerX Posted August 26, 2015 Author Report Posted August 26, 2015 You'd need to write it to a User Offset (one in the range 66C0-66FF). There are Lua ipc Library functions for writing to offsets. Pete Does the lua script have to do something else:1st: read the LVAR with ALT_value = ipc.readLvar("AB_AP_ALT_Select") 2nd: return the ALT_Value 3th: that's it ??
Pete Dowson Posted August 26, 2015 Report Posted August 26, 2015 Does the lua script have to do something else: 1st: read the LVAR with ALT_value = ipc.readLvar("AB_AP_ALT_Select") 2nd: return the ALT_Value 3th: that's it ?? Er, where are you "returning" the value to? I have no idea what you are attempting to do. Pete
FSlikerX Posted August 26, 2015 Author Report Posted August 26, 2015 Er, where are you "returning" the value to? I have no idea what you are attempting to do. Pete oh I'm sorry...I was allread on step ahead. May I ask you first: What the normal Offset for importing such a LVar would look like (How to write it, that FSUIPC is posible to read it - just a normal lua script?) ?
Pete Dowson Posted August 26, 2015 Report Posted August 26, 2015 What the normal Offset for importing such a LVar would look like (How to write it, that FSUIPC is posible to read it - just a normal lua script?) ? There are no 'normal offsets" for L:Vars! The L:Vars are LOCAL to specific gauges. I cannot include in FSUIPC a general facility for all possible LVars in all possible add-on aircraft! As you've already been told, you can READ or WRITE LVars, once you know their names in Lua plug-ins. If you need a value in an offset, write the result of reading one to an offset. I already told you this, and I also told you that you can use the offsets 6C00-6CFF which are reserved for general uses like tihs. Pete 1
FSlikerX Posted August 26, 2015 Author Report Posted August 26, 2015 Would this work? function ALT_set(offset, value)ALT_set = ipc.readLvar("AB_AP_ALT_Select")end event.offset("66C0", "ALT_set")
Pete Dowson Posted August 26, 2015 Report Posted August 26, 2015 Would this work? function ALT_set(offset, value) ALT_set = ipc.readLvar("AB_AP_ALT_Select") end event.offset("66C0", "ALT_set") No! Please please do read the Lua library documentation! The event library is there to call a function in the Lua plug in when something happens! event.offset("66C0", "ALT_set") is actually wrong in any case, You missed a parameter out! which specifies the type of value being tested. A more correct line: event.offset("66C0", "UW", "ALT_set") would tell FSUIPC to call a function called ALT_set when the Unsigned Word at offset 66C0 changes. You have no function called ALT_set and you are not writing anything to 66C0. I think you are completely out of your depth, or just haven't actually studied the documentation or any of the many examples provided for you, to help. Writing to offsets is done by other functions in the ipc library. Please go and look them up. Pete 1
FSlikerX Posted August 26, 2015 Author Report Posted August 26, 2015 Ohh well Thank you for your answer... I think that was just a result of copy and paste (without checking it :/ ) Do you mean: ipc.writeUW(66C0, ALT_set) Ofcause it has to write not to call the Offset...
Pete Dowson Posted August 26, 2015 Report Posted August 26, 2015 Do you mean: ipc.writeUW(66C0, ALT_set) Closer, but 66C0 will not work as it stands as it looks like a decimal 66 with C0 stuck on. It's a hexadecimal number and needs 0X in front of it (or quotes round it). ipc.writeUW(0x66C0, ALT_set) If you had started out just stating what it was you were trying to do, which you still haven't done, it might have been quicker. Why do you want the value in an offset in any case? Pete 1
FSlikerX Posted August 27, 2015 Author Report Posted August 27, 2015 :) So the the scripts basic: ALT_set = ipc.readLvar("AB_AP_ALT_Select") ipc.writeUW(0x66C0, ALT_set) Does LUA need a funktion arround these two commands to be run? -I`m accustomed to JAVA- The first reason why I want the vallue in an offset: As I allready said at the beginning of this topic I`m looking forward to buy the Arcaze Display-driver set and therefor I need a possibility to `export` the Variables out of the Airbus to the FSUIPC-Connector (the word allready the function: It shows the values of an FSUIPC-offset [that`s why I need an offset :)] on the 7-segment-display) and for the 2nd reason: I am going to write a pogramm like LINDA for the Airbus which export all possible variables for example to show tehm on a display... Cuold you tell me, if there is a standart offset the coordinates of the flying airplane?
Pete Dowson Posted August 27, 2015 Report Posted August 27, 2015 So the the scripts basic: ALT_set = ipc.readLvar("AB_AP_ALT_Select") ipc.writeUW(0x66C0, ALT_set) Does LUA need a funktion arround these two commands to be run? -I`m accustomed to JAVA- Not if you are simply doing the action once, with the plug-in being assigned to a button or keypress. Think of the plug-in as a sequence of commands as in a BATch file, or a Visual Basic script. Depending on what you need it for you can turn it into a continually running program, based on events, and have it loaded automatically (even according to aircraft profile) using the [Auto] sections of the FSUIPC INI file. You do really REALLY need to look at the Lua plugin documentation and the examples in your FSUIPC Documents folder. Cuold you tell me, if there is a standart offset the coordinates of the flying airplane? Yes. Such information is easily found in the Offsets Status document. Why not look? Pete
FSlikerX Posted September 6, 2015 Author Report Posted September 6, 2015 Hi, Thank you for all these awesome tips.. okay so now I have another script but it doesn`t print out anything... --------------------------- -- lua script exporting QNH in (another) FSUIPC-Offset QNH_cur = (ipc.readDD(0x0330)/16) BaroSTD_cur = ipc.readLvar("AB_MPL_Baro_STD") -- AB_MPL_Baro_STD is LVar, that indicades if Pressure is set to standart -- =1 means the pressure should be standart(1013hpa); =0 means manual pressure if (QNH_cur ~= QNH_pre and BaroSTD_cur = 0) then QNH_pre = QNH_cur ipc.display("QNH_cur") ipc.writeUW(0x66C0, QNH_cur) end elseif (BaroSTD_cur ~= BaroSTD_pre and BaroSTD_cur= 1) then QNH_cur = 8888 BaroSTD_pre = BaroSTD_cur -- 8888 simulate the standart pressure ipc.display("QNH_cur") ipc.writeUW(0x66C0, QNH_cur) end ipc.sleep(10) ------------------------------- First off all I simply wants to write the QNH Value in another offset :smile: By the way: ofcause I wrote the script in the [Auto] part... FSlikerX
Pete Dowson Posted September 6, 2015 Report Posted September 6, 2015 -- lua script exporting QNH in (another) FSUIPC-Offset QNH_cur = (ipc.readDD(0x0330)/16) Well, there's an error already, in the first line already! Offset 0x330 is most certainly NOT a 65-bit signed number. 64 = 8 x 8 = 8 bytes. Why not actually check the offset details in the list. You'll see 0x330 is 2 bytes = 16 bits = a word. And because the pressure cannot be negative it is unsigned, so "UW". if (QNH_cur ~= QNH_pre and BaroSTD_cur = 0) then Second error. "BaroSTD_cur = 0" will set that variable to zero. Comparison is ==. Please do be more careful. Programming is a precise practice -- garbage in, garbage out. I'm not sure what you want to do with this: ipc.display("QNH_cur") but it will simply display the text "QNH_our". Did you want the value instead? "" denote text strings. The same errors are repeated later. Not sure what you want 8888 to represent. Pete
FSlikerX Posted September 8, 2015 Author Report Posted September 8, 2015 Not if you are simply doing the action once, with the plug-in being assigned to a button or keypress. Think of the plug-in as a sequence of commands as in a BATch file, or a Visual Basic script. Depending on what you need it for you can turn it into a continually running program, based on events, and have it loaded automatically (even according to aircraft profile) using the [Auto] sections of the FSUIPC INI file. You do really REALLY need to look at the Lua plugin documentation and the examples in your FSUIPC Documents folder. Yes. Such information is easily found in the Offsets Status document. Why not look? Pete Provides FSUIPC a possibility if the simulator is ready to call a Lua file again and again after a certain time ? Because as far as I know [ auto] doesn`t call this the lua multiply ?! I apologize again for the beginner fails... FSlikerX
Pete Dowson Posted September 8, 2015 Report Posted September 8, 2015 Provides FSUIPC a possibility if the simulator is ready to call a Lua file again and again after a certain time ? Because as far as I know [ auto] doesn`t call this the lua multiply ?! You are taking this out of context. You asked if it should be in a function. That was my answer. And no, nothing will call your plug-in again and again after a certain time UNLESS you use an event which will do this. THEN you need your code to be in a function. If you want a function to be called every 5 seconds, for instance, you would use event.timer(5000, "name of your function") [Auto] run plug-ins suit simple scripts needed only once OR scripts which stay resident and activate on events. Otherwise plug-ins are assigned to do actions in response to button presses, switches or axis movements. Pete
FSlikerX Posted September 9, 2015 Author Report Posted September 9, 2015 You are taking this out of context. You asked if it should be in a function. That was my answer. And no, nothing will call your plug-in again and again after a certain time UNLESS you use an event which will do this. THEN you need your code to be in a function. If you want a function to be called every 5 seconds, for instance, you would use event.timer(5000, "name of your function") [Auto] run plug-ins suit simple scripts needed only once OR scripts which stay resident and activate on events. Otherwise plug-ins are assigned to do actions in response to button presses, switches or axis movements. Pete Okay :) That`s perfekt... Thanks When does FSUIPC call the scripts in the [auto] section? When the sim is fully loaded?
Pete Dowson Posted September 9, 2015 Report Posted September 9, 2015 When does FSUIPC call the scripts in the [auto] section? When the sim is fully loaded? Yes, when "ready to fly". You can have [Auto.<name>] sections for specific Profiles. Those are loaded when any aircraft associated with the named profile is loaded, and any plug-ins loaded are then terminated when the aircraft is changed. Note that the [Auto] sections are for any macros to be executed as well as Lua files loaded. Pete
FSlikerX Posted September 23, 2015 Author Report Posted September 23, 2015 Hi, which type of value (Uw, UB, UD,...) is used to read the availible FS memory (Offest: 024C)?
Pete Dowson Posted September 23, 2015 Report Posted September 23, 2015 which type of value (Uw, UB, UD,...) is used to read the availible FS memory (Offest: 024C)? 024C is documented as 4 bytes, (4 x 8 = 32 bits, so a DWORD, or double word) and it cannot be negative, so it must be a UD. This reference to a thread about numbers in the FAQ subforum will be useful: http://forum.simflight.com/topic/63908-about-bits-numbers-and-hexadecimal/ Pete
Gaurav Posted May 4, 2018 Report Posted May 4, 2018 Hi guys, I am completely new to LUA scripts. Need some support for a sample script. I can modify the sample and create copies for multiple actions. Can someone please help me with a sample script for setting ADRIS to NAV position in Aerosoft A320 addon. Based on the link shared in this thread, i got this:
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