ID:266717
Jun 2 2002, 3:48 pm
|
|
I've tried if(contents == null) but it didnt work. Any ideas?
|
In response to Lummox JR
|
|
How do I fix that with this then?
obj |
In response to Thief Jack
|
|
if(!contents.len) |
In response to Malver
|
|
Nope, not what i was looking for
|
In response to Thief Jack
|
|
Thief jack wrote:
How do I fix that with this then? obj/var/SwordX = 1 The problem you're having here is that you're mixing up which things to check, and when. You've got things put in loops that don't really belong there, and the contents.len check is actually irrelevant to your problem. As the code stands now, if you have a sword and other items in contents, it could go through several checks with other items saying "You get [src]!" until finally it finds and moves the sword. (And, because the first version of the move code doesn't match the second below, src.suffix and src.SwordX are never set.) Let's look at the loop first: for(var/obj/O in usr.contents) The code in the else block you really only want to execute if no swords are found; however, it will run for every item found that isn't another sword. Considering the way this is all set up, what you'd probably want to do is run through the entire loop, execute the code in the if() if it matches, and after the loop just let the code fall through to what you've got under the other else: obj/sword/verb/Get() That's already much shorter. One thing you should know, though, is that you don't even need to use a loop. You can use locate() here: var/obj/sword/O = locate(/obj/sword) in usr Lummox JR |
contents is a list, which is never null. What you want is this:
Lummox JR