Category | Scripting |
Created | 13.11.2019 07:44 |
Geni Meier (Gemini0915) | 13.11.2019 07:44 |
---|---|
Hi there, I want to build a tractor cockpit with displays, gauges and indicators. As i know the lua interpreter is running in a 'sandbox mode', so some lua functions are not available. My inelegant solution would be writing data (e.g. speed, rpm, torque, etc) into a data file on a RAM-disk, read the data with an external script (Python) and send it to the cockpit hardware via a serial interface. Of course there will occur an error if the file is already open by a script and the other tries to open it. I found in the lua reference the error handler function pcall, but all trials to get this function to work failed (without any error message). Long story, short question : Is the pcall function available for lua scripts in the GIANTS engine ? |
Bilbo Beutlin (BBeutlin) | 13.11.2019 10:46 |
---|---|
Quite simple: if you can't use it, it isn't implemented. In practice that is no problem. You should launch the write procedure via a timer, let's say 2-5x per second. That's way enough for an external program to read the datas. For safety you may enclose the read/write procedures in a loop "repeat ... until (no_error)". |
Geni Meier (Gemini0915) | 13.11.2019 13:28 |
---|---|
Got it ! ... Many thanks for your reply and the hint :) |
Note: Log in to post. Create a new account here.