Community

SCI Programming => SCI Syntax Help => Topic started by: NilG on January 29, 2019, 07:21:45 PM

Title: Unlocking Locales and Regions
Post by: NilG on January 29, 2019, 07:21:45 PM
Hi again!

As the title suggests, I'm trying to incorporate locales and/or regions in some of my scripts, but I seem to be running into an error; it compiles and the game runs up until the room is loaded, as which point I get the "Oops!" error and a crash.  I've read over the tutorial at http://mtnphil.com/Games/Tutorial/chapter2.html and things look right to me, but I must be missing something.

I've placed the script alias in game.sh:

Code: [Select]
(define LIEVENLOCALE_SCRIPT 750)
and have set up a basic test script:

Code: [Select]
;;; Sierra Script 1.0 - (do not remove this comment)
;
; SCI Template Game
; By Brian Provinciano
; ******************************************************************************
; lieven.sc
; Lieven Locale Script

(script# LIEVENLOCALE_SCRIPT)
(include "sci.sh")
(include "game.sh")
(use "controls")
(use "game")
(use "main")
(use "obj")
 
(instance Lieven of Locale
    (properties)
 
    (method (handleEvent pEvent)
        (super handleEvent: pEvent)
(if (Said 'smell/hands') (Print 1 7))
    )
)

Finally, I've set it in the room:

Code: [Select]
(instance rm001 of Rm
(properties
picture scriptNumber
north 0
east 0
south 0
west 0
)

(method (init)
(super init:)
(self setLocales: LIEVENLOCALE_SCRIPT)
(gEgo posn: 150 147 loop: 1 cel: 0)
(SetUpEgo 1 6)
                … etc etc

But no luck yet.  I also tried setting everything as a region with the same result.  Can someone help me see what I'm missing with this?  Thanks in advance.
Title: Re: Unlocking Locales and Regions
Post by: troflip on January 29, 2019, 08:51:02 PM
Try adding this in your Lieven script:

Code: [Select]
(public
Lieven 0
)

The locale and/or region objects needs to be exported publicly from the script and given a dispatch number. setLocales: will load the given script, and look for export #0, which needs to be the particular Locale instance.

SCI Studio syntax does this implicitly for anything marked public (they inherit the number based on the order they are declared in a script), but in Sierra syntax you need to do it explicitly (helps avoid issues when adding/removing public procedures or instances from a script).
Title: Re: Unlocking Locales and Regions
Post by: NilG on January 30, 2019, 10:42:44 AM
Thank you again, Troflip, that was absolutely it.  I'll be sure to keep that in mind.
Title: Re: Unlocking Locales and Regions
Post by: troflip on January 30, 2019, 04:37:38 PM
You can debug this more easily in the future by running sciv.exe with the -d command line parameter (for SCI0, anyway). It'll print out a nice message telling you in more detail what's wrong, and you can examine the state of the game.

Unfortunately I don't know how to do this when you start it with DOSBox, other than telling DOSBox not to exit the DOS console when the exe crashes, and then running "sciv.exe -d" right from the DOS prompt. Someone else would probably be able to help more...

Or run it with ScummVM, that will probably provide a more readable debug message.
Title: Re: Unlocking Locales and Regions
Post by: EricOakford on January 30, 2019, 08:24:00 PM
The -d parameter! So THAT could be useful in debugging the SCI01 template. You can make a batch file that automatically starts the interpreter with that parameter.
Title: Re: Unlocking Locales and Regions
Post by: Collector on January 30, 2019, 09:03:54 PM
Unfortunately I don't know how to do this when you start it with DOSBox, other than telling DOSBox not to exit the DOS console when the exe crashes, and then running "sciv.exe -d" right from the DOS prompt. Someone else would probably be able to help more...

Simple. Just remove or rem out the exit line in the [autoexec] section in the conf file. Or if doing it from the command line or shortcut remove the -exit flag.
Title: Re: Unlocking Locales and Regions
Post by: NilG on January 30, 2019, 09:04:17 PM
I've definitely give that debug -d param a look into, that'll be a definite timesaver with some of these "Oops" type messages.

A follow-up on locales and regions...  I've got it working now, and I know that the hierarchy is room response to a statement, then locale response if room response isn't defined.

Is there a way to bypass the room response, if I want to use the locale's response code within part of an 'if' statement without copying and pasting the whole deal?  So basically, in response to a 'Said':

Code: [Select]
(if a
  (do this set of things defined in the room script)
else
  (perform the locale code for this 'Said')
)

Without the 'else,' there's just no response, since it considers itself done once the 'if' returns false.  I can copy and paste into the room code if necessary, just thinking there's probably a way to hand up the chain to save on heap for larger chunks?
Title: Re: Unlocking Locales and Regions
Post by: gumby on January 31, 2019, 09:10:54 AM
I'm not sure on this, but would un-claiming the event in the else work?

Code: [Select]
  (pEvent claimed: FALSE)
Title: Re: Unlocking Locales and Regions
Post by: NilG on January 31, 2019, 09:57:06 AM
Thank you, gumby, I just tested it out and it appears to do exactly that in this case.  Way nicer than a c&p would have been!