Example Setup enabling you to sample the Scripting Clipboard scripts quickly:
Here's an example setup of a Simmetri show. These instructions will guide you through how you can copy, paste and adapt this these scripts to make thing interesting in your Simmetri world.
It involves:
- A blue box and pink sphere. When pressed, the blue box makes something happen on the pink sphere -- almost as if the box is a button.
- The blue box has an 'interactable' attribute enabling it to be pressed/clicked ( it now has an "onPress()" event ) and calls a function(script). [ Click here for more on "event functions"]
- The onPress() 'event' has a script associated with it. This script is called when the event takes place. All 'events' work this way. A trigger has onEnter() and onExit() event functions, each called when something crosses its boundary in that way: entering or exiting.
- The sphere gets acted on in the script.
- First you need to choose a way to access your sphere in the script.
- In this example we use drag and drop of the sphere icon into the script to get access to it.
- The script titles the accessing object representation "SphereEntity" in a line "SphereEntity = findObjectByUID("....")" [click here for more on accessing objects]
- The UID is specific to that sphere. The name "SphereEntity" is a placeholder, it can be whatever you want it to be...whatever will help you remember or organize these objects in script. It can be "object" if you want it to be. It can be ... "davidPumpkins".
- Now we're ready to copy and paste from the Scripting Clipboard (or other scripting docs).
- The line or lines of code we paste in from the clipboard will be acting on an object called "object". You can change that to SphereEntity. Or change SphereEntity to object. Or change them both to "davidPumpkins" ... whatever you like. Just know that to get the action from our sphere, we need a variable name connected to the "findObjectByUID" and the same variable name replacing "object" in the scripts you paste in from the Scripting Clipboard.
Step 1. Create The Objects.
- Draw a box and a sphere. Make them different colors.
Step 2. Setup the Interactivity. Blue box is interacted with, causes action on sphere.
- Add 'interactable' attribute to the box.
- Select the 'interactable' attribute in the property panel, and select "onPress()" in the right pane.
- The onPress() event script opens in the script editor.
- Drag the sphere's property icon into the script inside the function (above 'end' line, but after 'function' line)
- The new line appears: "SphereEntity = findObjectByUID("...")"
- "SphereEntity" is the script variable name for doing things to you sphere. But you can change that name to 'object' or whatever you want.
Step 3. Copy and paste what you want from the Scripting Clipboard.
- Navigate to the Scripting Clipboard.
- Copy only the lines inside functions. Don't copy and red 'function...' of 'end' lines.
- Copying in green ' --comment here' lines is totally fine. Those are comments and aren't run as code.
- In the script window, clear a few new lines (enter, enter) to prepare a place.
- Paste in the script.
Step 4. Make the variable names the same.
- Option A) Change your "SphereEntity = ..." line to "object = ..."
- Option B) In your pasted in line, change "object" to be the same as your object name "SphereEntity" in this case.
- Option C) Change both names to be something particular: "davidPumpkins" for example.
Comments
0 comments
Please sign in to leave a comment.