Is it possible to call a function from a separate Python script even if the whole project is in Lua?

Typically: "How do I... ", "How can I... " questions
Post Reply
coder212
Posts: 7
Joined: 10 Sep 2021, 13:29

Is it possible to call a function from a separate Python script even if the whole project is in Lua?

Post by coder212 »

I use Lua in my project. But there is a task I need to be done, which I cannot find a way to code it Lua so I coded it with Python. Is it possible to call a function from a separate Python script using Lua?

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Is it possible to call a function from a separate Python script even if the whole project is in Lua?

Post by coppelia »

Hello,

normally the approach you would take is to write a plugin that offers the missing functionality, via a new script command, e.g.

Code: Select all

local outArg1,outArg2,...=simMyPlugin.doSomeTask(inArg1,inArg2,...)
If you have an external application (i.e. not running in CoppeliaSim), then you have several ways to handle this via a means of communication.

E.g. using the ZeroMQ functionality (in the linked example, you would have the requester in a CoppeliaSim script, and the responder running in Python and handling requests from CoppeliaSim.

Cheers

Post Reply