lesson2.txt

txt file icon
Fact Value
Original File lesson2.txt
Game
  • Creatures 1
Creator
  • LummoxJR
Wiki Link Search "lesson2" on creatures.wiki
Tags
File Size: 3 KB

Description(Generated)

Text File Composite

::----- lesson2.txt -----::
COB Tutorial
Lesson 2: A remover script 

This lesson: Making an object to remove another object. This kind of thing has been done many different ways, but there is only one good way to do it. Here it is.

Step 1: What to Delete
Let's say I want to create a remover for the cheese object I made in Lesson 1. That object is class 2 6 65, with only one script: 2 6 65 1.
Well, that's easy enough. So let's build the remover. 

Step 2: Creating the Script
All right, now open CobCom. In the Object Name box, type "Cheese Variant Remover".
Now, click on the word "" in the list box that says "Installation Scripts" ("Imports" in CobCom 1.02 or earlier). That's where you'll be editing the macro code that performs the actual object removal.

Click in the edit box. Go ahead and delete the line that appears there. Now type in the following:

inst
enum 2 6 65
kill targ
next
scrx 2 6 65 1
endm 

Now, let's examine each line one by one.

inst
This command tells the object injector to execute the rest of this script before updating anything in the game. Since we're doing this all at once, it makes sense to go ahead and use this. Anyway, all scripts in the Imports section require this.

enum 2 6 65
This will cycle through all the cheese variant objects in the world and delete them. We could just as easily have made it a little more open-ended, though, and deleted all food from the world. To do that, you would use enum 2 6 0, where the 0 is a wildcard, saying that any species will do, as long as it is family 2, genus 6 (i.e., food).

kill targ
This destroys the object we're looking at right now. Since we're in the middle of an enum command, this deletes one of the cheese variant objects.

next
Finds the next cheese variant object and repeats the code right after the enum command. If there are no more objects, it skips ahead to the next command.

scrx 2 6 65 1
Kills the script that was installed by the object.

endm
 <...truncated>