Achoriham Posted December 6, 2011 Report Posted December 6, 2011 Hi Pete, I'm trying to start two programs on a slave PC. Since years I started them by widecliend's RunReadyx without any problem. The only thing never worked for me there was the OnTop switch, but after some experiments I realized that via Lua the Focus works just fine. So it would be easiest to start these two programs by lua and ext.run or ext.runif. Could you give just the possible simplest example of using these please? thanks in advance Achoriham
Pete Dowson Posted December 6, 2011 Report Posted December 6, 2011 So it would be easiest to start these two programs by lua and ext.run or ext.runif. Could you give just the possible simplest example of using these please? Sorry, I don't understand what there is to show or explain. If you know the pathname to the program you want to run, you just use it as the parameter. What more is there you need? Oh, there is one thing I ought to tell you. In the Lua strings the character \ is used to introduce special characters like "return" (\r), "tab" (\t) and "newline" (\n). So when you need to use it for real, as in a pathname, each use needs to be doubled, like \\. That means it is a real \.. Okay? Regards Pete
Achoriham Posted December 7, 2011 Author Report Posted December 7, 2011 Oh, there is one thing I ought to tell you. In the Lua strings the character \ is used to introduce special characters Hi Pete, Of course the problem was that. Thanks very much! May I have a tiny other question... I wanted to have a Lua function to set a few variables right after FS is started. I tried to use the ipc.elapsedtime() value for that, but nothing happens. Is it actually possible to use it inside a function? regards Achoriham
Pete Dowson Posted December 7, 2011 Report Posted December 7, 2011 I wanted to have a Lua function to set a few variables right after FS is started. I tried to use the ipc.elapsedtime() value for that, but nothing happens. Is it actually possible to use it inside a function? Of course. You can use any library functions in functions, just as you can use any functions in functions. But all the ipc.elapsedtime function does is return the elapsed time, in milliseconds, since FSUIPC started. What are you using it for? How are you calling your function? The plug-in you namee ipcReady.lua is automatically called when FS is "ready to fly", which is presumably too late for you if you want to set something "right after FS is started", but "ipcInit.lua" is executed as soon as FSUIPC is initialised, which is much earlier (though still not "ight after FS is started" which is of course not exactly possible). I'm not sure what you can validly do then, though. Perhaps you should explain a little more? Regards Pete
Achoriham Posted December 7, 2011 Author Report Posted December 7, 2011 But all the ipc.elapsedtime function does is return the elapsed time, in milliseconds, since FSUIPC started. What are you using it for? How are you calling your function? Perhaps you should explain a little more? Hi Pete, Thanks for helping. I tried something like this: inittime = ipc.elapsedtime() if inittime == 100000 then ipc.setbitsUB(0x56BD, 64) ipc.setbitsUB(0x56BD, 128) end Nothing happens... best regards Achoriham
Pete Dowson Posted December 7, 2011 Report Posted December 7, 2011 inittime = ipc.elapsedtime() if inittime == 100000 then ipc.setbitsUB(0x56BD, 64) ipc.setbitsUB(0x56BD, 128) end Nothing happens... Not surprising really, is it? What are the odds of that line in Lua (inittime = ipc.elapsedtime()) being executed just at the one millisecond that the elapsed time, a pretty random but increasing number, happened to equal precisely 100000? If is doesn't happen, which odds are probably almost infinitely against, then the code is skipped to the end and the Lua plug-in finishes its job and exits at the end. I'm really at a loss to understand what you are trying to do. what is so special about the exact moment 100,000 milliseconds after FSUIPC starts running? BTW, instead of ipc.setbitsUB(0x56BD, 64) ipc.setbitsUB(0x56BD, 128) it would be more efficient to set both bits together: ipc.setbitsUB(0x56BD, 192) Regards Pete
Achoriham Posted December 7, 2011 Author Report Posted December 7, 2011 Not surprising really, is it? What are the odds of that line in Lua (inittime = ipc.elapsedtime()) being executed just at the one millisecond that the elapsed time, a pretty random but increasing number, happened to equal precisely 100000? Hi Pete, My fault, as I just wanted to be short here. I also tried: if (inittime > 50000) and (inittime < 70000) then but it was also not working. But better not to be too boring with my silly idea, the thing I want to do is to set a couple of bits xxx.seconds after FS has started. Only once, when FS is ready to fly and all other stuff I need is loaded on the different machines. it would be more efficient to set both bits together: ipc.setbitsUB(0x56BD, 192) Oups, you are right. Many thanks! regards Achoriham
Pete Dowson Posted December 8, 2011 Report Posted December 8, 2011 I also tried: if (inittime > 50000) and (inittime < 70000) then but it was also not working. Again, though, if your Lua program is executed before FSUIPC has been running for 50 seconds, or after 70 seconds, that won't match anything. How are you starting this program, watching the seconds hand on your watch then clicking an assigned button when you think you might catch it? I really don't understand what you are trying to do. It makes no sense to me. Sorry. But better not to be too boring with my silly idea, the thing I want to do is to set a couple of bits xxx.seconds after FS has started. Only once, when FS is ready to fly and all other stuff I need is loaded on the different machines. In that case you'd need to either name it "ipcReady.lua" so it loads when FS is ready, or have it called by a "runlua" statement in such a plug-in, or possibly run it via an [Auto] section in the FSUIPC INI file. And then the easiest thing to do is work out how many seconds you want it delayed after FS is "ready to fly" and use ipc.sleep to wait that long before doing anything. Testing elapsed time really isn't that useful when all you want to do is wait a while. It's for determining the time between events, and stuff like that. Regards Pete
Achoriham Posted December 8, 2011 Author Report Posted December 8, 2011 I really don't understand what you are trying to do. It makes no sense to me. Hi Pete, A few hardware switches in my pit do not auto align with the actual positions as far as the offsets go, so I want to set them to match the hardware position right after FSX started. Is this one better? function Anything() ipc.sleep(120000) ipc.setbitsUB(0x56BD, 192) -- switches end best regards Achoriham
Pete Dowson Posted December 8, 2011 Report Posted December 8, 2011 A few hardware switches in my pit do not auto align with the actual positions as far as the offsets go, so I want to set them to match the hardware position right after FSX started. You can't set offsets "right after FSX started", only when it is ready to fly. Since the ipcReady.lua is automatically run when FSX is ready to fly, why not simple have just the one line: ipc.setbitsUB(0x56BD, 192) -- switches and save it as "ipcReady.lua"? If it only wants to happen when a WideFS client has connected, save it as a Lua file in the same folder as Wideclient instead. Is this one better?function Anything() ipc.sleep(120000) ipc.setbitsUB(0x56BD, 192) -- switches end What calls the function called "Anything"? If those lines are all there is then nothing will happen, will it? Why are you inventing a function with nothing calling it? What is the significance of the two minute wait (120000)? Why 2 minutes? Two minutes from when? How are you running this Lua? Why are you making it so complicated every time? Pete
Achoriham Posted December 8, 2011 Author Report Posted December 8, 2011 You can't set offsets "right after FSX started", only when it is ready to fly. Hi Pete, I meant after FS is ready to fly, just the wording was bad, sorry. Since the ipcReady.lua is automatically run when FSX is ready to fly, why not simple have just the one line: ipc.setbitsUB(0x56BD, 192) -- switches I will just do that, thanks! What calls the function called "Anything"? If those lines are all there is then nothing will happen, will it? Why are you inventing a function with nothing calling it?What is the significance of the two minute wait (120000)? Why 2 minutes? Two minutes from when? How are you running this Lua? I ran it as ipcready.lua. But you are right and nothing happens, because the function is unnecessary. Originally I wanted to have a function that do this approx. 1-2 minutes after FS is ready to fly, that's why I - wrongly - thought the ipc.elapsedtime() could be used for that. Didn't want to use the timer function for this, because it would have done it more than once. Thanks again. regards Achoriham
Pete Dowson Posted December 8, 2011 Report Posted December 8, 2011 I ran it as ipcready.lua. But you are right and nothing happens, because the function is unnecessary. Originally I wanted to have a function that do this approx. 1-2 minutes after FS is ready to fly, that's why I - wrongly - thought the ipc.elapsedtime() could be used for that. Didn't want to use the timer function for this If it starts earlier than you want you can still put a sleep in to delay it. I just couldn't figure out why you were making it a never-executed function, that's all. Regards Pete
Achoriham Posted December 8, 2011 Author Report Posted December 8, 2011 If it starts earlier than you want you can still put a sleep in to delay it. I just couldn't figure out why you were making it a never-executed function, that's all. Hi Pete, Wilco. Many thanks for your help! gratefully Achoriham
Achoriham Posted December 12, 2011 Author Report Posted December 12, 2011 Hi Pete, My humble question is so short and simple that I ask it here: Do you support compiled Lua scrips compiled by luac.exe? regards Achoriham
Pete Dowson Posted December 12, 2011 Report Posted December 12, 2011 Do you support compiled Lua scrips compiled by luac.exe? They should work, but I must admit to never having tested this. Try it and let me know, please. Regards Pete
Achoriham Posted December 12, 2011 Author Report Posted December 12, 2011 They should work, but I must admit to never having tested this. Try it and let me know, please. Hi Pete, I tried it and it seems to be working without problems. I tried before asking of course, but wasn't sure if it was "official". best regards Achoriham
Pete Dowson Posted December 13, 2011 Report Posted December 13, 2011 I tried it and it seems to be working without problems. I tried before asking of course, but wasn't sure if it was "official". That's fine. Glad it works okay. Regards Pete
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