Log In  

Cart [#9202#] | 2014-10-24 | No License | Embed
4

Here's a demonstration of the new object aliasing feature in 0.3.0. Click "Play >" to try it out in the browser, or if you'd like to open it in the designer, click on "Cartridge" and save the file somewhere handy (and then CTRL-O to open it from inside Designer).

For some background on how to make custom objects in Voxatron, try the tutorial: Modifiers and Monster Attacks

So, what is object aliasing?

An alias is a reference to another object definition. It looks like a regular item in the object navigator, but all it does is point to a definition somewhere else. This is very similar to aliasing in a file system -- for example, a desktop shortcut in Windows is not the whole program, but just a link to open it.

To create an alias in Voxatron, select the item(s) to alias and press CTRL-M. ("Make alias"). This creates the alias in the paste buffer, so you can now navigate to the location you would like to paste it and press CTRL-V. You should see the little arrow icon in the top right indicating that it is an alias.

What are they good for? In Voxatron Designer, they are really useful! There are two main uses, and in this tutorial we'll be covering only the second one:

  1. If several objects share the same component, you only need to define the component once and then make aliases to refer to it from each player. I'll talk about this more later, but if you'd like to see an example, check out the COMMON folder that is used by each player definition in Bloot:
  1. For creating lists of object definitions that can be selected from randomly. The treasure box in this cart does this both for emitting random treasure and for playing a random sound each time a gold coin is collected.

Here's what the treasure box's emitter folder looks like. It has 4 references to the treasure objects:

Note that the emitter's source_id is 0. This is just a convenient shortcut to mean 'this folder'. It could have been the object id of the emitter itself and mean exactly the same thing.

So.. wait -- normally the source_id of an emitter is the object to be emitted. What happens if it's a folder?

When a folder is specified, a random item is selected from that folder each time. The probability of each item being selected can be controlled with the SELECTION PROBABILITY field that every alias has. This value represents the relative likelihood that each item will be selected. For example, if there are 2 items with probabilites 5 and 10, you'll end up with twice as many of the second item on average.

It's possible to include folders in this list of things to randomly select from. Folders also now have a SELECTION PROBABILITY for this purpose. If an empty folder is selected, then no item is returned -- so this can be used for things like monsters that only drop a single item 5% of the time (check out the blocks in Bloot). If the folder is randomly selected and it is not empty, the random selection process recurses from that folder.

Playing random sounds works in the same way. If you look inside the gold coin's folder, you'll see an additional folder of pickup sounds, and also a folder of aliases. As a shortcut, it would have been possible in this case to skip the folder of aliases and just directly refer to the folder of object definitions instead, in which case each item implicitly has a selection probability of 1.

I hope that's enough to get you started! If you have any questions about how the treasure box works, please post them in the comments. Also, feel free to use or modify the treasure box guy in your own cartridges.


** While making this, I found some bugs that will be fixed in 0.3.2:

  • There's no way to select the SYSTEM:RANDOM event for triggering the treasure box's opening state. Please use HOST:PERIODIC instead for now
  • There's no way to trigger a sound when a pickup is collected. I used life <= 0, so the pickup sound is also played when the pickups are destroyed.
  • While viewing aliases in the navigator, they can not be deselected by clicking somewhere in the window. Press Enter instead.
P#9203 2014-10-24 10:12 ( Edited 2014-10-27 04:22)

Thx, very helpful :)

P#9226 2014-10-27 00:22 ( Edited 2014-10-27 04:22)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-22 11:04 | 0.019s | 4194k | Q:21