Combining things |
The main aspect of an adventure game is to use items with other things. To try this out we will lock the door so we can unlock it. First we need a Bool. So click on the plus-button to add one and name it "door_open". We want the door to be locked at the beginning of the game so our bool should be false (unchecked).
Now go to the script of the door and change its "open" event :
on (open) { if_obj (door ; 2) break () if_bool (door_open ;
false) setobj (door ; 2) |
The item you created before will be used to unlock the door... yes, no matter what it actually is. Click on your item within the gamepool while the scriptwindow is open. Edit its script now :
on (mouse) on (look) on (use) |
With the script command link the current game command will change to "link". This is the moment when the actiontext in the game contains something like "Use MyItem with". The parameter "linkname" can be anything you want and does not have to be the name of your item.
Now the door needs to react to the link event.
on (link) speech (self ; I cannot use this with a door.) |
The script checks if the linkname is correct. The player could try to use something else with the door. If the linkname is correct the bool for the door will be set to true (Door open) and the item will be deleted. Deleting the item is optional. You can also check for more than one linkname and use more items with the same object. Make sure that there is a break () at the end of the event. The last Speech command handles wrong linknames when the player tried to use something with the door that does not work.