Difference between revisions of "Interacting with Objects"

From SCI Wiki
Jump to navigationJump to search
()
Line 94: Line 94:
 
The ego will turn to look at the box and the message will be displayed. Easy, right? You can add more messages to handle different verbs on the box.
 
The ego will turn to look at the box and the message will be displayed. Easy, right? You can add more messages to handle different verbs on the box.
  
==<br /> ==
+
==<br /> Approach Verbs ==
  
  

Revision as of 20:33, 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

That was the hard part. Now the easy part.

Suppose we want to display a message when the player looks at the box. To do so, add a message for the LOOK verb on BOX:

BoxMessageLook.png
 

Save the message resource and run the game, and try to look at the box:

BoxMessageGame.png
 

The ego will turn to look at the box and the message will be displayed. Easy, right? You can add more messages to handle different verbs on the box.


Approach Verbs

 

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