February 5, 20197 yr Hi, I trying to store a simple value in a local variable in the following Lua code. the code: !Lua -- get the L:var value local val = varget("L:myVar","Number") val = val + 1 -- store value in L:var varset("L:myVar","Number",val) This code is used for material scripting (P3D v4.2) but it's seems doesn't work. Is it possible to store a new value in a local variable and re-read it at each execution of this code? Thanks by advance.
February 5, 20197 yr local val = varget("L:myVar","Number") should be val = varget("L:myVar","Number") varset("L:myVar","Number",val) should be varset("L:myVar”,val) Edited February 5, 20197 yr by bbuckley [CPL] : I9-9900K @5.0GHz HT ON, Maximus XI Hero, ASUS TUF RTX4080 OC, 32GB DDR4 3200 14, 1TB NVMe SSD, 500GB SSD, 1TB HDD, 40" Samsung 4K TV, Honeycomb Alpha & Bravo, Logitech Rudder Pedals, WIN11
February 5, 20197 yr Author Hello buckley, thanks for your quick answer, but I tried and it does not work, so I have a question, do I have to instantiate (L: myVar) before trying to get its value and if so where?
February 5, 20197 yr L variables are set to zero by default.. so the first varget should get you zero. You can set it: varset("L:myVar",0) Edited February 5, 20197 yr by Bert Pieke Bert
February 5, 20197 yr 18 hours ago, bbuckley said: varset("L:myVar”,val) This varset statement has two different quote marks... " " Could be a problem if copied/pasted Bert
February 6, 20197 yr 3 hours ago, Bert Pieke said: This varset statement has two different quote marks... " " Could be a problem if copied/pasted My bad. I copied and pasted OPs text and didn’t notice the different quotes. @bokdany make sure you correct that in both statements. Edited February 6, 20197 yr by bbuckley [CPL] : I9-9900K @5.0GHz HT ON, Maximus XI Hero, ASUS TUF RTX4080 OC, 32GB DDR4 3200 14, 1TB NVMe SSD, 500GB SSD, 1TB HDD, 40" Samsung 4K TV, Honeycomb Alpha & Bravo, Logitech Rudder Pedals, WIN11
February 6, 20197 yr Looking at it again zoomed, I think the second quote came from my iPad in the reply box. In any event, just type them both correctly in your text editor. Edited February 6, 20197 yr by bbuckley [CPL] : I9-9900K @5.0GHz HT ON, Maximus XI Hero, ASUS TUF RTX4080 OC, 32GB DDR4 3200 14, 1TB NVMe SSD, 500GB SSD, 1TB HDD, 40" Samsung 4K TV, Honeycomb Alpha & Bravo, Logitech Rudder Pedals, WIN11
February 6, 20197 yr Author Thanks alot for your replies, but i think that i have a another kind of problem because i did many different try without results, this script is called by a material who normally can access to local variables but its seems that i can read and write within some material variables and some simulation variables but not in local variables. I precise that i use P3D v4 with sdk 4.4.16.27106. Edited February 6, 20197 yr by bokdany
Archived
This topic is now archived and is closed to further replies.