TrustedUser
2,147
edits
m (Text replacement - "</source>" to "</syntaxhighlight>") |
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=") |
||
Line 63: | Line 63: | ||
* First the picture of the room number is loaded into memory, using the load.pic(room_no) command. Keep in mind that every command has either a semi-colon(;) at the end or an opening brace. In this case, it’s a semi-colon. If you wish to change the number of the PICTURE resource which is loaded, you must first set a variable(say, v200) to that value and invoke the command like this: | * First the picture of the room number is loaded into memory, using the load.pic(room_no) command. Keep in mind that every command has either a semi-colon(;) at the end or an opening brace. In this case, it’s a semi-colon. If you wish to change the number of the PICTURE resource which is loaded, you must first set a variable(say, v200) to that value and invoke the command like this: | ||
< | <syntaxhighlight lang="cpp"> | ||
v200 = 4; | v200 = 4; | ||
load.pic(v200); | load.pic(v200); | ||
Line 97: | Line 97: | ||
So, to add your object definition, add this code to the room(in this case room 2 - LOGIC.002), just under the line: | So, to add your object definition, add this code to the room(in this case room 2 - LOGIC.002), just under the line: | ||
< | <syntaxhighlight lang="cpp"> | ||
#include "defines.txt" | #include "defines.txt" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 103: | Line 103: | ||
add | add | ||
< | <syntaxhighlight lang="cpp"> | ||
#define your_object_name_with_no_spaces o1 | #define your_object_name_with_no_spaces o1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 109: | Line 109: | ||
So it should read like this: | So it should read like this: | ||
< | <syntaxhighlight lang="cpp"> | ||
#include "defines.txt" | #include "defines.txt" | ||
#define your_object_name_with_no_spaces o1 | #define your_object_name_with_no_spaces o1 | ||
Line 119: | Line 119: | ||
Now, in the initialisation section of the room, we decide which view we want to use for our object, and where we want to put it. The initialisation section is everything between | Now, in the initialisation section of the room, we decide which view we want to use for our object, and where we want to put it. The initialisation section is everything between | ||
< | <syntaxhighlight lang="cpp"> | ||
if (new_room) { | if (new_room) { | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 127: | Line 127: | ||
We want to add our code after the line: | We want to add our code after the line: | ||
< | <syntaxhighlight lang="cpp"> | ||
draw(ego); | draw(ego); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The code we will add here displays a view on the screen: | The code we will add here displays a view on the screen: | ||
< | <syntaxhighlight lang="cpp"> | ||
animate.obj(object name); //this tells the interpreter, that we're using this object | animate.obj(object name); //this tells the interpreter, that we're using this object | ||
load.view(2); //load the view we want to use into memory | load.view(2); //load the view we want to use into memory | ||
Line 169: | Line 169: | ||
After you have completed the first two steps, you are ready to add your Item to the room. This is done with the following code, added to the room: In the defines section(after the #include line): | After you have completed the first two steps, you are ready to add your Item to the room. This is done with the following code, added to the room: In the defines section(after the #include line): | ||
< | <syntaxhighlight lang="cpp"> | ||
#define item name o1 //replace item name with your own. | #define item name o1 //replace item name with your own. | ||
Line 186: | Line 186: | ||
This logic, in the template game, handles non-room-specific functions, like get item and look item. Add this code under the section that says put various input responses here: | This logic, in the template game, handles non-room-specific functions, like get item and look item. Add this code under the section that says put various input responses here: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said("look","your item name")) { // your item name must be replaced | if (said("look","your item name")) { // your item name must be replaced | ||
if (has("object name")) { // object name is the name you put in the OBJECT file | if (has("object name")) { // object name is the name you put in the OBJECT file | ||
Line 198: | Line 198: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Also needing to be added is the code for getting the object: | Also needing to be added is the code for getting the object: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said("get","your item name")) { | if (said("get","your item name")) { | ||
if (has("object name")) { | if (has("object name")) { | ||
Line 211: | Line 211: | ||
The above code was necessary for looking at the item in your inventory, or trying to get it if you already have it, but it's not good enough for getting the item from the specific room it's in. Use this code for that: | The above code was necessary for looking at the item in your inventory, or trying to get it if you already have it, but it's not good enough for getting the item from the specific room it's in. Use this code for that: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said("get","your item name")) { | if (said("get","your item name")) { | ||
v255 = 2; //obj.in.room only accepts variables | v255 = 2; //obj.in.room only accepts variables | ||
Line 230: | Line 230: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Of course, we don't necesarily have to use v255, we can use any available Variable. The posn(ego,x1,y1,x2,y2) command, requires that x1,y1 is the top left corner of an imaginary box, and x2,y2 the lower right corner. Don't forget to enter the words you use into the WORDS.TOK file! This code is for looking at the item: | Of course, we don't necesarily have to use v255, we can use any available Variable. The posn(ego,x1,y1,x2,y2) command, requires that x1,y1 is the top left corner of an imaginary box, and x2,y2 the lower right corner. Don't forget to enter the words you use into the WORDS.TOK file! This code is for looking at the item: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said("look","your item name")) { | if (said("look","your item name")) { | ||
v255 = 2; | v255 = 2; | ||
Line 242: | Line 242: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Finally, if you do not wish the item to be drawn when it isn't in the room(ie you have taken it), then replace the line above which said this: | Finally, if you do not wish the item to be drawn when it isn't in the room(ie you have taken it), then replace the line above which said this: | ||
< | <syntaxhighlight lang="cpp"> | ||
draw(your item name); | draw(your item name); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
to this: | to this: | ||
< | <syntaxhighlight lang="cpp"> | ||
v255 = 2; | v255 = 2; | ||
if (obj.in.room("object name",v255)) { draw(your item name); } | if (obj.in.room("object name",v255)) { draw(your item name); } |