Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SilverSpook on Wed 06/05/2015 22:59:49

Title: Copies of an Object
Post by: SilverSpook on Wed 06/05/2015 22:59:49
So I need many copies of a certain object, in this case a screw, which the player will use.  Is there a way to instance an object multiple times so that all the properties (image, description, etc) of each instance are identical?  If that's not possible, is there a way to copy an object?

Thanks
Title: Re: Copies of an Object
Post by: Mathias on Thu 07/05/2015 08:41:50
I'm not sure if I understand what you mean, but perhaps this link might be of use to you despite it being old:

http://www.adventuregamestudio.co.uk/forums/index.php?topic=37701.0

If you want several screws but in separate inventory slots I'm pretty sure you have to give each screw a separate object id.
Title: Re: Copies of an Object
Post by: Khris on Thu 07/05/2015 13:17:45
An object as in a room object? Or an inventory item?
You need to be more specific.
Title: Re: Copies of an Object
Post by: Monsieur OUXX on Thu 07/05/2015 16:37:22
I've you're talking inventory objects, yes, there are solutions -- if I recall, the object virtually exists only once but there's a count on how many of it the player carries)
Title: Re: Copies of an Object
Post by: SilverSpook on Thu 07/05/2015 20:48:40
I'm talking about creating a room object, "oScrew" for example, and then duplicating that object so there are multiple copies of it lying around a room.  For example, on a table.

Is that possible?
Title: Re: Copies of an Object
Post by: Mandle on Thu 07/05/2015 23:31:07
If you mean multiple objects but counted as a single object with a single object name then I think the answer is no.

If you mean to be able to copy objects for your own convienience when making the room: I believe there is a template option you can use...

If your problem is that you want to put so many screws that you are exceeding the room object limit then one solution might be to create three graphics (or more) for your "oScrews" object:

Many screws, half that amount, and just a few left (if that makes sense) and then change the object image as a variable counts down whenever a player takes one. You could also include the counter in the text when a character looks at the screws like:

"There are 123 screws left on the table."
Title: Re: Copies of an Object
Post by: SilverSpook on Fri 08/05/2015 04:03:36
@Mandle: I was mostly thinking of the convenience of making several identical objects without having to re-input all of their properties each time I create a new one.  I'd be interested in such a template option!
Title: Re: Copies of an Object
Post by: Snarky on Fri 08/05/2015 06:17:40
Unless I'm misremembering, can't you just right-click on an object in the room view to duplicate it?
Title: Re: Copies of an Object
Post by: SilverSpook on Fri 08/05/2015 07:17:54
According to my AGS 3.4 on right-clicking an object in a room you can "Delete", "Place new object here", or "Copy coordinates to clipboard".
Title: Re: Copies of an Object
Post by: Snarky on Fri 08/05/2015 07:55:35
Ctrl-C Ctrl-V, then? I'm pretty sure there is a way to copy an object.
Title: Re: Copies of an Object
Post by: SilverSpook on Fri 08/05/2015 08:01:21
That would make sense, but Ctrl-C, Ctrl-V doesn't work.
Title: Re: Copies of an Object
Post by: Snarky on Fri 08/05/2015 09:20:00
Hmm, how about having an object selected, and then right-clicking somewhere else on the background?

(If that doesn't work, I give up and leave it to someone else who either know this stuff better or have the editor in front of them. I wonder if I might be thinking of GUI controls, which can definitely be copied.)

Though honestly, there aren't that many things you need to set for an object, so it shouldn't really be a ton of work to do it manually. It's really just graphic, script name and label in most cases; then of course you have to set the event handlers (but those probably wouldn't be copied in any case).
Title: Re: Copies of an Object
Post by: Crimson Wizard on Fri 08/05/2015 10:06:23
There is a copy/paste command for GUI elements, but not for Room objects. Idk why, but it was never added.
Title: Re: Copies of an Object
Post by: SilverSpook on Sun 10/05/2015 23:20:55
Ah, that makes sense.  Thanks.

I think what I was really thinking of is a method of instantiating objects from a template.  Which provides 1.) Time savings on placement of objects 2.) in the case that you modify a parameter of the template, changes would propagate to all instantiated objects.  (As in Object-Oriented-Programming C++/C#/Javascript objects). 

Perhaps it's not really extant/feasible/reasonable in the context of AGS.
Title: Re: Copies of an Object
Post by: Crimson Wizard on Mon 11/05/2015 13:46:03
Quote from: SilverSpook on Sun 10/05/2015 23:20:55
Perhaps it's not really extant/feasible/reasonable in the context of AGS.
I think its feasible in the AGS Editor. The engine would require an overhaul to do this at runtime, though.