Advanced SCI Tutorials and Advanced Use of Control Areas: Difference between pages

From Sierra Wiki
(Difference between pages)
Jump to navigationJump to search
m 4 revisions imported
 
m 1 revision imported
 
Line 1: Line 1:
[[Category:SCI Pages]]
=Chapter 8 - Advanced use of control areas=
By Phil Fortier (Troflip)<br />
October 22nd, 2005


<span class="Category">Introduction</span>
The main set of SCI tutorials shows that the way to check if the ego is on a particular control area is the following:


&nbsp;
<blockquote>
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">(instance RoomScript of Script
  (properties)
  (method (doit)
    (if(== (send gEgo:onControl()) ctlGREEN)
      (send gRoom:newRoom(1))
    )
  )
)</syntaxhighlight>
</blockquote>
 
If the ego is on GREEN, then he is sent to a new room.
 
That's only part of the story.  The value returned by '''onControl()''' is actually a bit mask, which can contain any combination of the following values:
 
<blockquote>
These are defined in sci.sh:
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">(define ctlBLACK                      $0001)
(define ctlNAVY                        $0002)
(define ctlGREEN                      $0004)
(define ctlTEAL                        $0008)
(define ctlMAROON                      $0010)
(define ctlPURPLE                      $0020)
(define ctlBROWN                      $0040)
(define ctlSILVER                      $0080)
(define ctlGREY                        $0100)
(define ctlBLUE                        $0200)
(define ctlLIME                        $0400)
(define ctlCYAN                        $0800)
(define ctlRED                        $1000)
(define ctlFUCHSIA                    $2000)
(define ctlYELLOW                      $4000)
(define ctlWHITE                      $8000)</syntaxhighlight>
</blockquote>
 
This makes sense, because the 'footprint' of the ego (or any '''Act''' class) is actually a two-dimensional area, not a single point.  Therefore, he may be on several colors at once.
 
<blockquote>
To detect if the ego is ''completely'' on one color do the following:
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">        (if (== (send gEgo:onControl()) ctlGREEN)
            // Ego is completely on green (no part of his footprint hits black, even).
        )</syntaxhighlight>
</blockquote>
 
<blockquote>
To detect if some part of the ego's footprint is touching a particular color:
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">        (if (& (send gEgo:onControl()) ctlGREEN)
            // Part of ego is touching green.
        )</syntaxhighlight>
</blockquote>


These are Advanced SCI tutorials written by Troflip, intended to complement the information provided in Brian Provinciano's first two sets of tutorials.
<blockquote>
To detect if the ego is touching one or more of ctlGREEN and ctlCYAN, do the following:
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">        (if (& (send gEgo:onControl()) (| ctlGREEN ctlCYAN))
            // Ego is touching green or cyan.
        )</syntaxhighlight>
</blockquote>


<span class="Category">Table of Contents</span>
<blockquote>
To detect if the ego is touching both ctlGREEN and ctlCYAN exclusively, do the following:
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">       (if (& (send gEgo:onControl()) (| ctlGREEN ctlCYAN))
            // Ego is touching green or cyan.
        )</syntaxhighlight>


* [[Advanced Said() Strings - Part 1|Chapter 1 - Advanced Said() Strings - Part 1]]
Basically, just remember it is a bit-mask, so the '&amp;' and '|' operators are your friends.
* [[Regions and Locales|Chapter 2 - Regions and Locales]]
* [[Scripting Props and Acts|Chapter 3 - Scripting Props and Acts]]
* [[Loopers|Chapter 4 - Loopers]]
* [[Jumping Bug|Chapter 5 - Jumping Bug]]
* [[The z-coordinate|Chapter 6 - The z-coordinate]]
* [[SCI Memory Management|Chapter 7 - Memory Management (advanced)]]
* [[Advanced Use of Control Areas|Chapter 8 - Advanced Use of Control Areas]]


&nbsp;
&nbsp;


<span style="float: left">[[SCI_Studio_Tutorial_2|&lt; Previous: Brian Provinciano's SCI Studio Tutorial 2]]</span><span style="float: right">[[Advanced Said() Strings - Part 1|Next: Chapter 1 - Advanced Said() Strings - Part 1 &gt;]]</span><br />
<span style="float: left">[[Memory Management|&lt; Previous: Chapter 7 - Memory Management (advanced)]]</span><span style="float: right">[[SCI_Point_and_Click_Tutorial|Next: Cloudee1's SCI Point and Click Tutorial &gt;]]</span>
 


&nbsp;
&nbsp;


[[Category:Technical Info]]
[[Category:Control Areas]]
[[Category:Tutorials ]]
[[Category:Tutorials]]
[[Category:SCI Tutorials]]

Revision as of 00:26, 3 June 2024

Chapter 8 - Advanced use of control areas

The main set of SCI tutorials shows that the way to check if the ego is on a particular control area is the following:

Code:
(instance RoomScript of Script
  (properties)
  (method (doit)
    (if(== (send gEgo:onControl()) ctlGREEN)
      (send gRoom:newRoom(1))
    )
  )
)

If the ego is on GREEN, then he is sent to a new room.

That's only part of the story. The value returned by onControl() is actually a bit mask, which can contain any combination of the following values:

These are defined in sci.sh:

Code:
(define ctlBLACK                       $0001)
(define ctlNAVY                        $0002)
(define ctlGREEN                       $0004)
(define ctlTEAL                        $0008)
(define ctlMAROON                      $0010)
(define ctlPURPLE                      $0020)
(define ctlBROWN                       $0040)
(define ctlSILVER                      $0080)
(define ctlGREY                        $0100)
(define ctlBLUE                        $0200)
(define ctlLIME                        $0400)
(define ctlCYAN                        $0800)
(define ctlRED                         $1000)
(define ctlFUCHSIA                     $2000)
(define ctlYELLOW                      $4000)
(define ctlWHITE                       $8000)

This makes sense, because the 'footprint' of the ego (or any Act class) is actually a two-dimensional area, not a single point. Therefore, he may be on several colors at once.

To detect if the ego is completely on one color do the following:

Code:
        (if (== (send gEgo:onControl()) ctlGREEN)
            // Ego is completely on green (no part of his footprint hits black, even).
        )

To detect if some part of the ego's footprint is touching a particular color:

Code:
        (if (& (send gEgo:onControl()) ctlGREEN)
            // Part of ego is touching green.
        )

To detect if the ego is touching one or more of ctlGREEN and ctlCYAN, do the following:

Code:
        (if (& (send gEgo:onControl()) (| ctlGREEN ctlCYAN))
            // Ego is touching green or cyan.
        )

To detect if the ego is touching both ctlGREEN and ctlCYAN exclusively, do the following:

Code:
        (if (& (send gEgo:onControl()) (| ctlGREEN ctlCYAN))
            // Ego is touching green or cyan.
        )

Basically, just remember it is a bit-mask, so the '&' and '|' operators are your friends.

 

< Previous: Chapter 7 - Memory Management (advanced)Next: Cloudee1's SCI Point and Click Tutorial >