Welcome to the handy-dandy SkookumScript Primer–your first step up the superbly spiralling spiral staircase to scripting supremacy!
- Initial Installation
- SkookumIDE Workbench basics
- Language warnings and errors
If you haven’t done so already, now is the time for you to install either the Stand-alone SkookumDemo (a fast and easy install that allows to you check out SkookumScript without installing a game engine) or the SkookumScript Unreal Engine 4 Plugin (a longer and more involved setup that also involves setting up Unreal Engine 4 and its game editor), plus the SkookumDemo project (which must be downloaded separately).
- Install and familiarize yourself with the Stand-alone SkookumDemo here.
- Install and familiarize yourself with the SkookumScript Unreal Engine 4 Plugin and SkookumDemo project here.
Both the SkookumScript UE4 Plugin and UE4 itself can be downloaded as pre-built binaries, or you can build them yourself, which enables you to pull them apart and put them back together according to your liking, as well as contribute fixes and improvements.
If you have any difficulties getting up and running, get thee to the SkookumScript Forum, where SkookoumScript staff and our user community will help you out.
SkookumIDE Workbench basics
In a long-standing programming language manual tradition, we begin with the minimal amount of code needed to print something:
The SkookumIDE Workbenches allow you to run code snippets on any connected and running project. Type (or copy and paste)
"Hello World!" into the Workbench (REPL), and right click on it to bring up the context menu. Choose “Compile & Debug” → “Execute Line”. In the IDE Log (by default the upper pane of the Console) you should see the following printed out:
Note that the Tutorial Workbench is read-only since we frequently change its contents and any code changes you made would be lost with each update. You can still execute the example code snippets or copy them over to the Workbench (REPL) if you want to edit them.
SkookumScript prints out the result of any script that is executed (or evaluated, run, called, invoked—whatever you prefer). Many languages call this a read-eval-print loop (REPL) and it is traditionally accomplished with a simple command line prompt. These REPLs read in a command, evaluate it, print out the result and then loop all over again with any new command. Since this is the 21st Century, SkookumScript’s REPL uses a spacious text edit box that can accommodate multiple lines of commands. It also saves all your commands for later use, which can be very handy.
Stringing you along
Zero or more characters between double quotes
" is known as a string. The string itself is the characters between the double quotes; the string including the quotes is a string literal. A string with zero characters
"" is an empty string.
If you would like to print something other than a result to the Log, 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).
F4 is a keyboard shortcut for executing code. You can place the edit caret anywhere on a line and press
F4 rather than go through the context menu.
You will see:
Hello, world! nil
The result of a
println() command is
nil, which is essentially an object that 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
When you execute 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.")
Select both lines with the mouse and/or keyboard, and then press
Hello, world! I'll be your megalomaniacal overlord for today. nil
So, using these mechanisms you can execute any selection of text that parses correctly—including a portion of a single line, or multiple lines—as well as an unselected line that the caret is on.
You can enter simple math into a Workbench. The SkookumIDE is a great calculator.
6 * 7
The string version of the result will be printed to the Log:
Since a result is often something useful you want to paste back into a Workbench,
Insert pastes the most recent result string into a Workbench at the caret position.
Insert copies the result into the system clipboard.
Every time you execute a line of code in a Workbench, press
S, or shut down the SkookumIDE, the
SkookumIDE\Scripts\workbench.sk file is saved with your latest changes. All these handy code snippets are then ready to reuse 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—but your errors will become progressively more interesting.
Warnings and errors are two of the hippest and coolest things about SkookumScript. Developers experience warnings and errors every day, and it pays to have a good workflow associated with them. Before attempting to run your code, the SkookumScript parser does as much up-front work as possible to detect errors. SkookumScript can detect over 150 kinds of errors, and issue seven different warnings of varying sternness. (Don’t worry, you’ll experience them all eventually.)
This section is copied from the Parser error checking page.
Lexical (spelling) errors
Everybody makes typos (or as Computer Science PhDs prefer to call them, “booby-boo-boos”). But luckily for humanity, SkookumScript’s sophisticated error-checking will prevent your typos from causing mayhem on a planetary scale. (Well, usually.)
println("Hello, world!") printl("I'll be your megalomaniacal overlord for today.")
If you select the above two lines and press
F4, you will get the following rap on the knuckles:
ERROR: The method 'printl()' does not exist for an instance of the class 'SkookumDemo'. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv println("Hello, world!") printl("I'll be your megalomaniacal overlord for today.") -----^ <<<< Line: 2, columns: 1-7 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
As you can see, an
n is missing in
println. Just type in the fix (perhaps assisted by auto-complete, which, if anything, is usually over-eager to make suggestions) and try again.
Note that no part of a code selection will be executed if the parser encounters an error in any part of the selection.
Syntax (grammar) errors
This bit of code is missing an end bracket:
If you evaluate it, you will get the following sharp slap on the buttocks:
ERROR: Expected the end of the invocation list ')', but did not find it. [Too many arguments supplied?] vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 42.max(33.min(11.max(9)) >>>>>>>>>>>>>>>>>>>>>>> ^ <<<< Line: 1, column: 25 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
The compiler will heroically attempt to pinpoint the location where the fix should go. Yes, it’s still a hero even it turns out to be incorrect.
Semantic (meaning and logic) errors
Sometimes code might look error-free at first glance, yet still have errors in logic or meaning. The SkookumScript compiler will craftily catch these too.
If you try to execute the above code, you will get the following slap across the face with a cold, wet fish:
ERROR: The argument supplied to parameter named 'num' was expected to be of type 'Integer' and it is type 'String' which is not compatible. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 42.max("amok") >>>>>>>>>>>> ^ <<<< Line: 1, column: 14 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
max() method expects a number, not a string.
More helpful help from the SkookumIDE compiler
The SkookumIDE has a few mechanisms to spot and prevent errors, even as you are typing code.
If you enable the “View” → “Toggle Auto-Parse Selections” setting, the compiler will automatically parse any text you select to determine if it is valid. If it is not valid, the compiler adds a red wavy underline to the problem area. This is a valuable early-warning system that saves you the humiliation of pressing
F4 and being swiftly rejected.
Enabling the “View” → “Toggle Auto-Parse Editor” setting does the same thing for files (such as methods and coroutines) in the source editor window, even when you don’t have text selected.
The bracket grouping symbols—
] for blocks,
) for invocation arguments, and
} for lists—all have slight color differences between different group pairs, with three alternating colors representing levels of nesting. In the default color style, the first bracket for a group will be a bright light green, the next will be a slightly darker green, and the next will be darker still. Each matching closing bracket will have a matching color, so you can tell at a glance which brackets match.
When you type class names into a SkookumIDE Workbench or Editor pane, valid (known) classes will be colored default yellow, while invalid (unknown) classes will be colored default orange. This catches class name typos as they are being written—and more importantly, it adds a refreshing default citrus ambiance to your code.
To be continued…
Work on this Primer is in progress, so check back soon.