Home | SCI Documentation | SCI Tutorials | SCI Tools | SCI Wiki | Community

Chapter 7 - Preparing the Supporting Scripts

Once again, just like when we started building the point and click inventory room, we are going to begin by getting the main script ready. This time though, we are also going to have to handle another script or two. I was actually quite surprised when I started digging around, but it turns out when Troflip released the updated template game with SCI Companion, He actually changed around a number of different things. The menubar script for one. So what I had done before, with the old SCI studio template game, wasn't quite going to fly this time around.

Begin in the Main script

Main Script 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. If you skipped it, you may want to check out Chapter 1, Preparing the Main Script, as we reuse a number of the variables we added when we started the point and click inventory room.

Open up the main script and just below the inventory variables we added, let's add these.

Code:
    menuOption = 0          // determines menu shown on point-n-click bar
    sGauge                  // game speed gauge name
    vGauge                  // volume gauge name
    pncSpeed                // speed set with gauge
    pncVolume               // volume set with gauge

    gGameTitle              // a pointer to the games title

For the most part, we luck out because the 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 basically have one job, and that is to deal with the gauges, 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 the 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 the 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.

Code:
        = 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.

Code:
(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.

Code:
(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:
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:
Code:
  (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 the edit intact, so just comment the debug cases, not the whole thing. Lets make a change in the Controls script

Opening up the Controls script, you should notice that it begins by outlining the MenuBar class, what luck, that is exactly what it is that we came here to edit. Specifically the draw method. I know that there are supposed to be other ways to Disable or hide the menubar, but for some reason or another, I always managed to get that darn thing to come open on me. Well, since we are making this a point and click game, and the new menubar will handle everything that the old one did, lets take the easiest way out and just not let the draw do anything.

So find the draw method, the first method in the class:
Code:
	(method (draw)
		= state ENABLED
		DrawMenuBar(TRUE)
	)
And simply change that to this:
Code:
	(method (draw)
	//	= state ENABLED
	//	DrawMenuBar(TRUE)
	)

Now you notice, I didn't actually have you delete or change anything, just comment out the instructions of the draw method. I am trying to make as small of an impact as possible on any of the supporting scripts as I can. In case someday you want to come in and change things back all you will have to do is uncomment, not track down code. But anyway, I think that covers all the additional edits that we are going to need to make outside of the actual rooms. That sums up the edits of the supporting scripts, easy right!

< Previous: Chapter 6 - Loose ends in the Inventory Room Next: Chapter 8 - Ordering the Additional Cursors >
 

by helping to defray some of the costs of hosting this site. If it has been of help to you, please consider contributing to help keep it online.
Thank you.
pixe
Top

© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.