Give Item to...


Items need to be given away sometimes. Add a second character to your game, it can be the same one. The characters name will get a number at the end if you do so.

Handle this second character like an object (yeah, you like that dont you?). Add to the characters script a click and a mouse event.

on (mouse)
 showinfo (The other guy; true)

on (click)
 walkto (self ; x ; y ; lookto)

To make an item available for a Give-Away add those lines to the items script :

on (give)
 givelink ()

The scriptcommand givelink will automaticly remember the items name, so you don't need to provide a parameter. The actiontextline of the game should now contain "Give Item to"

Now add these lines to the second characters script :

on (givelink)
 {
 delitem (self ; givelink)
 additem (character2 ; givelink)
 pickup (self)
 pickup (character2)
 }

Both characters will perform their pickup animation. Instead of an itemname you use the term "givelink" which adds and deletes the previous item. Now your item is in the inventory of your second character. You can switch to him/her by using the setfocus command.