Giving objects between two characters
cdutton184
12 Sept 2013, 13:38I'm planning to write a game where you play two characters and I've worked out easily how I can 'switch' between characters.
However, I'm struggling on how to give any object from one character to the other character and vice versa. I don't want to be stuck giving each object an individual 'give to' script for each character.
Please, help!
However, I'm struggling on how to give any object from one character to the other character and vice versa. I don't want to be stuck giving each object an individual 'give to' script for each character.
Please, help!

jaynabonne
12 Sept 2013, 17:08It looks like the core "give" command supports a general purpose handler on a recipient. You should be able to implement a "giveanything" script on each character, which will be called when "give X to Y" is input (the script is on Y). The parameter coming in will be "object" for the given object.

jaynabonne
12 Sept 2013, 17:14Sorry, you need to create an empty "give" scriptdictionary on the character as well for the above to kick in.
cdutton184
14 Sept 2013, 11:35jaynabonne wrote:It looks like the core "give" command supports a general purpose handler on a recipient. You should be able to implement a "giveanything" script on each character, which will be called when "give X to Y" is input (the script is on Y). The parameter coming in will be "object" for the given object.
Sorry, Jaynabonne but I'm not a programmer. I write all my games using the menu system in Quest and know only the basics when it comes to handling variables. I have no idea how to start creating the above. You'll have to either explain it in plain English or write a script for me, thanks in advance.

jaynabonne
14 Sept 2013, 12:48Looking deeper now, I see an easier way to do it (via the menus as opposed to attributes).
For each object which you wish to be able to receive (e.g. your two characters), do this:
1) Click on the character, and then on the Use/Give tab
2) Under "Give (other object) to this", select "Handle objects individually". (This will create the empty "give" dictionary I mentioned above.)
3) Now you will also be able to see something new: "Give any other object to this". This is a place where you can put a script. The script will receive a parameter called "object" which is the object given.
4) If your desired behavior is just for the recipient to take the object, then click "Add new script" there, then under "Objects", select "Move object" and hit "Add". It will bring up "Move object <object> <> to <object> <>".
a) Change the first "object" to "expression" using the drop down. In the field to the right of it, type "object".
b) Change the second "object" (after "to") to "expression" using the drop down. In the field to the right of it, type "this".
That's it for that one. Again, you'll need to do this for each character you wish to be a recipient.
If you want more involved behavior, then let me know what you'd like to have happen, and we'll see what we can do.
For each object which you wish to be able to receive (e.g. your two characters), do this:
1) Click on the character, and then on the Use/Give tab
2) Under "Give (other object) to this", select "Handle objects individually". (This will create the empty "give" dictionary I mentioned above.)
3) Now you will also be able to see something new: "Give any other object to this". This is a place where you can put a script. The script will receive a parameter called "object" which is the object given.
4) If your desired behavior is just for the recipient to take the object, then click "Add new script" there, then under "Objects", select "Move object" and hit "Add". It will bring up "Move object <object> <> to <object> <>".
a) Change the first "object" to "expression" using the drop down. In the field to the right of it, type "object".
b) Change the second "object" (after "to") to "expression" using the drop down. In the field to the right of it, type "this".
That's it for that one. Again, you'll need to do this for each character you wish to be a recipient.
If you want more involved behavior, then let me know what you'd like to have happen, and we'll see what we can do.