Page 1 of 1

passing parameters

Posted: 27 Jul 2017, 18:10
by IRIIWU
Hey Coppelia,
How would you pass some variables from one child script to another? for eg I have a table from one child script which I want to access from another. Any help would be great.

Re: passing parameters

Posted: 28 Jul 2017, 10:49
by coppelia
Hello,

you have several ways of doing this. You can call simSetScriptVariable, simCallScriptFunction, or you can also use following method:

You can have objectA write a value into objectB with:

Code: Select all

local myVariable={}
myVariable.openGripper=true
simWriteCustomDataBlock(objectB,'myData',simPackTable(myVariable))
and check on a regular base in objectB that value with:

Code: Select all

local data=simReadCustomDataBlock(objectB,'myData')
if data then
    local myVariable=simUnpackTable(data)
    if myVariable.openGripper then
        ...
    else
        ...
    end
end
Cheers