Difference between revisions of "Interacting with Objects"

From SCI Wiki
Jump to navigationJump to search
Line 48: Line 48:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
However, this won’t compile properly yet, because we have given it a noun that doesn’t exist. You can just remove the noun property altogether, but we want to actually interact with this box. So go to the message resource for script 110 (use the ''Messages'' link in the Toolbox pane). Add a new noun, and call it N_BOX (see [[Message editor]] to learn how to do this). Save the message resource and return to the script. Set the noun property of ''theBox'' to N_BOX:
+
However, this won’t compile properly yet, because we have given it a noun that doesn’t exist. You can just remove the noun property altogether, but we want to actually interact with this box. So go to the message resource for script 110 (use the ''Messages'' link in the Toolbox pane). Add a new noun, and call it N_BOX (see [[scicd:/messages.html|Message editor]] to learn how to do this). Save the message resource and return to the script. Set the noun property of ''theBox'' to N_BOX:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>

Revision as of 20:24, 26 February 2016

SCI Tutorials

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11


Interacting with Objects
Author: Phil Fortier


This will show how to add an object to your room and interact with it.


Adding a Prop

First, go to the Game Explorer, and add the Box sample from the Toolbox’s Insert view sample menu. Give it resource number 123:

Box.png
 

Next, go back to the rm110.sc script and place the cursor at the bottom. Right-click InsertObject->Prop. Give it a name theBox, and set its view property to 123 (this is the Box view included in the template game). It should look like this:

Code:
(instance theBox of Prop
    (properties
        view 123
        x 150
        y 100
        signal ignAct
        loop 0
        cel 0
        noun N_NOUN
        priority 0
    )
)

However, this won’t compile properly yet, because we have given it a noun that doesn’t exist. You can just remove the noun property altogether, but we want to actually interact with this box. So go to the message resource for script 110 (use the Messages link in the Toolbox pane). Add a new noun, and call it N_BOX (see Message editor to learn how to do this). Save the message resource and return to the script. Set the noun property of theBox to N_BOX:

Code:
(instance theBox of Prop
    (properties
        view 123
        x 150
        y 100
        signal ignAct
        loop 0
        cel 0
        noun N_BOX
        priority 0
    )
)

We’re not quite done yet! In addition to declaring a Prop, you need to initialize it. This makes sense, since you might not always want Props to appear right away in a room. So go to the room’s init() method and add this to the end:

Code:
(theBox init:)

Now compile and run, and you should see the box in the center of the room:

BoxInRoom.png
 


Interacting with a Prop


 

< Previous: The First Room Next: The Priority Screen >