SkookumScript commands can be typed and run on live projects on any platform using SkookumIDE command consoles called Workbenches – a form of a “read evaluate print loop” (REPL).
More sophisticated SkookumScript commands are often grown and tested in a Workbench before they are wrapped up into reusable routines. People also swap around these handy code snippets via chat, email, posting online, etc.
- The basics
- Work through the “Tutorial Workbench”
Several of the script examples on this page assume that you are using the SkookumScript Unreal Engine 4 Plugin and the example SkookumDemo project that comes with it though many of the examples will work for any project. See the Unreal Engine 4 Plugin installation and setup instructions for more information.
Ensure that the runtime is started when you evaluate commands. If the runtime is not started, various game data may not be available or the commands may queue until it starts.
In a long-standing programming language manual tradition, we begin with the minimal amount of code needed to print something:
The SkookumIDE Workbench widgets allow you to run code snippets on any connected and running project. Type (or copy and paste)
"Hello World!" into the Workbench (REPL), then open the Build menu option and select Execute Selection on Runtime.
In the Log widget you should see the following printed out:
Simple, eh? No includes, mucking about with files, making classes, nor other typical language red-tape or bookkeeping is needed.
SkookumScript prints out the
result of any script that is evaluated (or executed, run, called, invoked – whatever term you prefer).
NOTE You may have noticed that there are two Workbench widget tabs - the REPL and the Tutorial. The REPL Workbench is writeable, saves your changes and reloads with each launch of the SkookumIDE. The Tutorial Workbench is read-only since the example code snippets that it contains are frequently changed by the mad computer scientists on the SkookumScript team and any of your own custom code snippets would be lost with each update. You can still evaluate the Tutorial example code snippets or copy them over to the REPL Workbench if you want to edit them.
TIP: F4 is a keyboard shortcut for evaluating code. You can place the edit caret anywhere on a line and press F4 to evaluate the whole line or select some text even across multiple lines and whatever is selected is evaluated when you press F4. Using these mechanisms, you can evaluate any selection or line of text that parses correctly.
You can enter math into a Workbench. The SkookumIDE is a great calculator.
6 * 7
This is actually really useful. We mad computer scientists use it all the time.
NOTE Only the last expression is displayed as a result in the Log widget. Any results from expressions before the last expression will be ignored. If you want to use or see results from expressions that come before the last expression, you will have to store them in variables, pass them as arguments to routines or print them out.
All commands entered into a Workbench are run on an instance of the SkookumScript project’s default
Mind object - it is the inferred
this for any command. So when you evaluate code, it looks for routines and data in the project’s default
Mind object and then its superclass and then the superclass of its superclass and so on. Every project can have its own customized
Also see Mind objects and the Master Mind for more information on mind objects.
TIP: Since a result is often something you want to reuse, there are some hotkeys to help you copy it around:
- Alt+Insert pastes the most recent result string into the currently focused Workbench widget at the caret position
- Alt+Ctrl+Insert copies the result string from the currently focused Workbench widget into the system clipboard
What is a REPL?
Many languages call the ability to interactively evaluate code a read-eval-print loop or REPL and it is traditionally accomplished with a simple interactive command line prompt
>. These REPLs read in a command, evaluate it, print out the result (usually in the same console) and then loop all over again with any new command. Since this is the 21st Century, SkookumScript’s Workbench widgets use a more sophisticated text edit box that can accommodate multiple lines of commands and easily allow you to scroll around. It also saves all your commands for later use, which can be very handy. While this is more than a traditional REPL, we still call it a REPL since it serves essentially the same purpose and people looking for a “REPL” will find it when searching information about the SkookumIDE.
You can also call SkookumScript on the command prompt if you need to – for example to evaluate SkookumScript commands from non-SkookumSript applications such as text editors. See the SkookumIDE Command line arguments page.
Printing to the Log
If you would like to print something other than a result to the Log widget, you can put it in a
println() command, which prints out one or more objects and adds a line break (hence the
ln for “line” at the end). Printing is an essential and versatile tool for any programmer’s toolbox.
While the result of the simple
6 * 7 earlier was the number
42, the result of a
println() command is
nil is an object that essentially represents nothing or the absence of a value.
nil, or something like it, is common in many languages (Smalltalk, Lisp, Objective-C, Ruby). It goes by several different names, such as
nullptr (C++), and
TIP Those with a sharp eye may have noted that the
println() command prints out one or more objects.
println("The answer: " 42 " and running on object: " this)
The answer: 42 and running on object: 'SkookumDemo'
You can cram in as many arguments to
println() as you like and they are all converted to strings and joined together. All SkookumScript objects know how to convert themselves to a string to get a textual representation of themselves.
println() command above is called with 3 arguments: a string, a number and another string. SkookumScript arguments do not need to be separated with commas
, – the parser automatically figures out where one argument ends and another begins. You can use commas if you think it makes things easier to read, though they aren’t necessary.
When you evaluate several commands at once, they will be called one after the other (in sequence).
println("Hello, world!") println("I'll be your megalomaniacal overlord for today.")
SkookumScript also does not need an end of line or end of expression / statement delimiter such as a semi-colon
; like most C/C++ languages. Some amount of whitespace between each expression is all that is needed.
Select both lines with the mouse or keyboard, and then press F4.
I'll be your megalomaniacal overlord for today.
The file that stores the text for the Workbench (REPL) widget is located at
SkookumIDE\Scripts\workbench.sk and it is saved with your latest changes every time you evaluate a line of code or after some time passes since it was changed. You can also save it manually by pressing Ctrl+S or by shutting down the SkookumIDE.
If you open the context menu for a Workbench, you can select Show in Explorer (or use the hotkey Cltr+Shift+E) to open up the file in the Windows File Explorer or Open in External Editor (or use the hotkey Cltr+E) to open up the file in Your Favorite Editor™. It will use whatever default application that you associate with the SkookumScript
.sk file extension.
The file for the Tutorial Workbench is located at
SkookumIDE\Scripts\tutorial-workbench.sk and it can also be opened up in an external editor or via the Windows File Explorer by using the context menu or hotkeys.
All these handy Workbench code snippets are reloaded and ready to be reused the next time you run the SkookumIDE.
Language warnings and errors
Errors are something you must embrace if you wish to become an awesome coder. No matter how awesome you get, you will always have errors—though your errors will become progressively more interesting.
The SkookumIDE will helpfully alert you whenever it detects what may be an error and helps visualize it with, different colorizations, red underlines, mouse hover info and more.
Since errors will be a frequent companion and patient teacher, we recommend that you take a look at the Parser error checking page and then return filled with knowledge of error notification goodness.
Work through the “Tutorial Workbench”
Here is a simple command to ensure your project is running in the UE4 editor and it is ready to receive commands from the SkookumIDE:
Paste/type the command into the Workbench (REPL), have the caret on the line or select/highlight the text and press F4. The location of the player should be printed in the Log widget and will look something like this:
(770, -345, 322.25)
Now take a moment and read through these examples illustrating some basic concepts of SkookumScript. All these examples can be found already entered in the Tutorial Workbench.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
1 2 3 4 5 6 7 8
You can see more SkookumScript code examples at Rosetta Code which also shows the same examples in many other languages for comparison.
Get more in-depth with the SkookumScript language by going to (or returning to) the SkookumScript Primer.