## Creating disc objects? And putting scripts on them at creation time

Typically: "How do I... ", "How can I... " questions
RobAtLab
Posts: 84
Joined: 10 Jan 2018, 17:49

### Creating disc objects? And putting scripts on them at creation time

I need an object in my scene to create disc objects which can then do things for themselves. I want this object to be able to create the discs, then load them with a script. I already know what this script will be, but it has a few variables in it which can have different valeus set at the moment of creation. I have two pieces of trouble.

1. sim.createPureShape doesn't seem to have options for a disc, only cubes. spheres, cylinders and cones. But disc (and plane) primitive objects can be made from the GUI, so surely must be producible from a lua script.

2. How do I get a (non-threaded child) script to appear on the new objects as they are created. It doesn't need to run immediately, if it only starts one or two simulation steps afetr the object is created that is fine. But I've still no idea how to do it.

Thank you

fferri
Posts: 679
Joined: 09 Sep 2013, 19:28

### Re: Creating disc objects? And putting scripts on them at creation time

Hi,

not sure why you can't create those shapes. You always have the alternative option to use sim.copyPasteObjects to duplicate any object that is in the scene.

Then you can use sim.addScript, sim.associateScriptWithObject, sim.setScriptText to add a child script to the object.

Or, if it is always the same script, you can just set it in the original object and control its behavior via user parameters which then you read with sim.getUserParameter.