ID:141214
 
I have a problem:

obj
PC
verb
Deposit()
set src in oview(1)
for(var/mob/P in usr.contents2)
if(usr.PokemonOnHand <= 1)
alert("You must have atleast 1 Pokemon in your party at all times.")
else
usr.contents2 -= P
usr.contents4 += P
P.loc=null
usr << "[P] was deposited."
usr.PokemonOnHand -= 1
Withdraw()
set src in oview(1)
for(var/mob/P in usr.contents4)
if(usr.PokemonOnHand >= 6)
alert("You may not have more than 6 Pokemon on hand at a time.")
else
usr.contents4 -= P
usr.contents2 += P
P.loc=null
usr << "[P] was withdrawn."
usr.PokemonOnHand += 1



obj/Pokeball
icon='pokeball.dmi'
icon_state="Pokeball"
verb
PickUp()
set src in oview(1)
if(usr.pokeballs>=1)
usr.pokeballs += 1
src.loc = usr
var/obj/Pokeball/P = locate(/obj/Pokeball) in usr.contents3
P.name = "Pokeballs x[usr.pokeballs]"
else
usr.pokeballs += 1
src.loc = usr
var/obj/Pokeball/P = new(usr)
usr.contents3.Add(P)
P.name = "Pokeballs x[usr.pokeballs]"
Drop()
if(usr.pokeballs==0)
usr<<"You have no Pokeballs to drop"
else
if(usr.pokeballs>1)
usr.pokeballs -= 1
src.loc=usr.loc
var/obj/Pokeball/P = locate(/obj/Pokeball) in usr.contents3
P.name = "Pokeballs x[usr.pokeballs]"
else
usr.pokeballs -= 1
src.loc=usr.loc
var/obj/Pokeball/P = locate(/obj/Pokeball) in usr.contents3
usr.contents3 -= P
P.name = "Pokeball"
Catch(var/mob/M as mob in oview(1)) //The catch verb.
set category="Pokemon Commands"
if(usr.pokemonout>=1)
usr<<"You cant catch a pokemon until you return your current one"
else
if(istype(M,/mob/Pokemon))
if(usr.pokeballs<=0)
usr<<"You have no Pokeballs"
else
if(prob(25))
M.MHP=100
M.HP=100
M.owner="[usr.key]"
M.loc = null
M.name = input("[M]","Name") as text|null
if(length(M.name)<1)
M.name = "[M.Species]"
usr << "You have successfully named it [M.name]!"
if(usr.PokemonOnHand>=6)
usr.contents4 += M
usr<<"[M.name] was transfered to your PC"
else
usr.contents2 += M
usr.PokemonOnHand +=1
else
usr<<"The Pokemon broke out of the ball"
usr.pokeballs -= 1
if(usr.pokeballs>=1)
var/obj/Pokeball/P = locate(/obj/Pokeball) in usr.contents3
P.name = "Pokeballs x[usr.pokeballs]"
else
var/obj/Pokeball/P = locate(/obj/Pokeball) in usr.contents3
usr.contents3 -= P
else
usr << "You can't catch [M]!"


As you can see, when I catch it adds PokemonOnHand.. But no matter how many pokemon I have; when it deposits it says "You must have more than one pokemon in your party" and it gives me 1 message for each pokemon I have in my party.
Xyphon101 wrote:
As you can see, when I catch it adds PokemonOnHand.. But no matter how many pokemon I have; when it deposits it says "You must have more than one pokemon in your party" and it gives me 1 message for each pokemon I have in my party.

Your for() loop is looping through all of your different pokemon. As for the issue with it saying "You must have at least 1..." I'd guess your variable is becoming inconsistent for whatever reason.
In response to AJX
Well then.. How can I fix this?
In response to Xyphon101
           Deposit(P as mob in usr.contents2)
set src in oview(1)
if(usr.PokemonOnHand <= 1)
alert("You must have atleast 1 Pokemon in your party at all times.")
else
usr.contents2 -= P
usr.contents4 += P
P.loc=null
usr << "[P] was deposited."
usr.PokemonOnHand -= 1

Something like that should accomplish what you want.
In response to AJX
I get the exact same problem >.<
In response to Xyphon101
Xyphon101 wrote:
I get the exact same problem >.<

You're saying that it is still giving you the multiple error messages (1 for each pokemon) after changing that code?

Can you copy/paste your new deposit code please? There must be a mistake.
In response to AJX
obj
PC
verb
Deposit(P as mob in usr.contents2)
set src in oview(1)
if(usr.PokemonOnHand <= 1)
alert("You must have atleast 1 Pokemon in your party at all times.")
else
usr.contents2 -= P
usr.contents4 += P
P:loc=null
usr << "[P] was deposited."
usr.PokemonOnHand -= 1
In response to Xyphon101
Xyphon101 wrote:
obj
> PC
> verb
> Deposit(P as mob in usr.contents2)
> set src in oview(1)
> if(usr.PokemonOnHand <= 1)
> alert("You must have atleast 1 Pokemon in your party at all times.")
> else
> usr.contents2 -= P
> usr.contents4 += P
> P:loc=null
> usr << "[P] was deposited."
> usr.PokemonOnHand -= 1


TBH I have no idea. You'll have to wait for someone else to answer. I never use verbs, I hate em. Prefer interfaces/huds.
In response to Xyphon101
That can't possibly be giving you one error message per pokemon in your party.

Any particular reason you can't just check usr.contents2.len to determine how many pokemon they have on hand?
In response to Jp
Well, to tell you the truth.. I don't know the function.
In response to Xyphon101
F1 is your friend. It checks to see how many items or whatever are in a list.

As for your problem, you might be adding Pokemon in some other way than Catching them? And if not, upon catching them, do you see the message "blabla was transferred to your PC" ?
In response to Mysame
Thanks for your help guys, but I figured it out on my own.