contents+=new/obj/Items/Sword
//Error displayed - cannot append to list
Problem description:
Why do I get this error?
Code:
contents+=new/obj/Items/Sword Problem description: Why do I get this error? |
Nov 8 2016, 7:47 pm
|
|
I need more context here. However, the better syntax by far would be new/obj/Items/Sword(src).
|
In response to Lummox JR
|
|
Its a simple starter item for directly after you've created a character, and after fiddling around for a bit i came up with the same solution as you, however, every time an object is picked up using the get() verb, after saving then restarting dream seeker and loading the savefile, i get the same error and the contents of the character is wiped (no items, or skills)
obj |
That's because I changed it to loc=usr when I was fiddling around during testing, but the error would still occur occasionally, albeit not all the time. Before it was :
usr.contents.Add(src) |
In response to Lummox JR
|
|
Ah, the cause was old save files from before it was changed. Well then..., since up to now this was a waste of your time, let me ask you something else that I've been wondering about. What is:
.=..() |
. = ..() means to call the parent proc, and use its value as the default return value.
If you override a proc, like for instance obj/item/Click(), then ..() will call the parent--which might be obj/Click() or atom/Click() or so on. (You can override the very same proc more than once and one will be the parent to the other, but that's usually a bad idea.) The . var is the default value for return; it starts out as null. Where you often see . = ..() is in procs like Move(), where the return value matters. When you call the parent, you often want to use the value it returned, but still do other work first. For instance: mob/Move(newloc, newdir) This calls the default Move() if the mob isn't dead, but if the move succeeded, it also calls a proc called TookStep() that might do additional housekeeping. |