Scripting Props and Acts: Difference between revisions

From Sierra Wiki
Jump to navigationJump to search
m (1 revision imported)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Category:SCI Pages]]
= Chapter 3 - Scripting Props and Acts =
= Chapter 3 - Scripting Props and Acts =


Line 45: Line 46:
It's that easy. Of course, the prop or actor's script can contain any of the standard script methods: '''changeState''', '''handleEvent''' or '''doit'''.
It's that easy. Of course, the prop or actor's script can contain any of the standard script methods: '''changeState''', '''handleEvent''' or '''doit'''.


 
==<br /> References ==
 
<references />
 
==<br /> Related Links ==
 
* &nbsp;


<span style="float: left">[[Regions and Locales|&lt; Previous: Chapter 2 - Regions and Locales]]</span>
<span style="float: left">[[Regions and Locales|&lt; Previous: Chapter 2 - Regions and Locales]]</span>
<span style="float: right">[[Loopers|Next: Chapter 4 - Loopers &gt;]]</span>
<span style="float: right">[[Loopers|Next: Chapter 4 - Loopers &gt;]]</span>
&nbsp;
&nbsp;
 
[[Category:Technical Info]]
[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Tutorials]]
[[Category:Tutorials]]
Line 57: Line 63:
[[Category:SCI Props]]
[[Category:SCI Props]]
[[Category:Actors]]
[[Category:Actors]]
[[Category:SCI Tutorials]]

Latest revision as of 10:25, 5 December 2024

Chapter 3 - Scripting Props and Acts

In addition to a room having a script associated with it, props and actors can also have scripts. If you have a lot of actors and props in a room, all doing different things, it is much easier to associated the scripting logic for a particular actor with that actor instead of in the room's script.

Adding a shadow of the ego

For this exercise, we'll make a Prop that acts as the shadow of the ego. The Prop's script's doit method will check the ego's position, and adjust its own position accordingly.

Example:

Code:

<syntaxhighlight lang="sci" class="cs"> (instance aShadow of Prop (properties x 0 y 0 view 800 ) (method (init) (super:init()) (self:ignoreActors() z(-90)) (self:setScript(shadowScript)) ) )

(instance shadowScript of Script (properties) (method (doit) (aShadow: posn((+ 20 (send gEgo:x)) (- (send gEgo:y) 90)) ) (super:doit()) ) )</syntaxhighlight>

And then, in the init method of the room, you do

For example:

Code:

<syntaxhighlight lang="sci" class="cs"> (aShadow:init())</syntaxhighlight>

It's that easy. Of course, the prop or actor's script can contain any of the standard script methods: changeState, handleEvent or doit.


References



Related Links

  •  

< Previous: Chapter 2 - Regions and Locales Next: Chapter 4 - Loopers >