mob/verb

Send_Out()
set category = "Poke Commands"
var/wait=15
var/mob/P=input(usr,"Select a Pokemon to Send Out","Select") in usr.pokemonlist+"Nevermind"
if(P=="Nevermind")
return
if(usr.sendoutwait==1)
usr<<"<font color=red><u>You have to wait awhile to send out another Pokemon"
return
if(P.hp<=0)
alert("[P] is to weak to fight","")
return
if(P.returned==1)
if(P.orginal_icon=='Ditto.dmi')
P.icon=P.orginal_icon
P.overlays=null
P.overlays -= image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.overlays += image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.Type1="Normal"
P.Type2="None"
P.typematchup()

P.underlays=null
P.loc=locate(usr.x,usr.y,usr.z)
P.returned=0
src.PokeSentOut += P
if(usr.sendpurple==1)
flick("Sendpurple",P)
if(usr.sendblue==1)
flick("Sendblue",P)
if(usr.sendpink==1)
flick("Sendpink",P)
if(usr.sendgreen==1)
flick("Sendgreen",P)
if(usr.sendblue==0&&usr.sendgreen==0&&usr.sendpink==0&&usr.sendpurple==0)
flick("Send",P)
usr.pokemonsout++
P.inreturned=0
usr.controlled=P
usr.client:perspective = EYE_PERSPECTIVE
client.eye = P
view() << "[usr.sendingoutext], [P]!"
usr.sendoutwait++
sleep(wait)
usr.sendoutwait--
else
usr << "<font color = blue>[P] isnt in its pokeball!"


the verb does nothing :/. and thank you again for taking your time for helping me.
I'm not sure about this because but..

Should this line:
var/mob/P=input(usr,"Select a Pokemon to Send Out","Select") in usr.pokemonlist+"Nevermind"

Be
var/mob/P=switch(input(src,"Select a Pokemon to Send Out","Select") in list(usr.pokemonlist, "Nevermind"))


All I did was add the switch statement and put the pokemonlist and "nevermind" in a list (which your original code still did but I like to see it that way for some reason)

Also I changed the usr to src, because you shouldn't call usr there. In fact, in all of that code change usr to src.
says switch undefined proc


mob/verb

Send_Out()
set category = "Poke Commands"
var/wait=15
var/mob/P=switch(input(src,"Select a Pokemon to Send Out","Select") in list(usr.pokemonlist, "Nevermind"))
if(P=="Nevermind")
return
if(usr.sendoutwait==1)
usr<<"<font color=red><u>You have to wait awhile to send out another Pokemon"
return
if(P.hp<=0)
alert("[P] is to weak to fight","")
return
if(P.returned==1)
if(P.orginal_icon=='Ditto.dmi')
P.icon=P.orginal_icon
P.overlays=null
P.overlays -= image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.overlays += image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.Type1="Normal"
P.Type2="None"
P.typematchup()

P.underlays=null
P.loc=locate(usr.x,usr.y,usr.z)
P.returned=0
src.PokeSentOut += P
if(usr.sendpurple==1)
flick("Sendpurple",P)
if(usr.sendblue==1)
flick("Sendblue",P)
if(usr.sendpink==1)
flick("Sendpink",P)
if(usr.sendgreen==1)
flick("Sendgreen",P)
if(usr.sendblue==0&&usr.sendgreen==0&&usr.sendpink==0&&usr.sendpurple==0)
flick("Send",P)
usr.pokemonsout++
P.inreturned=0
usr.controlled=P
usr.client:perspective = EYE_PERSPECTIVE
client.eye = P
view() << "[usr.sendingoutext], [P]!"
usr.sendoutwait++
sleep(wait)
usr.sendoutwait--
else
usr << "<font color = blue>[P] isnt in its pokeball!"
That's odd..

I could be missing something but when I get home in like 6 hours I'll test it out.
You're using switch() wrong, that's why. Nailez previous post was just wrong.

switch(input("..."))
if(value)
// ...
if(value2)
// ...


Is the correct way of using a switch() statement.
In response to Nailez
It seems like a common misconception going around BYOND rips that switch() has something to do with popup boxes.
I see...

