ID:148686
 
For some reason, I tried running a control box by attacking the Collective Control Box (in my game), it said as though I were trying for a friendly, not an enemy. Here are the two code bits that are relevant.


obj
CollectiveControlBox
icon = 'collectivecontrol.dmi'
density = 1
verb
Pickup()
set src in oview(1)
if(usr.Team == "Titan")
world << "Titans win!"
usr.score += 1000
usr.Experience += 1000
for(var/mob/M in world)
if(M.Team == "Titan")
M.score += 1000
M.Experience += 1000
world.Reboot()
else
usr << "Do you REALLY want to betray your own team?"

Team()
switch(input("What team do you want?","Team","Collect") in list("Titan","Collective"))
if("Titan")
if(usr.Team == "Collective Militia")
usr.overlays -= /obj/overlays/Collective
usr.Team = "Titan Marines"
usr.overlays += /obj/overlays/Titan
usr.loc = locate(/turf/Titan)
else
usr.Team = "Titan Marines"
usr.overlays += /obj/overlays/Titan
usr.loc = locate(/turf/Titan)
if("Collective")
if(usr.Team == "Titan Marines")
usr.overlays -= /obj/overlays/Titan
usr.Team = "Collective Militia"
usr.overlays += /obj/overlays/Collective
usr.loc = locate(/turf/Coll)
else
usr.Team = "Collective Militia"
usr.overlays += /obj/overlays/Collective
usr.loc = locate(/turf/Coll)


The "Team" verb is defined at mob/verb, but it's above a different verb.
Maybe it has something to do with the fact that the team is "Titan Marines", not "Titan".

Also, you should store the teams in a list, not as a text string. That way you don't have to loop through all mobs in the world to do something to a single team.
In response to Garthor
Garthor wrote:
That way you don't have to loop through all mobs in the world to do something to a single team.

Is that a bad thing?
In response to Drafonis
I didn't want to make a new topic, but I have a new error.

mob
verb
CreateSquad(msg as text)
usr.Squad = "[msg]"
InviteUser(M as mob)
alert(M,"[usr] has invited to join [usr.Squad]. Do you accept?",,"Accept","Deny"))
if("Accept")
M.Squad = "[usr.Squad]"
if("Deny")
usr << "[M] denies!"


The error is:

loading Inf.dme
clans.dm:6:error: ): expected }
clans.dm:6:error: location of top-most unmatched {

Inf.dmb - 2 errors, 0 warnings (double-click on an error to jump to it)
In response to Drafonis
You need "switch(" before that alert().

Also, looping through all the mobs in the world is bad, especially if you have a lot of players.