001 Game Creator

001 Game Creator

Not enough ratings
Starting to Script in 001: Beginner's Guide
By AnvilHouse
Learn how to start your journey in 001 using the Script Editor and build a good foundation to continue into advanced scripting.
   
Award
Favorite
Favorited
Unfavorite
An Introduction
Scripting is the core essence of what brings your games to life through interactivity. In this tutorial, you will learn how to use the simple point and click visual scripting environment and go hands on with the mesh that holds 001 scripting together.
Inserting Events
1. At the bottom of the Script Editor window, click Expand Events.
2. Double-click on the Message Box event. You can find this event by doing one of three things:
-1. Select the System category from the list on the left.
-2. Turn off the Specifics, Advanced and Intermediate graph icons (top-left
corner of the window) so only the Basic events are visible.
-3. Begin typing Message Box into the Search box (bottom-left corner of the window) to
filter the amount of events to the one you want.
3. Type something into the Message text box and then click the OK button to close the window. For this tutorial, I wrote: Hello World.

The event will automatically connect to the Start event, which means that when the script plays it will run the Message Box event you just created. If an event is not attached to an existing event, or the Start event, it will not run when the script plays.
Inserting Quick-Access Events
Quick-Access events provide convenience by displaying the most common events one might use.

1. In the right-hand panel, double-click the Message Box event to bring up the Message Box window.
2. Type something into the Message text box and then click the OK button to close the window. For this tutorial, I wrote: Hello World.

Notice how much quicker that was? By having the Message Box event available as a Quick-Access event, we're able to save time by not having to find it in the Expand Events list. You can freely customize this list to display events that you personally make use of most. To customize the list, go to Tools > Options and check the events, that you want to appear as Quick-Access events, from the list in the bottom-left corner of the Options window.
Connecting Events
1. Move the mouse cursor over the line connecting the Start event and Message Box event (a diamond reticle should appear).

2. Right-click the line to detach the Start event from the Message Box event.
3. Left-click and drag on the small node underneath the Start event to create a line that you can then use to connect two events together (the line color will change from black to red).

4. Hover the mouse cursor over the Message Box event and you'll see the line snap to the top of it. Release the mouse button to connect the events.

You've just successfully detached and connected two events. It's worth noting that you can also connect events from the top of a event to the bottom of another event, as well as from the bottom of an event to the top of another event (like we just did).
Managing Events
To Cut/Copy/Paste events:

1. Right-click on the Message Box event to bring up the context menu.
2. Select Cut (Ctrl + X) or Copy (Ctrl + C) to cut/copy the event respectively (both options will send the event to the clipboard but cutting an event will also remove it, whilst copying an event leaves the original intact).
3. Right-click an empty space in the Script Editor and select Paste (Ctrl + V), from the
context menu, to paste the event we just stored in the clipboard.

The duplicated event will have all of the same settings you specified in the original event however it won't be automatically connected to the other events and so it will not run when the script plays, unless it has first been connected to another event.

To Delete events:

