I'm trying to create a scene with randomly scattered simple obstacles (for now, only static cuboids of fixed size). I achieve this by attaching a non-threaded child script to the cuboid object and write it's init function as follows (object is called Cuboid01):
Code: Select all
function sysCall_init()
cuboidHandle = sim.getObjectHandle('Cuboid01')
gndHandle = sim.getObjectHandle('ResizableFloor_5_25')
position = {math.random()*20-10,math.random()*20-10,0.5}
orientation = {0,0,math.random()*math.pi/2}
sim.setObjectPosition(cuboidHandle,gndHandle,position)
sim.setObjectOrientation(cuboidHandle,gndHandle,orientation)
end
Code: Select all
Lua runtime error: [string "CHILD SCRIPT Cuboid01#0"]:29: Object does not exist. (sim.getObjectHandle)
stack traceback:
[C]: in function 'getObjectHandle'
[string "CHILD SCRIPT Cuboid01#0"]:29: in function <[string "CHILD SCRIPT Cuboid01#0"]:1>
Any help with this will be appreciated. Thanks!When you duplicate Cuboid01, the copy will be named Cuboid01#0. In that case the duplicated script remains identical to the original script, however the duplicated script will know that is must access Cuboid01#0 and not Cuboid01.