Pass values into child script in headless mode

Typically: "How do I... ", "How can I... " questions
Post Reply
kat
Posts: 13
Joined: 02 Sep 2021, 15:50

Pass values into child script in headless mode

Post by kat »

Hello,
Sorry for the simple question but I've not been able to find how to do it.

Please is there a way to pass a value into the child script when running in headless mode?

Like this:

./coppeliaSim.sh -h -s myscene.ttt <value to pass in>

Code: Select all

function coroutineMain()
 X= <value passed> 
print(X)
 end
So that I can run the same scene with different values without editing the child script?
Best,
Kat

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

Re: Pass values into child script in headless mode

Post by coppelia »

Hello Kat,

yes, you can do this with named parameters and the command-line option -G, e.g.

Code: Select all

./coppeliaSim.sh -GmyValue=hello
Then you can retrieve the value with sim.getStringNamedParam / sim.getNamedStringParam

Cheers

kat
Posts: 13
Joined: 02 Sep 2021, 15:50

Re: Pass values into child script in headless mode

Post by kat »

Thank you, that's just what I was after!

Post Reply