ID:156266
 
How would I make a capsule where i can put 1 object in it then be able to deploy it or look to see whats inside of it
like a storage system
The word you're probably looking for under "Demos" is 'stack'
In response to Flame Sage
no thats not actually what im looking for a way to store items not a thing to tell me i have 5x chairs like a storage box kind of thing where you can withdraw/ depoist items into the capsule
By placing the object inside the other object's contents. There are no new concepts, really, so figure it out.
In response to Garthor
Dont you have something better to do then post pointless crap in threads honestly seriously if your not going to help do leave
In response to Mastergamerxxx
I am giving you the answer. If you want object A to contain object B, then move object B to object A's contents. Or, in other words, B.loc = A.
In response to Garthor
obj
Capsule
icon='Capsule.dmi'
desc="This capsule can hold one item of your choice..."
var/contains
verb
Whats_In_This()
usr << "<b>Looks like there is a [contains] in the capsule."
Deploy()
usr.contents+=contains
usr << "<b>You deploy the [contains]."
contains=null
Insert(obj/items/I in usr.contents)
if(!contains)
contains+=I
del(I)
else
usr << "<b>There is a [contains] already inside..."


So how would I fix this would I then put I.loc=src.loc?
In response to Mastergamerxxx
You should do what I said you should do.
In response to Garthor
I know but how do I go about doing it like what am i making the loc like i look at the code and im instantly lost as to what to put where and to what to change
In response to Mastergamerxxx
Mastergamerxxx wrote:
...
> Insert(obj/items/I in usr.contents)
> if(!contains)
> contains+=I
> del(I)
> else
> usr << "<b>There is a [contains] already inside..."
>
>

Why do you have contains+=I? Is contains a list that you are adding the I to it? Remember, if you want to reference something, it's just =. If you do want to have a list of things in the capsule, that's still not going to work properly for several reasons.

If you want it to be a list, you have to make it a new /list.

if(!contains), assuming contains is a list, is not going to work how you think it is. !contains will always evaluate to false as long as contains is not null, even if it is empty.

However, you are setting contains to null in deploy, so perhaps you don't want a list of things in it, you only want the one thing?

Why are you deleting the object when you store it? When you delete it, it's gone, so it's not in the capsule anymore. But then you try to take it back out when you deploy... but there's nothing there because you used del on it.

Instead of deleting it, just put the object into the capsule at that point the way Garthor said. Instead of deleting it, set contains = the object and remove it from the player's contents, or instead of using the contains variable you could (but obviously don't have to) put it into the contents of the capsule, or use Move() on the object to I.Move() it into the capsule. However, if you actually put the object into the the contents of the capsule object, and if you only want 1 object in the capsule, remember you'll have to check the contents of the capsule every time you try to put something into it.

So there's a bunch of issues here. Hopefully this helps you start to sort them out. If you still have issues, feel free to ask, just remember to ask clearly and with detail on what you're doing. No offense intended, but if I were replying to your original question I would not have been very helpful either, as there wasn't much in it to say anything constructive about. I say this often around here to many people; help us help you. You'll get much better results from it, and you'll definitely realize it's worth the effort.

To be more precise, before I saw Garthor's answer I was going to reply with the following:
mob/verb/make_a_capsule()
var/obj/capsule/o = new(src)
o.contents.Add(new /obj)
obj/capsule
verb/deploy()
loc = usr.loc

That is all I was going to post, nothing more.

Technically, that satisfies the requirements of your initial post. I now know that this does not satisfy the requirements you had in mind, but I did not know that until after your later post.

Anyway, hope all this helps.
Move the objects into the 'contents' list of the capsule object. To display the capsules contents, use a grid or statpanel and output it the same way you do for the users contents.