ID:144267
 
Heres My Code...

obj
verb/Pickup()//get verb used when the person is next to or on the object
set category = "Commands"//puts it in the 'other' category
if(src in view(1))
if(src.Owner = usr.key)
src.loc = usr
else
usr << "This is not yours."


obj/var/Owner

<\dm>

<b>Problem description:</b>
I Get This Error...

Houses.dm:173:error::invalid expression

When i double click this,
It shows this part of the code:

<dm>
if(src in view(1))


Can someone help?
Please.

- Bevan
I don't think posting this on two different forums will help, or is allowed in that matter.
In response to DarkD3vil666
I posted it in the rong forum,
So i moved to here.

I posted in Developer How-To
Wich is wasent suposed to be there
So i moved here.
Everything below set category="Commands" is indented one tab too far.
In response to Xooxer
Had 3 errors,
Can you recreate my code to show me what you mean.
In response to BEVAN
obj
verb/Pickup()//get verb used when the person is next to or on the object
set category = "Commands"//puts it in the 'other' category
if(src in view(1))
if(src.Owner = usr.key)
src.loc = usr
else
usr << "This is not yours."


Plus, I'm not sure this will do what you want it to. src is the object being picked up. The first if() will always be true.
In response to BEVAN
1) It's spelled "wrong" not "rong"

2) There's a reason why people say not to copy and paste... you are trying to check if something is equal by = and NOT ==

- GhostAnime
In response to Xooxer
I want someone to pick up a obj, And its then theirs (If the obj has no owner)
But if someone owns the obj (Like in their house)
Only they can pick it up,
No one else can.

Is the code right for that?
In response to BEVAN
I believe you'd want something like this:
obj
verb/Pickup()//get verb used when the person is next to or on the object
set category = "Commands"//puts it in the 'other' category
set src in oview(1)
if(src.Owner)
if(src.Owner == usr.key)
src.loc = usr
else
usr << "This is not yours."
else
usr << "You pickup [src.name]."
src.loc = usr
src.Owner = usr.key


The set src in oview(1) replaced your first if() statement. This tells the game to give the Pickup command to anyone in 1 tile or less of the object. The oview() proc keeps the verb from being used after the person picks up the object, since view() will let them pick it up from thier inventory. Also, you forgot to check to see if there was already an Owner assigned. That's the new first if() statement above. Finally, the last else actually does the pickup and sets the Owner to the key of the person picking it up.

Questions? Hope this helps.

~X

[Edit] Oh, and as Ghost Anime said, you need to use two equal signs when testing if things are the same. One equal sign makes the left thing the same as the right thing.