1. Right-click on the Message Box event to bring up the context menu.
2. Select Delete (Del) to remove the event from your script completely (if it's connected to other events it will automatically detach from them).

To Undo/Redo mistakes:

1. Right-click an empty space in the Script Editor to bring up the context menu.
2. Select Undo (Ctrl + Z) or Redo (Ctrl + Y) to undo/redo your past action respectively.

You'll be pleased to know that if you accidentally delete an event (which also detaches it from any event it was previously connected to) undoing the action also automatically restores the connection it once had. So you don't have to manually re-connect events that you had previously deleted by mistake.
Inserting Multi-Node Events
A "multi-node" event is an event that has more than one node underneath it - whereas most events only have a single node on the top and bottom.

Once Branch:

1. Insert a Once Branch event from the Quick-Access event panel to the right (or by
clicking on the Expand Events button and finding it under the Structure category).
2. Insert an event and type something into the Message text box that the player will only see
once. For this tutorial, I wrote: You'll only see me once!
3. Left-click the Once Branch event to select it and then insert another event. This time type something into the Message text box that the player will always see after the first one.
For this tutorial, I wrote: You won't see that first message again!

If you've followed the steps above correctly, your script should look like this:

This is an example of a "multi-node" event. The event attached to the left node, of the Once Branch event, will only run once. Every other time the script plays, it will run the event attached to the right node instead.

Switch Operation/Switch Branch:

1. In the same script, or a brand new script, insert a Switch Operation event from the Quick-Access event panel to the right (or by clicking on the Expand Events button and finding it under the Switches category).
2. In the Switch Operation event window, click on the Edit button to open the
Switches window.
3. In the first empty text box below Name, input Toggle_Switch and leave the
Default Value unchecked. Then close the window to return to the Switch Operation
event.
4. Select your newly created switch, Toggle_Switch, from the drop-down menu, next to the
Edit button.
5. Then select the Toggle option directly underneath the drop-down menu. Click the
OK button to close the window.
6. Insert a Switch Branch event from the Quick-Access event panel to the right (or by clicking on the Expand Events button and finding it under the Switches category).
7. Select your switch, Toggle_Switch, from the drop-down menu and then click the OK
button to close the window.

You can now insert events for both the left and right nodes, depending on what you want to happen when the switch is turned on or off. The default value is set to OFF, so when the Switch Operation event is activated it will turn the switch on, meaning that the left node of the Switch Branch event will run first. The next time the script plays the event connected to the right node will run, as the switch will be turned off. The Switch Operation event turns the switch on or off and the Switch Branch checks the state of the switch.
Inserting Sub-Events
A "sub-event" is an event which has its own layer of scripting (a sub-script).

Repeat Loop:

1. Insert a Repeat Loop event by clicking on the Expand Events button and finding it
under the Structure category.
2. Set the Number of Times to 3. Then click the OK button to close the window.

Don't be alarmed! Your script is not gone, you've just entered a new scripting layer - specifically the Repeat Loop script that is contained within the event.

3. Insert a Message Box event and type something into the Message text box. For this
tutorial, I wrote: Look Mom, I'm being repeated! Then click the OK button to close the
window.
4. Left-click the OK button, at the bottom-right of the Script Editor window, to close the
Repeat Loop script and return to your main script.

The Repeat Loop event will appear just like any ordinary event but when double-clicked, it will open up the sub-script you saw earlier. When the script plays, and the Repeat Loop event runs, all of the events inside the sub-script will run for however many times you specified - in this case, 3.

Sub Script:

1. In the same script, or a brand new script, insert a Sub Script event by clicking on the
Expand Events button and finding it under the Structure category.

Upon creating this event, you'll notice that you immediately enter a new scripting layer. This is a literal example of a "sub-event". It's used primarily to organize larger scripts by having events split up into different scripting layers. It's important to note that the properties and behavior of the events stored inside a Sub Script event don't change. It's just a way to help better organize larger, more complicated scripts.
Using Local Variables
Local Variables are used to store data temporarily and are useful for when a variable only needs to be called in the same script and nowhere outside of it.

1. Left-click the Edit Local Variables button, from the bottom-left of the Script Editor
window, to open the Local Variables window.
2. Left-click Add Local Variable in the new window.
3. Type Number_Input into the text box below and leave the Persistent value unchecked. Then close the window to return to the Script Editor window.
4. Insert an Input Box event by clicking on the Expand Events button and finding it
under the System category.
5. Type something into the Message text box. For this tutorial, I wrote: Please enter a number
between 1 and 100
.
6. Select your local variable, Number_Input, from the drop-down menu besides Save Input
Into
. Then click the OK button to close the window.
7. Insert a Comparison Branch event from the Quick-Access event panel to the right (or
by clicking on the Expand Events button and finding it under the Variables/Scripting category).
8. Next to the Expression text box, left-click on the button (known as the Use Value button) to open the Use Value window.
9. Double-click on your local variable, Number_Input, from the Local Variables tree, near the top of the list (click on the small + button besides Local Variables to expand the list).
10. Then select > (Greater Than) from the Operator drop-down menu.
11. Set the Value to 50 and then click on the OK button to close the window.

You can now insert events that will run depending on the result of what the user inputs. If the number is greater than 50, the left node of the Comparison Branch event will run. If the number is less than or equal to 50, the right node of the Comparison Branch event will run. The number that the user inputs will be stored inside the Local Variable we created (Number_Input).
Using Use Values
Use Values are used to retrieve data, so that they can be used in scripting. You might have noticed that we used a use value above, in the Local Variables section. We're now going to take a closer look at Use Values by demonstrating two basic examples of how they can be used.

Check whether player has enough gold:

1. Insert a Comparison Branch event from the Quick-Access event panel to the right
(or by clicking on the Expand Events button and finding it under the Variables
category).
2. Next to the Expression text box, left-click on the button (known as the Use Value
button) to open the Use Value window.
3. Type: money into the Search box, at the top, and double-click on the Amount of
Money
use value under the Main Party / Game section.
4. Then select >= (Greater Than or Equal) from the Operator drop-down menu.
5. Set the Value to 100 and then click on the OK button to close the window.

You can now insert events that will run depending on the data retrieved. If the player's current money is greater than or equal to 100, the left node of the Comparison Branch event will run. If the player's current money is less than 100, the right node of the Comparison Branch event will run. This is an example of how use values can be used to retrieve data and then use that data to compare it to a value.

Display Total Time Played to player:

1. Insert a Message Box event and type something into the Message text box to
inform the player of how long they've played the game for. For this tutorial, I wrote: Did you
know you've been playing for:

2. Left-click on the button, above the Message text box, to open the Use Value window.
3. Type: time into the Search box at the top, and then double-click on the Amount
Time Played (00:00:00)
use value under the Main Party / Game section.

4. Click on the OK button, at the bottom of the Message Box window, to close the window.

When you play your game, the \V[Main.PlayTimeSemicolon] use value will change to retrieve the amount of time played and relay it to the player. This is an example of how use values can be used to retrieve data and present it to the player.
Conclusion
With your newfound knowledge of 001 scripting and general workflow you now have the tools to continue onward towards more advanced scripts and features for your projects. This foundation is used constantly within 001 and will be your key to unlocking your potential as an 001 engine user.