ID:271725
 
I need to make it so the item is added to the list, then once its added to the list it appears on my build statpanel, and then it is deleted from the map.

Right now, i can add it to the list, but once i go to make it delete the source object, my code stops working.

What do i need to do?

var/obj/A = src
InventoryTwo += A
usr << "You have picked up a [A]!"
del src
That's because the source object has been deleted.
When you kill an object, and procedures running from it are killed as well.

Now, I'll just take a moment to explain about references. (for future reference)

obj/proc/test()
var/obj/A = src
world << "[A] is a new [src]?"


Now, you might think by assigning an object to a variable, you are creating a replica of that object under a new identity (in this case, it's new identity would be A, instead of src).

But in reality, this is simply creating a reference to an existing object.
In other words, now, when you access the object (A), you're actually accessing it's referenced object (the previous src). (basically, when you call "A", it's saying "jump to src")

And because of this, editing or killing A will in turn edit or kill src, and vice versa.

So, like I said before, killing an object also kills it's running procedures, so that's why it's stopping.
Super Silly Stuart wrote:
> var/obj/A = src
> InventoryTwo += A
> usr << "You have picked up a [A]!"
> del src
>


The problem is that A is merely a reference to src; you add A to InventoryTwo---the same as adding src to InventoryTwo---and then call del() on src, which is the same thing as calling del() on A. Essentially, you've just deleted the item that you added to the list. If you want to remove it from the map, just do that (move the object to null); don't delete it.

On another note, you may as well do away with the A variable altogether; in all of it's occurrences you could simply use src to the same end. When you output, you should use src.name, not src, so that lowercase names don't get prefixed with "the ", and you should use the \a text macro in place of directly typing "a", so that it can automatically determine whether to use "a", "an", or "some", instead of being constrained to one qualifier.

Hiead
In response to Hiead
ok, how do i make it so A is a new object of the same type and such?
I wanna make it so one of these 3 things happen.

1-either it just inherits all properties easily

2-or i can make it so that it inherits all properties another way...a way in which i need to use parsed text to make the code change a variable based on the text, without some kind of typed out parser for every different text, cause the text = the variables name..

3-pass it all through a proc
In response to Super Silly Stuart
[link]

Something like that?
In response to GhostAnime
i dunno what that is even....

i want some kind of verb as to where the original object is deleted from the map, and then the item is added to the statpanel so that u can create that object whenever u decide....like a building game, except u click on what u want, and whatever u click gets deleted, and then it shows up in the statpanel (within a list, that the statpanel views)
In response to Super Silly Stuart
1) It's a proc, not a verb (saw any /verb in it?)

2) Nope, not at all of what you said.

mob/Entered() is called when something successfully enters the mob, meaning when something is added to the contents. Eg:
object.Move(mob)
The object will be moved into mob's content, where Enter(), Entered() and other procedures are called.

The Entered() checks if the item that was just added is /Item or not. If it is, it's removed from the contents list and then added in to Inventory2 list variable.

The item was never deleted, just moved to another location. I hope you did take time to read the comments in that snippet.
In response to GhostAnime
ok, fine, i got what i need working anyways, because of that snippet, anyways, now i need help with my drop verb since in list2 the drop verb doesnt appear, and when i try to make it do so, it errors in the following way....

set src in usr.SecondInventory

TwoTimesInventory.dm:46:error:usr.SecondInventory:unsupporte d src setting




how would i make it so things in this list can be dropped with that verb??? without the verb showing up on items outside of the list.... like when i right click the item, it to not show up on other items...