 |
Before we ever get to coding any actual rooms, we need to set up a couple of variables that we are going
to need. Since we are going to need them between rooms and throughout the whole game, we will need to make
them global variables, we do this by placing them in the main script.
Open up the main script and just below this
gLoadingCursor = 997 /* the number of the loading cursor (ie. hand) */
We'll go ahead and add in these new variables
gPreviousCursor=999 // Used when leaving inventory screen empty handed
itemIcon = 900 // cursor number of inventory item last selected
canTab = TRUE // Allow access to inventory room
totalcash = 100 // An Inventory Item, Cash in pocket at start
Ok, so far so good right, see this isn't going to be as hard as you thought it was going to be.
|
 |
While we are in the main script, we may as well go ahead and add in a couple of inventory items.
Now I know that there are at least two of them that you are probably never actually going to use
in a game, but they will serve as the perfect example when it comes time to take care of our inventory
room, so for now just bear with me on these.
The first item, which you may have been able to guess, just from the variables that we added above
is cash. Really, everything about the way we are using this could also be used for any item that we
would have a pocketfull of, for example the rocks that we all loved to throw at anything and everything
in Hero's Quest. But I digress, back to actual work, the other three items we are going to be adding are
a balloon, a string, and a balloon with a string (it's actually our string and balloon combined).
I'm not going to go into great detail here explaining how to add inventory items to the main script, if
you don't know how, check out chapter 18 of the Volume I Tutorials. So without further ado, about a quarter
of the way down, change the inventory add to this.
This is what we want
(Inv:add(
{Nothing}
{Cash}
{Balloon}
{Striiing} // Jut to make sure there is no confusion with string variables
{StriiingBalloon}
)
)
So, with that done let\s head down to the bottom of the script and take care of the inventory's instances. Now you may notice
right away that these instances seem to be lacking in a few of the standard properties that you would normally have. Let
me explain, by the end of this tutorial we will have an inventory "room" which is going to handle all of the views and
whatnots so we don't need those here. Also, there isn't going to be anymore saying anything, so we
definately don't need that part here anymore. Now as for the descriptions, we still need those, but we don't need them here
taking up valuable heap space by cluttering up
our main script with miscellaneous text strings since this script gets loaded in almost every other script, as you
will probably figure out from doing this tutorial, I am anal
about trying to preserve my
heap space memory, probably to a fault, but the more I can save and get back, the more I can use for other stuff.
You'll see what I mean when we start actually scripting a room, but for now trust me when I say that this is all
we need and let's roll with it.
(instance Nothing of Iitem(properties))
(instance {Cash} of Iitem(properties))
(instance {Balloon} of Iitem(properties))
(instance {Striiing} of Iitem(properties))
(instance {StriiingBalloon} of Iitem(properties))
Ok, all done here. Compile the main script, and don't forget, after you do you must compile all scripts. ANY time you
change the main script you need to "compile all" or things may go a little crazy with your game. But for now, that is
all that we need to do in here so you can close it up.
|
 |
Just a little reminder, don't forget to define your inventory items in the game.sh file. Again this is
covered in Chapter 18 of the original tutorials, but as the number that the item gets defined as is actually
pretty important for how our point and click system handles everything, I feel the need to cover it here too.
So pop open the game.sh file real quick and make the inventory section look like this.
// Inventory Items
(define INV_NOTHING 0)
(define INV_CASH 1)
(define INV_BALLOON 2)
(define INV_STRIIING 3)
(define INV_STRIIINGBALLOON 4)
|