|
Open up the main script and just below the inventory variables we added, let's add these.
menuOption = 0 // determines menu shown on pointnclick bar
sGauge // game speed guage name
vGauge // volume guage name
pncSpeed // speed set with guage
pncVolume // volume set with guage
gGameTitle // a pointer to our games title
For the most part, we luck out because our regular game rooms are going to be using the same variables
we added already for the point and click inventory. So if you haven't
gone through the inventory room portion of this tutorial, you probably should. Most of these new variables, if you notice by their names
basicly have one job, and that is to deal with the guages, speed and volume. menuOption, determines which set of menu buttons to show. Finally
gGameTitle, which isn't essential for a point and click system, but I do reference it in our text resources so you may want to add it too.
Now if you included the gGameTitle variable, we are actually going to need a couple of more edits in the main script, just to make our life easier. First off though
we are going to need to actually give it a value. So scroll down to just below the variable declarations to the main script's init method and at the gVersion
declaration, go ahead and give your game a title.
= gGameTitle "The PnC Template"
= gVersion "1.0"
Since we've got it declared now, we may as well make use of the gGameTitle variable, so go ahead and scroll down some more, just a little more than half way, you should find the
statusCode instance. Go ahead and change that to this.
(instance statusCode of Code
(properties)
(method (doit param1)
Format(param1 " Score: %d of %-3d %s " gScore gMaxScore gGameTitle)
)
)
This is supposed to be a point and click game, so we may as well take away the users ability to
type in commands as well. This can be done quite simply here in the main script. Simply scroll down to
public procedure for PlayerControl and change the canInput value from TRUE to FALSE, so now it should look
something like this.
(procedure public (PlayerControl)
(User:
canControl(TRUE)
canInput(FALSE)
)
(send gEgo:setMotion(NULL))
)
We do have one more edit yet to make in the main script though. If you are using the template game
that comes with sci companion, we are going to be adding another case or two to the debug area that Troflip set up.
If you are using the template game that comes with sci studio, which I certainly hope you aren't, might I suggest that you
check out the how to titled Troflip's easy alt debugging, that is the same code which we are about to add to.
So find the code
(if (== evKEYBOARD (send pEvent:type))
(switch (send pEvent:message)
// Check for ALT keys
(case $2f00 // alt-v
Show(1) // Show visual
)
And we want to add in there, the Tab button, or $09
(if (== evKEYBOARD (send pEvent:type))
(switch (send pEvent:message)
(case $09 // tab
(if(== canTab TRUE)
= gPreviousCursor gCurrentCursor
(send gRoom:newRoom(500))
)
)
// Check for ALT keys
(case $2f00 // alt-v
Show(1) // Show visual
)
We had to add in that bit to check if the user pressed the Tab button on their keyboard, because
the edit I am going to have you make in the Controls script causes the Tab button to no longer function.
This is an easy workaround for that.
Keep in mind though, if you comment out the debug functions prior to releasing your game publicly, you will still
need to keep our edit intact, so just comment the debug cases, not the whole thing.
|