development, tutorial

[code] Picking a random letter in CAOS

Malkin approached me on Discord, asking me how to pick a random letter. I’ve been using random numbers in CAOS with the RAND command for like forever, but I hadn’t found a reason yet to pick random letters. The question made me think, though.

Of course, there’s the old-fashioned, boring and bulky-code-way of just picking a random number between 1 and number-of-letters-in-the-alphabet. Then you can set a variable to a letter depending on the value of that number, in an if-elif-elif-elif-elif-… scenario.

Surely there should be a cleaner/easier way!

Recently I learned more about the CHAR variable thanks to Amaikokonut’s blog post over at Naturing :: Nurturing. I noticed char has two commands, one that returns a variable and one that sets a variable.

The command returning the character returns the ASCII number for that character.
I wondered if the one setting a variable also uses the ASCII code for a character: Yup!

So, all that’s left is to figure out the ASCII numbers of the characters you want to use.

For the characters A to Z, that’s 65 to 90. For the characters a to z, that’s 97 to 122.

So if you want a character between a to z, the resulting code would be this:

sets va00 “a”
setv va01 rand 97 122
char va00 1 va01

Nice and clean, right? 😀

 

Advertisements
tutorial

[Code] How to make a door agent in C3/DS

I wrote up a quick tutorial on how to write a CAOS script to make a door for C3/DS.
I posted it over at the creatures wiki (since their formatting is nice and simple, and it’s pretty fitting for tutorials.)

You can find the door tutorial here

Enjoy!

development, tutorial

[Code] How I (should) organize my files

..Yes, the ‘should’ is absolutely neccessary in that title.

When I’m working on a project, I tend to use a very specific naming scheme for my cosfiles and image files, but other than that everything of the project gets thrown into the same map, so if I want to compile the whole thing it’s a painless experience.

I always prefix my .cosfiles with the ID number they have. That way when I need to write their ID number down in the script somewhere, I can just glance at the filename. Also each .cosfile has a caos2pray chunk so if I would want to inject it as an agent I can just compile it.

Any .c16 files get prefixed with the name of the project, and suffixed with the name of the artist (except if draw them myself or if they are are grabbed/recolored from C1/C2/C3/DS).

To compile the whole project I create a new installer.cos file, create a caos2pray chunk that includes pretty much every file in that map and LINK the cosfiles into the caos2pray. Then if you want the complete agent to compile you can just drag the installer on Monk.

This is how I do it. Hope it’s somewhat helpful. 😀

 

development, tutorial

[Code] Setting up a development environment for Docking Station

Hello all!

I will occasionally post some coding tutorials and other commented code for Docking Station here.

In this post I’ll show the development environment I’m using, and I’ll explain you how to set up your own under Windows 10.

Continue reading “[Code] Setting up a development environment for Docking Station”