Resources

Monday, May 17, 2010

The Basics

What is CAOS?

CAOS is a programming language used to control objects in Creatures worlds. In Creatures 3 and Docking Station, objects make up everything the player interacts with - Norns, weather, the hand, even the world switcher.

CAOS is interpreted by the Creatures engine. There are several different incarnations of this engine, with slightly different CAOS syntaxes (grammar) and commands. The differences between the Docking Station and Creatures 3 engines are so minute that they can usually be ignored*, and we will not be focusing on any of the DS engine's "special" commands in these tutorials.

Note that the CAOS we produce in these tutorials will largely be incompatible with the Creatures 1 and 2 Engines. However, when you have become adept at CAOS, you may wish to convert some of your agents and scripts for use with previous games!

*Note that Creatures Adventures and Playground use the same engine as Creatures 3. Add-ons are so difficult to produce for these games, however, that they will not be covered in this tutorial.

Hello World

If you have ever taken a programming course, or read a book on the subject, you will probably be familiar with the concept of Hello World Programs. These are short programs created for two purposes, to test that the compiler or interpreter (in this case the engine) is working correctly, and to familiarize oneself with the syntax of the language in question.

Creating a Hello World program is, in this instance, very simple. Press the keys SHIFT+CONTROL+C to open up the command line. (We will be exploring the command line in more depth later, but for now, we will just be using it as a testing tool for simple programs.)

Type the following:

outs "Hello World"

And press the key ENTER. If all goes well, the command line should print "Hello World".

outs is the command used to print a string on the command line, or whatever program you are using to enter CAOS. "Hello World" is the string that will be printed.

In Creatures, there is actually a more interesting way to create a Hello World program! Select your favorite creature, then repeat the above steps with the following code:

targ norn sezz "Hello World"

Your creature should have said "Hello World". It is pretty simple to understand how this works. targ norn makes our code act on the currently selected creature. sezz is a command used to make creatures speak a specified string, and, of course, "Hello World" is the string that is spoken.

Finding Map Locations

Taking a break from syntax, it's time to introduce you to an ingame tool that will become invaluable, the co-ordinate finder. Press the keys SHIFT+CONTROL+X. You should see a couple of numbers next to the hand. Try moving the hand around and seeing how the numbers change. This is the co-ordinate finder. It shows the x (horizontal) and y (vertical) placement of the hand - the two numbers you are seeing. These numbers, or co-ordinates, can be used to place an object at the same position when injecting it or moving it around. We do need to make sure that it is a safe map position for that object according to its size and the type of map area. In the middle of a room at about adult norn head height is usually pretty safe for smaller objects, like toys and food. Don't worry if the placement is in midair, gravity will make most objects fall to the floor.

Try moving an object. Get some safe-looking co-ordinates. Hover the pointer over a piece of cheese or fruit, open the command line, and use this code:

targ hots mvto number1 number2

With number1 being the first co-ordinate you found, and number2 being the second.

This concludes the first lesson. The next lesson will cover how to make an object from scratch, give it some physical properties, and make it possible for creatures to interact with it.

No comments:

Post a Comment