This is hard to explain but ill try my best.In my code im trying to look for Pets in the users contents.The problem im having is if i use var/mob/Pets/T = locate() in usr.contents then it will Stop when it finds the First Pet in his inventory but if i use for(var/mob/Pets/T in usr) it will Give me too many Messages/Popups.For example
for(var/mob/Pets/T in usr)
if(T)
if(usr.Pet)
usr << "[BadMessage]You already have a pet Out"
else
var/K = input("Which slot do you want to Revive?","[usr.Pet]")in list("Slot One","Slot Two","Slot Three","Slot Four","Cancel")
switch(K)
if("Slot
That Code Will give me the usr << "[BadMessage]You already have a pet Out" msg 3 times if it finds 3 pets in my inventory and i have a pet out and if i dont have a pet out and it finds 5 Pets in my inventory it will give me the K input 5 times.(By the way the #'s are just examples).This code has been giving me trouble for like 2 weeks now and everytime i think about this problem i cant think straight for some reason.so ill just post it, If you have any questions please ask.This is my Code right now.
mob/var
PetSlot
PetSlot1 = 0
PetSlot2 = 0
PetSlot3 = 0
PetSlot4 = 0
mob
NPC
PetStorage
icon = 'NPC.dmi'
icon_state = "PetStorage"
Click()
if(src in oview(1))
if(usr.action)
return
else
usr.action = 1
if(usr.move == 0)
usr.action=0
return
else
usr.move = 0
var/R = input("What do you want to do","[src]")in list("Freeze","Revive","Cancel")
switch(R)
if("Freeze")
if(usr.Pet)
var/K = input("Which slot do you want to freeze him in?","[usr.Pet]")in list("Slot One","Slot Two","Slot Three","Slot Four","Cancel")
switch(K)
if("Slot One")
if(usr.PetSlot1 == 0)
usr << "[NormalMessage]You Freeze [usr.Pet] In [K]"
usr.Pet.Move(usr)
usr.Pet.PetSlot = 1
usr.PetSlot1 = 1
usr.Pet = null
usr.verbs-=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You already have a Pet in Slot1"
if("Slot Two")
if(usr.PetSlot2 == 0)
usr << "[NormalMessage]You Freeze [usr.Pet] In [K]"
usr.Pet.Move(usr)
usr.Pet.PetSlot = 2
usr.PetSlot2 = 1
usr.Pet = null
usr.verbs-=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You already have a Pet in Slot2"
if("Slot Three")
if(usr.PetSlot3 == 0)
usr << "[NormalMessage]You Freeze [usr.Pet] In [K]"
usr.Pet.Move(usr)
usr.Pet.PetSlot = 3
usr.PetSlot3 = 1
usr.Pet = null
usr.verbs-=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You already have a Pet in Slot3"
if("Slot Four")
if(usr.PetSlot4 == 0)
usr << "[NormalMessage]You Freeze [usr.Pet] In [K]"
usr.Pet.Move(usr)
usr.Pet.PetSlot = 4
usr.PetSlot4 = 1
usr.Pet = null
usr.verbs-=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You already have a Pet in Slot4"
if("Cancel")
usr.move=1
usr.action=0
return
else
usr << "[BadMessage]You dont have a pet to freeze"
usr.move=1
usr.action=0
if("Revive")
for(var/mob/Pets/T in usr)
if(T)
if(usr.Pet)
usr << "[BadMessage]You already have a pet Out"
else
var/K = input("Which slot do you want to Revive?","[usr.Pet]")in list("Slot One","Slot Two","Slot Three","Slot Four","Cancel")
switch(K)
if("Slot One")
if(T.PetSlot == 1)
usr.PetSlot1 = 0
usr.Pet = T
usr.Pet.Move(usr.loc)
usr.Pet.loc = locate(usr.loc)
usr << "[GoodMessage]You revive [usr.Pet]."
usr.verbs+=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You have no pet in Slot One"
if("Slot Two")
if(T.PetSlot == 2)
usr.PetSlot2 = 0
usr.Pet = T
usr.Pet.Move(usr.loc)
usr.Pet.loc = locate(usr.loc)
usr << "[GoodMessage]You revive [usr.Pet]."
usr.verbs+=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You have no pet in Slot Two"
if("Slot Three")
if(T.PetSlot == 3)
usr.PetSlot3 = 0
usr.Pet = T
usr.Pet.Move(usr.loc)
usr.Pet.loc = locate(usr.loc)
usr << "[GoodMessage]You revive [usr.Pet]."
usr.verbs+=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You have no pet in Slot Three"
if("Slot Four")
if(T.PetSlot == 4)
usr.PetSlot4 = 0
usr.Pet = T
usr.Pet.Move(usr.loc)
usr.Pet.loc = locate(usr.loc)
usr << "[GoodMessage]You revive [usr.Pet]."
usr.verbs+=typesof(/mob/PetCommands/verb)
else
usr << "[BadMessage]You have no pet in Slot Four"
if("Cancel")
usr.move=1
usr.action=0
return
else
usr << "[BadMessage]You have no Pets to Revive"
usr.move=1
usr.action=0
return
if("Cancel")
usr.move=1
usr.action=0
return