ID:175204
 
    Entered(mob/PC/M in world,var/obj/BlueFlag/B,turf/BlueFlagChecker/T)
if(M.contents == /obj/BlueFlag)
B.loc = T.loc
world<<"[M] returned the Blue Flag saftly!"


Eh...it simply dosn't work. I dont get any compile time errors, or runtime errors. Nothing happens when I step into the turf. All help is appreaciated.
SSChicken wrote:
Entered(mob/PC/M in world,var/obj/BlueFlag/B,turf/BlueFlagChecker/T)
if(M.contents == /obj/BlueFlag)
B.loc = T.loc
world<<"[M] returned the Blue Flag saftly!"



Eh...it simply dosn't work. I dont get any compile time errors, or runtime errors. Nothing happens when I step into the turf. All help is appreaciated.

You are assuming you know what is going to be passed to Entered...you don't know what kind of object will be passed, in particular why would a BlueFlag be passed? Unless you are calling Entered yourself.

Second, you are asking if M.contents, an array, is equal to a BlueFlag. An array is never going to equal a flag...you probably want to know if the flag is inside the contents, which is going to require you to iterate through the array and check each item.

I don't have time to provide the code, but hopefully this gives some hints.
In response to Deadron
Deadron wrote:
you probably want to know if the flag is inside the contents, which is going to require you to iterate through the array and check each item.

<code>if (locate(/obj/BlueFlag) in M.contents)</code>

=)

SSChicken, what exactly are you trying to do? What are all those arguments supposed to refer to, exactly?
In response to Crispy
If the player has in his contents the blue flag and he enters the redflag field he scores a point!...Thats what I'm trying to acomplish. Now I tried the stuff you told me (except Deadron's first suggestion) and neither worked.


Crispy's way

    Entered(mob/PC/M in world,obj/BlueFlag/B,turf/BlueFlagChecker/T)
if (locate(B) in M.contents)
B.loc = T.loc


OR

    Entered(mob/PC/M in world,obj/BlueFlag/B,turf/BlueFlagChecker/T)
if (locate(B) in M.contents)
B.loc = T.loc


Deadron's way

for(B in M.contents)


or

for(/obj/blueflag in M.contents)



[Edit]
One more thing, how do I add a HTML intro into my game. I already made it in word. The extention is .txt now how do I implement it into my game. I tried usr << run(Intro) and it asks if I want to open the .txt file. I don't want that, I want it to be automatic. And even if I do click yes the actual .txt file opens, instead of its HTML version. I'd be glad if someone told me how to do it or showed me a demo or something.
In response to SSChicken
for(var/obj/blueflag/O in M.contents)


That should work.
You're not using Entered() correctly. You've given it three arguments when it only takes two, so the third will never be anything but null.

The first argument to Entered() is the atom/movable that entered src.contents. The second argument is that atom's old location, but most of the time you won't need that.

When the arguments are correct, there's still no guarantee that the items you get will be the types you specified. M, for example, may be an obj or another kind of mob.

Furthermore, this line is bogus:
if(M.contents == /obj/BlueFlag)
M.contents is a list--and not even an ordinary list, but a special internal one. /obj/BlueFlag is a type path. A list will never be equal to a type path, so this if() will always fail. Nor can you say if(/obj/BlueFlag in M), which is another common mistake; M.contents contains atoms (actual objects), not type paths.

There are two correct ways to look for a flag in M.contents:
var/obj/BlueFlag/B = locate() in M
if(B) // a flag was found
B.loc = src
world << "<B><font color=blue>[M.name] returned [B] to safety.</font></B>"
Or...
for(var/obj/flag/F in M)
if(F.team == src.team) // assume this turf has a team var
F.loc = src
world << "<B><font color=[F.color]>[M.name] returned [F] to safety.</font></B>"
There's something else I changed here that's critical. Look at this line in your original code:
B.loc = T.loc
Since you defined T as a turf--and you probably meant src instead of T, since this Entered() proc belongs to a turf--T.loc would be an area, not a turf. B.loc=T would be correct, so I changed it to B.loc=src.

You'll notice too that in the second version I actualyl changed things around a bit. It's a very bad idea to do separate types for things like /obj/RedFlag, /obj/BlueFlag, etc., when you can have /obj/flag/red and /obj/flag/blue and give them a team var instead.
atom
var/team
var/color

New()
if(team && !color) color = team

obj/flag
New()
..()
name = "[team] flag"

red/team = "red"
blue/team = "blue"

turf/flagpole
Entered(mob/M)
if(!M.team) return ..()
var/obj/flag/F
if(M.team != team)
for(F in src)
F.loc = M
if(F.team == M.team)
// their own flag is lying here
world << "<B><font color=[M.color]>[M.name] retrieved [F]!</font></B>"
else
// our flag has just been stolen
world << "<B><font color=[M.color]>[M.name] stole [F]!</font></B>"
else
for(F in src)
if(F.team != M.team)
// a flag is lying here
F.loc = M
world << "<B><font color=[M.color]>[M.name] stole [F]!</font></B>"
for(F in M)
if(F.team == M.team)
// return the flag to its place
F.loc = src
world << "<B><font color=[M.color]>[M.name] returned [F] to safety!</font></B>"
There are other ways to handle this too; one of the better ones is to make the team var a datum instead of just text, so it can hold a list of players on the team. But this should give you some good ideas.

Lummox JR