Steps to change a Drink
into a Cow
1. If you followed the instructions for making a drink, you now have a drink with multiple swigs and multiple tastes. If you don't have this yet, go back and program your drink.
2. A cow and a drink work the same way. The main difference is that instead of a verb called "drink" for coffee, we have the verb "milk" for cow. Ah, the wonder of language.
Create an object called Cow, or Bessy, or Blacky or whatever you want to name your cow. Then hit the Program button and create a new verb for your cow. Call the verb "milk" with arguments this none none.
Here is the milk verb. Notice how it looks like your drink verb.
"<---start copying here--->"
1: swigs_left = this.swigs;
2: if (swigs_left == 0)
3: player:tell("The", this.name, " is empty. You need to FEED
it.");
4: elseif (swigs_left == 1)
5: player:tell("You squeeze ", this.tasteone, " from ",
this.name, ".");
6: player.location:announce(player.name, " takes sqeezes the last bit of
", this.tasteone, " from ", this.name, ".");
7: left_swigs = swigs_left - 1;
8: this.swigs = left_swigs;
9: elseif (swigs_left == 2)
10: player:tell("You take ", this.tastetwo, " from ", this.name,
".");
11: player.location:announce(player.name, " takes this.tastetwo, "
from ", this.name, ".");
12: left_swigs = swigs_left - 1;
13: this.swigs = left_swigs;
14: elseif (swigs_left == 3)
15: player:tell("You begin taking ", this.tastethree, " from
", this.name, ".");
16: player.location:announce(player.name, " takes ", this.tastethree,
" from ", this.name, ".");
17: left_swigs = swigs_left - 1;
18: this.swigs = left_swigs;
19: endif
"<---stop copying here--->"
Add Properties Swigs and Taste:
Start by creating a property called "swigs." In the Program box select your object and view it. Then hit the "New Property" button. Call the property "swigs". In the box the property, type the number 3. this gives your cow 3 swigs of milk.
Next add the properties called tastethree, tastetwo and tasteone. So, you can have "fresh milk" "sweet milk" and "the last bit of milk" respectively.
Compile and test your verb.
Now you need a "refill"
verb since your cow will run out of milk.
How can we refill a cow? Well, in line 3 of the "milk" verb we told
the user to "feed" the cow. So, lets use the word "feed"
instead of refill. Make a verb called "feed" on your cow and give
"feed" the arguments this none none. Note: you could also name
the refill verb "calm" and change the word "FEED" to "CALM"
in line 3 of the milk verb above.
Here is your "feed" verb
"<---start pasting from here--->"
1: if (this.swigs == 0)
2: this.swigs = 3;
3: player:tell("You feed and refill ", this.name);
4: player.location:announce(player.name, " feeds and refills ", "
", this.name, ".");
5: else
6: this.swigs = 3;
7: player:tell(this.name " still has milk.");
8 : endif
"<---end pasting here-->"