ID:144360
 
Code:
area
portal
var/goloc
Entered()
usr.loc=src.goloc
test2test
goloc=locate(1,2,3)


Problem description:
It keeps giving me this error:

520:error::expected a constant expression

btw, line 520 is the one with goloc=locate(blah).

Thanks in advance,
-Meta
You shouldn't be using usr in Enter(). Make an argument in Enter() such as
area
teleport
Entered(atom/movable/A) //it's better to use Entered() for teleports
if(ismob(A))
var/mob/M = A // we typecast so we dont use the : operator
// do the default mob stuff here.
else if(isobj(A))
var/obj/O = A //type cating again
// now do the default stuff
else // for some odd reason another type happend to enter
// deal with this behavior here.
Just as the error says, you must use constant expressions in variable initializations (that means you can't use other vars and procs in them). So you can't use locate(). Complicated initializations must be done in New() -- you can use locate() in there, and use 'teleport_x','teleport_y','teleport_z' vars defined on the portal object - if you want, you could have a single 'coords' text string var with the x,y,z coords separated by commas (eg "1,1,1") and parse that in New(), as well.
Also, you better not force changing of the loc var - that fails to call any movement system procs, which can break things that rely on them in your game. Rather, use the Move() proc, (with a temporairy density=0 for teleportations to make sure the movement will succeed, by default) or to force the movement (it will always succeed), a set_loc proc (look here: [link]).
In response to Xx Dark Wizard xX
Dark Wizard: If you check the type and make sure it's the correct one, you don't have to typecast to refrain using the : operator - also, you can just typecast the argument as a /mob for example to save you 1 typecasting.
Note though that the last 'else' should NEVER happen anyway - unless the code calls Entered() manually (with a faulty arg) - and is pretty useless, you probably won't want to do anything in that case anyway.