Lua Script input and output

Typically: "How do I... ", "How can I... " questions
zhy149
Posts: 74
Joined: 14 Apr 2021, 20:18

Lua Script input and output

Hello,

Is there a way to do console input in Coppeliasim? Can I open a text file or other files inside a child script and write to a file?
Thank you very much!

fferri
Posts: 781
Joined: 09 Sep 2013, 19:28

Re: Lua Script input and output

If you mean to read standard input, you can do so in a plugin, but it is not recommended as it is not a modular solution (what if another plugin reads from stdin as well?).

If you need input from the user, you can use the UI plugin.

If you need input/output with external applications, you can read/write files in Lua with the io module, or use one of the many means of communication which are often better than text files.

coppelia
have also a look at sim.textEditorOpen and similar functions.