I wasn't sure about it from the start. I knew the switch syntax that Nadrew posted and always thought it was like that but if you look earlier in the thread he's code has a switch(input that makes a popup box. I thought it would be the same here.

Thanks for clearing that up for me!
In response to Nailez
still undefined switch proc. and i rather have you explain it to me because i like the way you explain things.
In response to Louisthe10
First off, I'd change all usr to src in this verb. Although it's a verb and is usr-safe, because it's a mob verb src==usr by default, so you may as well stick with src. That way, you can also avoid stuff like usr.varX, since varX is good enough.

Going over the problem bits:

        var/mob/P=switch(input(src,"Select a Pokemon to Send Out","Select") in list(usr.pokemonlist, "Nevermind"))

This is the wrong way to put a cancellation choice in an input(). What you want is "as null | anything in list", and then the result is null if you canceled. The way you've setup this input(), there is no proper cancel choice, and you're giving it only two items to choose from: a list, and "Nevermind".

This is also not a valid switch() setup, which is why you're getting the error. The correct format is:

        // corrected
var/mob/P = input(src, "Select a Pokemon to Send Out", "Select") as null|anything in pokemonlist

Now onward.

        if(P=="Nevermind")
return

With the revised code, that'd be:

        // corrected
if(!P) return

Moving on.

        if(usr.sendoutwait==1)

This is the wrong way to check a true/false value. If a value is only ever true or false, then you use if(var) to check for truth, and if(!var) to check if it's false. That's it. That's because if your var ever changed to anything other than 0 or 1, the ==1 or ==0 check you're doing will always fail. You're doing this in lots of places.

        if(P.hp<=0)
alert("[P] is to weak to fight","")
return

This is just bad UI. Never use alert() where simple output will do. Or better still, before the above switch() you should make a temporary list that only includes the choices that are valid.

Even better yet, this whole setup would benefit from an interface box or HUD overlay where you could see a list of available creatures and choose from them, or back out. That'd make the game more gamepad- and tablet-friendly and give it a nicer look.

Also, you meant "too".

        if(P.returned==1)
if(P.orginal_icon=='Ditto.dmi')
...

Aside from the ==1 issue, this is running code specific to the type of creature. There's no reason to do that here. Instead, give each creature a proc like OnSendOut() and maybe one called OnReturn() that does all the housekeeping you need, and call the appropriate proc here.

            P.loc=locate(usr.x,usr.y,usr.z)

Why bother with locate() here? Unless there's any chance you're not standing on a turf, P.loc = loc will do just fine.

            if(usr.sendpurple==1)
flick("Sendpurple",P)
if(usr.sendblue==1)
flick("Sendblue",P)
if(usr.sendpink==1)
flick("Sendpink",P)
if(usr.sendgreen==1)
flick("Sendgreen",P)
if(usr.sendblue==0&&usr.sendgreen==0&&usr.sendpink==0&&usr.sendpurple==0)
flick("Send",P)

This is no bueno. Why not just have a simple sendcolor var, instead of four different vars that are all doing the same thing? Obviously you don't intend for more than one of them to be true at a time, so this is clearly a case where you should have just one var with a value that says which of them you want.

            // corrected
flick("Send[sendcolor]", P)

Onward.

            usr.pokemonsout++

This var is redundant. You already have a list of who you sent out; the length of that list should always be equal to this var. Ditch this var.

            usr.client:perspective = EYE_PERSPECTIVE
client.eye = P

Safety check: You can't be sure client is still valid at this point, because of the fact that you had to wait for input(). Make sure you put in a sanity check to see if client is not null, before trying to change these values. You can also do that sanity check directly after the switch(), like if(!client) return.

            view() << "[usr.sendingoutext], [P]!"
usr.sendoutwait++
sleep(wait)
usr.sendoutwait--

This code isn't broken, but I wanted to point out this is why you shouldn't use the ==1 and ==0 checks on true/false values, like I said above. Let's say somehow you had a situation where sending out a second creature could happen. Then the sendoutwait==1 check above would fail, because the value would be 2, allowing you to send out an infinite number at that point.

            usr << "<font color = blue>[P] isnt in its pokeball!"

Bad HTML form: Never put spaces around the = in an attribute.

You're also missing an apostrophe in "isn't"; on the bright side, "its" is correct, and everyone gets that wrong.
still undefined switch proc error.


p.s. thank you byond community for being so friendly.
For some reason I missed the switch() thing when I was going over the rest. I've edited my previous answer.

Here's the problem: switch() is an execution flow statement, like if() or for() or while(). You can't use it in an assignment.

// wrong
var/thing = switch(...)

// right
switch(thing)
if(...)
...
...

The logic in your verb is such that switch() isn't needed there.
mob/verb

Send_Out()
set category = "Poke Commands"
var/wait=15
var/mob/P = switch(input(src, "Select a Pokemon to Send Out", "Select") as null|anything in pokemonlist)
if(!P) return
if(src.sendoutwait)
src<<"<font color=red><u>You have to wait awhile to send out another Pokemon"
return
if(P.hp<=0)
alert("[P] is to weak to fight","")
return
if(P.returned==1)
if(P.orginal_icon=='Ditto.dmi')
P.icon=P.orginal_icon
P.overlays=null
P.overlays -= image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.overlays += image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.Type1="Normal"
P.Type2="None"
P.typematchup()

P.underlays=null
P.loc=locate(usr.x,usr.y,usr.z)
P.returned=0
src.PokeSentOut += P
if(src.sendpurple==1)
flick("Sendpurple",P)
if(src.sendblue==1)
flick("Sendblue",P)
if(src.sendpink==1)
flick("Sendpink",P)
if(src.sendgreen==1)
flick("Sendgreen",P)
if(src.sendblue==0&&usr.sendgreen==0&&usr.sendpink==0&&usr.sendpurple==0)
flick("Send",P)
src.pokemonsout++
P.inreturned=0
src.controlled=P
src.client:perspective = EYE_PERSPECTIVE
client.eye = P
view() << "[usr.sendingoutext], [P]!"
src.sendoutwait++
sleep(wait)
src.sendoutwait--
else
src << "<font color=blue>[P] isn't in its pokeball!"

im going to do what you said in the earlier posts later when i have more time. please excuse me im a rookie.
I edited my last post (and the one before it) so you'll want to take another look. The problem is that switch() doesn't really even belong in this verb.
sorry im being a pia but the input doesn't show up.i kept getting switch proc error so i tried this
mob/verb

Send_Out()
set category = "Poke Commands"
var/wait=15
var/mob/P = input(src, "Select a Pokemon to Send Out", "Select") as null|anything in pokemonlist
if(!P) return
if(src.sendoutwait)
src<<"<font color=red><u>You have to wait awhile to send out another Pokemon"
return
if(P.hp<=0)
src<<"[P] is to weak to fight"
return
if(P.returned==1)
if(P.orginal_icon=='Ditto.dmi')
P.icon=P.orginal_icon
P.overlays=null
P.overlays -= image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.overlays += image('Meter.dmi',icon_state = "owned",pixel_y=6)
P.UpdateMeters()
P.Type1="Normal"
P.Type2="None"
P.typematchup()

P.underlays=null
P.loc=locate(usr.x,usr.y,usr.z)
P.returned=0
src.PokeSentOut += P
if(src.sendpurple==1)
flick("Sendpurple",P)
if(src.sendblue==1)
flick("Sendblue",P)
if(src.sendpink==1)
flick("Sendpink",P)
if(src.sendgreen==1)
flick("Sendgreen",P)
if(src.sendblue==0&&usr.sendgreen==0&&usr.sendpink==0&&usr.sendpurple==0)
flick("Send",P)
src.pokemonsout++
P.inreturned=0
src.controlled=P
src.client:perspective = EYE_PERSPECTIVE
client.eye = P
view() << "[usr.sendingoutext], [P]!"
src.sendoutwait++
sleep(wait)
src.sendoutwait--
else
src << "<font color=blue>[P] isn't in its pokeball!"

and the list doesn't appear, and sorry Im being such a pain. so I'm still confused.
Does pokemonlist contain any actual items? If it's empty, then the input() will short-circuit to null.
they have verbs but no items.
So I have tried the above code, the only thing that doesn't let it show up is if the pokemonlist is empty.
doesnt work for me :/. and i had one pokemon in my inventory.
Is this the code you use to add the pokemon to the list?
mob
proc
SelectStarter(var/mob/SelectedPokemon)
src.pokemonlist.Add(SelectedPokemon)
src.PkmInInven ++

If so are you calling that proc correctly after they select their starter?
src.SelectStarter(Pokemon)

Where the Pokemon is the reference to the pokemon you selected.
oh i was using just src.SelectStarter()
Page: 1 2 3