Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: Cloudee1 on September 09, 2003, 02:09:01 PM

Title: Trying to use locals
Post by: Cloudee1 on September 09, 2003, 02:09:01 PM
ok I'm trying to use local variables butit's not quite working like I thought is there a step that I am missing?

                       I've got this- under the (use)'s:
(local
    TRAP_IN_CABINET
)
                       I've got this with my (init)'s:
 =TRAP_IN_CABINET TRUE
       (if(TRAP_IN_CABINET)(theTrap:init()setPri(1)))

                        I've got this mith my (said)'s
(if(Said('take/trap'))
  (if(TRAP_IN_CABINET)
    (if(== (send gEgo:onControl()) ctlLIME)
       (eDoor:setCycle(End))
       (send gGame:changeScore(3))
       (send gTheMusic:number(2)loop(1)priority(-1)play())
       Print("The trap has been taken!")
       (send gEgo:get(INV_TRAP))
       (theTrap:hide())
       =TRAP_IN_CABINET FALSE
    )(else Print("Try standing closer!"))
  )(else Print("I already have it!"))
)

when I am in the room it works fine, but if I return to the room the trap has been replaced, and you are able to get it again, I assume that something needs to go in global but I don't know what?
Title: Re:Trying to use locals
Post by: robingravel on September 09, 2003, 03:41:25 PM
Hi  cloudee1

I noted it me too.

SCI is always reset any local variables when you leave the room and back.

You'll need the global variables to use.
Put TRAP_IN_CABINET in the main.sc. Here the code:

(local
 gEgo               /* points to the ego's class */
 gGame               /* points to the game instance */
 gRoom               /* points to the current room instance */
 gSpeed = 7               /* the game speed (delay each interpreter cycle) */
 gQuitGame = FALSE      /* if set to TRUE, the game will exit */
   
 gCast               /* points to the cast class (list of actors) */
 gRegions            /* points to the regions class (list of regions) */
 gLocales             /* points to the locales class (list of locales) */
 gTimers               /* points to the timers class (list of timers) */
 gSounds               /* points to the sounds class (list of sounds) */
 gInv               /* points to the inventory class */
 gAddToPics            /* points to the add to pics class */
 gFeatures            /* points to the add to features class */
 gSFeatures            /* points to the add to sfeatures class */
   
 gRoomNumberExit         /* room number exit */
 gPreviousRoomNumber      /* the number of the previous room */
 gRoomNumber            /* the number of the current room */
 gDebugOnExit = FALSE   /* enter debug mode on room exit */
   
 gScore = 0            /* the game score */
 gMaxScore = 14         /* the maximum game score */
 gOldScore            /* previous score */
   
 gCurrentCursor         /* the number of the current cursor */
 gNormalCursor = 999      /* the number of the normal cursor (ie. arrow) */
 gLoadingCursor = 997   /* the number of the loading cursor (ie. hand) */
   
 gDefaultFont = 1      /* the number of the default font */
 gSaveRestoreFont = 0   /* the number of the font for the save/restore dialogs*/
 gDeadFont = 0         /* the number of the font for the dialog when ego dies */
   
 gUserEvent            /* points to the user's event object */
 gPrintDlg            /* points to the current Print() window */
 gVolume               /* the sound volume */
 gVersion            /* the version string */
 gSaveDirPtr            /* points to the save directory string */
 gCheckAniWait         /* the checkAni delay */
 gSetRegions            /* a flag -- see User:doit() */
   
 gPicAngle            /* the room's pic angle */
 gOverlay = -1         /* whether to overlay the picture when drawing */
 gDefaultPicAni         /* the default pic animation */
 gDefaultPalette=0     /* the default palette to use for the pictures (0-3) */
 gCastMotionCue         /* if set, the cast's motionCue() is called */
   
 gTheWindow            /* points to the window class */
 gWndColor            /* the colour of the game's windows foreground (ie. text) */
 gWndBack            /* the colour of the game's windows background */

 gOldPort            /* the previous port */
   
 gEgoView            /* ego's current view number */
   
 /* hh:mm:ss | gTimeHours:gTimeMinutes:gTimeSeconds */
 /* the time elapsed since the game started */
 gTimeSeconds         /* the seconds */
 gTimeMinutes         /* the minutes */
 gTimeHours            /* the hours */
   
 gCurrentTime            /* the current time in seconds */
   
 gTheMusic            /* points to the music class */
 gTheSoundFX            /* points to the sound fx class */
 gProgramControl       /* states whether the program has control or the user */
=TRAP_IN_CABINET TRUE
Title: Re:Trying to use locals
Post by: robingravel on September 09, 2003, 03:49:59 PM
Sorry.

I cannot able to copy the code from sci studio to Netscape.

I used Explorer to put the code to the board.  I had not a problem with the thread 'Problems with this script'


Robin Gravel
Title: Re:Trying to use locals
Post by: Cloudee1 on September 09, 2003, 04:20:57 PM
Robin thanks for the info
   I pulled the local stuff slid, that little line into the main and now I know how to do so many things that I didn't know how to do an hour ago.

  Thank you, Thank you, Thank you

p.s. I tried to fidget around with the pallette problem you had and could never get any of my colors to look different. sorry