Category:Run & Gun Themed Action Gamess and Advanced Use of Control Areas: Difference between pages
m 1 revision imported |
m 6 revisions imported |
||
Line 1: | Line 1: | ||
[[Category:SCI Pages]] | |||
= 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: | |||
<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> | |||
<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> | |||
<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> | |||
Basically, just remember it is a bit-mask, so the '&' and '|' operators are your friends. | |||
==<br /> References == | |||
<references /> | |||
==<br /> Related Links == | |||
* | |||
<div> </div> | |||
<span style="float: left">[[SCI Memory Management|< Previous: Chapter 7 - SCI Memory Management (advanced)]]</span><span style="float: right">[[SCI_Point_and_Click_Tutorial|Next: Cloudee1's SCI Point and Click Tutorial >]]</span> | |||
| | ||
[[Category:Technical Info]] | |||
[[Category:Control Areas]] | |||
[[Category:Tutorials]] | |||
[[Category:SCI Tutorials]] |
Latest revision as of 09:03, 16 February 2025
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.
References
Related Links
< Previous: Chapter 7 - SCI Memory Management (advanced)Next: Cloudee1's SCI Point and Click Tutorial >
Pages in category "Run & Gun Themed Action Gamess"
The following 2 pages are in this category, out of 2 total.