ID:1970823
 
(See the best response by FKI.)
I'm currently in class and, rather than paying attention, decided to work on a Capture the Flag script. I just tested this by putting the flags on a basic map with crappy grass turfs and a circle for the player.. bla bla bla. Unfortunately, Entered() isn't being called when I actually enter. I read the documentation on Entered() and... yeah. I'm starting to wonder if I overlooked anything.

// CTF.dm
// This script handles the capture the flag
// game.

var/obj/GameObjects/CTF/Flags/Flag = new('Flag.dmi', "Flag")

mob/attackable/player
var
team = "red"
obj/GameObjects/CTF/Flags/Flag/takenFlag

proc
GiveFlag(obj/GameObjects/CTF/Flags/Flag/f)
src.overlays += Flag
takenFlag = f
//slow the users speed here

TakeFlag(scored = 0, mob/attackable/player/p)
src.overlays -= Flag
if(!scored)
src.takenFlag.GiveFlag(p)
else
src.takenFlag.GiveFlag()

src.takenFlag = null

obj
GameObjects
CTF
Flags
Flag
var/taken = 0
var/score = 0
var/team = ""
layer = MOB_LAYER + 1
icon = 'Flag.dmi'
icon_state = "Not Taken"

Entered(mob/attackable/player/O) // Originally just O.. I just breifly tried changing the type of the var
if(istype(O, /mob/attackable/player))
var/mob/attackable/player/p = O
if(p.team != src.team && !src.taken)
src.TakeFlag(p)

if(p.team == src.team && p.takenFlag)
src.ScoreFlag(p)

proc
GiveFlag(mob/attackable/player/p)
icon_state = "Not Taken"
taken = 0
if(p)
world << "[p.name] has [(p.team == src.team) ? "returned the flag to [src.team]." : "scored [src.team]\'s flag for [p.team]."]"

TakeFlag(mob/attackable/player/p)
icon_state = "Taken"
taken = 1
world << "[p.name] has taken [src.team]\'s flag."
p.GiveFlag(src)

ScoreFlag(mob/attackable/player/p)
p.takenFlag.GiveFlag(p)
p.TakeFlag(1)
src.score++
Best response
I think you want Crossed() instead. Entered() is called for movable objects when something is placed in its contents, not when they step on/in it.
I always thought Entered() was still possible of checking if something is inside of it. *shrugs* I know crossed will do the job though. Haven't tested it but it should work flawlessly. Thanks.
In response to Xirre
You're not inside a bag if you're standing on top of it, right?
Enter/Entered are called when something is added to the source's contents, while Exit/Exited are called when something is removed from the source's contents. Idea for creating a stackable items inventory system.
In response to Kaiochao
Kaiochao wrote:
You're not inside a bag if you're standing on top of it, right?

If it's a bag of holding, you are never technically inside of it. You are actually in a parallel reality.

Anyway, Enter/Entered() are only called when you actually call Move(). It's not triggered by any other means of adding to contents. Be mindful of this.

This is part of why I never recommend setting locations manually, because you can't rely on accurate Entered()/Exited() parity.