Problem with giving objects

CoolGuyMalohn
06 Nov 2016, 19:13

So I have a part of my game where the player has to choose which person they give an item to. The problem is, once the player gives an object to one of the people, the object is not removed from their inventory, so they can just give it to both people. So how do I get the item to leave the player's inventory?


hegemonkhan
06 Nov 2016, 22:08

There's Objects and there's a 'clone' Script/Function that makes a copy of them. There's also also Object references too, involved with the Object, Object List, and Object Dictionary Attributes. These are just references, not the actual/"physical" Objects, but they can/are used to control the referenced Object.


An Object's location is controlled/determined/set by the 'parent' Object Attribute:

scripting:

player.parent = room
player.parent = room99

aslx/xml 'creation' tag block:

<object name="room">
</object>

<object name="player">
  <attr name="parent" type="object">room</attr>
</object>

// which is the same as this:

<object name="room">
  <object name="player">
  </object>
</object>

or, you can use the 'MoveObject (NAME_OF_MOVING_OBJECT, NAME_OF_DESTINATION_OBJECT)' Script/Function, instead

in GUI/Editor:

run as script -> add new script -> 'Objects (I think)' section/category -> 'Move an Object (or something like this)' Script -> set it up


to remove an Object, there's 3 methods:

  1. http://docs.textadventures.co.uk/quest/functions/corelibrary/removeobject.html (this just moves the Object from within some Object to within the ''
  2. http://docs.textadventures.co.uk/quest/scripts/destroy.html
  3. Moving an Object (already discussed way up above) to being within some other Object

if you could provide more details at what you're doing, then I can help you with getting it to work.


CoolGuyMalohn
06 Nov 2016, 22:20

I have it so that at some point, you receive a doll. Later, you run into a girl who claims it is hers, but upon giving it to her, she destroys it. Next you run into a little girl who says her sister stole her doll and wants to break it, and upon giving it to her, she is grateful. The problem is, I want the player to only be able to give it to one of the girls, but the doll never leaves the inventory, so you can give it to both.

Thank you for your help!


hegemonkhan
06 Nov 2016, 22:38

I don't know the built-in 'give' that well, but I'm pretty sure it should move (NO cloning) the Object, so it shouldn't still be in your inventory... as it should be given (moved) to that other Object.

could you add in scripting to see whether the 'doll' Object is indeed moved to the other Object or not (as well as it staying within your inventory --- the reason is that unless you made a Clone, the Object shouldn't still be in your inventory after using the built-in 'give' Script/Function) ?? if you don't know how to do this, let me know... or... it'd be easier to just.... (see below)

if you could tell me scripting-wise what you did... or if you don't mind, posting your entire game code (if it's not too big of a game, hopefully, lol), would help me to figure out what you need to do to fix it up.


here's the tutorial on give (not much --- almost all of it is on 'use' but it's similiar to how 'give' works):

http://docs.textadventures.co.uk/quest/tutorial/more_things_to_do_with_objects.html

and here's the docs on 'give' :

http://docs.textadventures.co.uk/quest/attributes/give.html
http://docs.textadventures.co.uk/quest/attributes/giveanything.html


are you using the GUI/Editor and selecting the Object to give from a drop down box or are you typing in the Object? If you're typing it in, you must type in it's 'name' exactly.


OurJud
06 Nov 2016, 22:50

@CoolGuyMalohn, are you using the 'move' script after the object has been given?

I'm going to presume you have actually created the object, so all you should need to do is add:

MoveObject (doll, trash)

This is assuming your object is named doll and you've created a 'dead' room called trash. Dead rooms, as I call them, are created in the normal way, but never seen or used by the player and are for dumping unused inventory items)


XanMag
07 Nov 2016, 00:15

Or you could use the 'remove object' script and get rid of the doll permanently.