Check for obj when entering turf Not Working in Developer Help
|
|
The objs and entering them:
obj Red_Flag icon = 'redflag.dmi' Blue_Flag icon = 'blueflag.dmi'
turf Red_Ring icon = 'Rring.dmi' Entered(mob/M) if(/obj/Blue_Flag in M.contents) if(Red_Halt == 0) Red_Halt = 1 redteamscore++ var/obj/Blue_Flag/Bf del Bf Bf = new(null, src) if(prob(50)) Bf.loc = locate(101,101,2) else Bf.loc = locate(100,1,2) view() << "<B>Red</B> team has scored a point! They have [redteamscore]/13 points to go!" if(redteamscore>12) view() << "The game is over. <big><font color=red>Red</big></font> team is victorious!" view() << output("<font color=red>Red WINS! Rebooting . . .","log") world.Reboot() else M << "You must wait 12 seconds, do not continue to try before the time is up!" sleep(120) M << "<big>Time Up!" Red_Halt = 0 if(M.team == 2) M << output("Get it!","log") Blue_Ring icon = 'Bring.dmi' Entered(mob/M) if(/obj/Red_Flag in M.contents) if(Blue_Halt == 0) Blue_Halt = 1 blueteamscore++ var/obj/Red_Flag/Br del Br Br = new(null, src) if(prob(50)) Br.loc = locate(1,101,2) else Br.loc = locate(1,1,2) view() << "<B>Blue</B> team has scored a point! They have [blueteamscore]/13 points to go!" if(redteamscore>12) view() << "The game is over. <big><font color=blue>Blue</big></font> team is victorious!" view() << output("<font color=blue>Blue WINS! Rebooting . . .","log") world.Reboot() ..() else M << "You must wait 12 seconds, do not continue to try before the time is up!" sleep(120) M << "<big>Time Up!" Blue_Halt = 0 if(M.team == 2) M << output("Get it!","log")
|
Get:
obj verb get() set hidden = 1 set src in oview(2) usr << output("You get [src]","log") if(src!=/mob||/turf) if(src == /obj/Red_Flag) if(usr.team == 2) view() << "[usr.key] has obtained the Red Flag!" usr.contents+=src else src << output("That's <font color=blue>yours</font>!","log") return else if(src == /obj/Blue_Flag) if(usr.team == 1) view() << "[usr.key] has obtained the Blue Flag!" usr.contents+=src else usr << output("That's <font color=red>yours</font>!","log") return
|
Problem description:
-There are 2 objs. When I enter a turf I want it to check if the obj is in the contents and do an action.
--My get code just takes the item no matter what. It doesn't check for what I want it to.
Edit: Thank-you Garthor. You've helped me a lot. When I get a credit card I'm definatly gifting you a membership.
|
If you want to find an actual instance of an object, use locate().
Also: all the view()s should be view(src), otherwise they default to view(usr) and usr should not be used in procs.