passing parameters

Typically: "How do I... ", "How can I... " questions
Post Reply
IRIIWU
Posts: 9
Joined: 11 Jul 2017, 21:53

passing parameters

Post by IRIIWU » 27 Jul 2017, 18:10

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.

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

Re: passing parameters

Post by coppelia » 28 Jul 2017, 10:49

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

Post Reply