ID:1307666
 
(See the best response by Kaiochao.)
Code:
area/Map_Edge
Enter()
.=..()
if(istype(usr,/obj/Energy))
. && del(usr)

else
..()


Problem description:

Areas.dm:5:error: : missing expression
Areas.dm:5:warning: &&: statement has no effect

I've always seen people use the .=..(), and I thought I semi-understood it, but I guess not. I want it to allow energy objects to enter it and then delete them. So I want it to return normally but then delete. Can someone explain what I'm doing wrong?

You can't use && in this manner, as the warning tells you. You get the error because it expects a if() or similar statement.

You just have to place it on the next line down or include a if() statement.
But I do have an if().
What's the point of allowing them to enter if they're going to be deleted right away?
The . proc returns a value of the proc it's contained in.
proc/factorial(N as num)
if(N<=0) return 1
return .(N-1)*N

proc/add(x, y) . = x + y


Now, the difference between the . proc and return is that return stops the execution of the current proc
AND returns the value to the caller-- the . proc only returns the value.

Take this example, for instance.

According to the reference, if the mob has no location, it's placed near (1, 1, 1). This is also the default action for the Login() procedure.
mob/Login()
// Reflecting back on what I told you, the . proc returns a value of the proc it's contained in,
// so since the default action of Login() is placing a mob near (1, 1, 1), we use it here.
. = ..()

// Do some action
do_something()
In response to Magnum2k
Magnum2k wrote:
The . proc returns a value of the proc it's contained in.
proc/factorial(N as num)
> if(N<=0) return 1
> return .(N-1)*N
>
> proc/add(x, y) . = x + y
>

Now, the difference between the . proc and return is that return stops the execution of the current proc
AND returns the value to the caller-- the . proc only returns the value.

Take this example, for instance.

According to the reference, if the mob has no location, it's placed near (1, 1, 1). This is also the default action for the Login() procedure.
> mob/Login()
> // Reflecting back on what I told you, the . proc returns a value of the proc it's contained in,
> // so since the default action of Login() is placing a mob near (1, 1, 1), we use it here.
> . = ..()
>
> // Do some action
> do_something()
>


So bear with me here...I'm a little slow. The . proc is used to call on the value that the parent proc returns?

And the reason I want them to enter and be deleted is so the projectiles don't pile up around the edges of the map.

In response to Khye
You could just delete them, then; instead of allowing them to enter THEN deleting them.

My response was to the
. && del(usr)
section, which case && wont work since it's not inside a if()(or like) statement.

Also, you shouldn't be using usr here, you should define the variable at the start of Enter() and use that as so.
turf/Enter(var/MovingAtom)//Define whatever moving atom you need
del(MovingAtom)//Delete that atom, preferably AFTER some sort of check; like if(isobj(MovingAtom)) del(MovingAtom)
In response to NNAAAAHH
NNAAAAHH wrote:
You get the error because it expects a if() or similar statement.
This is incorrect. The && operator exists independently of the if() statement, as all operators do.

The warning there is from using "del" as if it were a proc.
BYOND's built-in instructions, like sleep, del, return, winset, etc., can't be used in expressions like that because they don't return a value and are not real procs internally. When they're used, it's as if they're not even there.

Bottom line, && can be used outside of if() statements, but "del" can't be used in an expression.
In response to Kaiochao
And here I thought it was only & and not && that could be used out of a operator. Shows what I know, again. Thank you for correcting me, hate to be wrong and spread lies across BYOND :'(
Best response
Enter() is not necessary here.

Enter() is used when you want to selectively allow objects to enter src.
Its return value determines whether the object can or can't enter.

Entered() is the event that happens when the object successfully enters src.
Its return value affects nothing, and it does nothing by default.

Also, you're misusing usr.

area/Map_Edge
Entered(atom/movable/o)
if(istype(o, /obj/Energy)) del o
..()