ID:149844
 
Like many people on this region of the forum i have a problem one i cant solve so im asking you for help.

in a pick up verb i have i want the sertain obj(in this case a sword)to move to a panel called Weapons.
Here it is

Pick_up(O as obj)
set src in oview(0)
if(istype(O,/obj/swords))
src.Move(Weapons)
usr<<"You pick up the [O]"
else
src.Move(contents)

mob/var/list/Weapons
var/obj/O = Weapons
mob
Stat()
statpanel("Weapons",Weapons)
return ..()

but when i use the pick up verb on a sword it says the messege "You Pick up the [O]" but it doesnt move to the Weapons nor the contents, it doesnt move at all just stays on the map.
Am i missing something?
sorry about the indentation it is right in the code.
Try changing Move(contents) to +=(contents)
In response to Kappa the Imp
that wont help any....
Vicious wrote:
Like many people on this region of the forum i have a problem one i cant solve so im asking you for help.

in a pick up verb i have i want the sertain obj(in this case a sword)to move to a panel called Weapons.
Here it is

Pick_up(O as obj)
set src in oview(0)
if(istype(O,/obj/swords))
src.Move(Weapons)
usr<<"You pick up the [O]"
else
src.Move(contents)

You seem to have misunderstood the use of Move(), here. Move(contents) is not, so far as I know, valid in any way. For one thing, that would be src.contents and thus you'd be moving the object into itself. For another, Move() is supposed to take an atom, not a list.
Your code is also not clear on what src is supposed to be. If it's the obj being picked up, then the "O as obj" argument is redundant. If it's the player, the "set src in oview(0)" line should really be "set src = usr", and src.Move() should be O.Move(). If it's neither, the verb shouldn't be where it is at all. As your verb stands now it's a sort of ambiguous case in between object-oriented and user-oriented code, and won't work.

Whether an object is a weapon or not, it should still end up in usr.contents because they are indeed picking it up. It can then be added to a list, if necessary:
obj
verb/Pick_Up()
set src in oview(0)
var/mob/M=usr
if(istype(O,/obj/swords))
M.weapons+=O
O.Move(M)

mob
var/list/weapons // remember to initialize this to list() in mob/New()

That puts the Pick_Up verb ("get" will be easier to type, but it's your game) in the obj's code, where it probably belongs. You could also assign this verb to the mob, and then you'd use the O argument but it would be "O as obj in oview(0)"; the code is actually more complicated if you implement it that way.

I would suggest that the weapons list is probably not necessary and too much trouble to maintain, unless you want this for purposes of picking from a list later (such as through input() or other mechanisms). For Stat(), you could quite simply do this:
mob/Stat()
statpanel("Weapons")
for(var/obj/swords/w in src)
stat(w)

I like lists a lot, but they do involve upkeep work that you'll have to watch out for. My thinking is that if you really don't need one, don't use it. For just the stat panel a simple for() loop is probably just as efficient.

Lummox JR
In response to Lummox JR
Thank you, the whole point of this was to get the Pick up verb for swords to add the selected sword to the weapon list so i can make that list come up when the user wants to sell,ect ect(i dont want to say more).