ID:167270
 
I have a big ol' list of songs for my game but how do i make it so there is an actual list so when I select a certain song it plays it
well you could do it in a input like so:
mob/verb/Play()
switch(input("What song do you wish to play?","Song?") in list("Pokemon song","DBZ intro","cancel")
if("Pokemon song")
world<<sound('ps.wav')
if("DBZ intro")
world<<sound('DBZ.wav)
In response to National Guardsmen
oh thx but instead of if what if you put else if or would that not work
In response to Mxjerrett
there is no use for else in that.
In response to National Guardsmen
whats wrong with this

            Play()
switch(input("What song do you wish to play?","Song?") in list("Track1","Track2","Track3","Track4","Track5","Track6","Track9","Track10","Track11","cancel")
if("Track1")
world<<sound('track11.wma')
if("Track2")
world<<sound('track2.wma')
if("Track3")
world<<sound('track3.wma')
if("Track4")
world<<sound('track4.wma')
if("Track5")
world<<sound('track5.wma')
if("Track6")
world<<sound('track6.wma')
if("Track9")
world<<sound('track9.wma')
if("Track10")
world<<sound('track10.wma')
if("Track11")
world<<sound('track11.wma')
if("cancel")
return
In response to Mxjerrett
Mxjerrett wrote:
whats wrong with this

>           Play()
> switch(input("What song do you wish to play?","Song?") in list("Track1","Track2","Track3","Track4","Track5","Track6","Track9","Track10","Track11","cancel")
> if("Track1")
> world<<sound('track11.wma')
> if("Track2")
> world<<sound('track2.wma')
> if("Track3")
> world<<sound('track3.wma')
> if("Track4")
> world<<sound('track4.wma')
> if("Track5")
> world<<sound('track5.wma')
> if("Track6")
> world<<sound('track6.wma')
> if("Track9")
> world<<sound('track9.wma')
> if("Track10")
> world<<sound('track10.wma')
> if("Track11")
> world<<sound('track11.wma')
> if("cancel")
> return
>
>


you need to indent the ifs 2 times to were its like so
mob/verb/Play()
switch(input("blah","blah") in list ("blah","blah2)
if("blah")
usr<<"blah"
if("blah2")
usr<<"blah2"

and there is no need to if cancel the switch takes care of it
by make it return when choose. if i am wrong some one plese correct me.
In response to National Guardsmen
i still get the same error
In response to Mxjerrett
post the errors plese kinda hard to fix with out them even so i told you what to fix in my post above.
In response to National Guardsmen
code files\admin.dm:79:error: if: missing comma ',' or right-paren ')'
In response to Mxjerrett
ahh i see what i forgot sorry,
mob/verb/Play()
switch(input("What song do you wish to play?","Song?")) in list("Pokemon song","DBZ intro","cancel")
if("Pokemon song")
world<<sound('ps.wav')
if("DBZ intro")
world<<sound('DBZ.wav)

note the extra ) i added to the input
In response to National Guardsmen
It'd be better to keep an associative list.
var/list/songs=list("Pokemon Song"='ps.wav',"DBZ Intro"='DBZ.wav')
mob/verb/Play()
var/x=input("What song do you wish to play?","Songs")as null|anything in songs
if(x) usr<<sound(songs[x])
In response to Artemio
hmm i never thought of doing it that way. and i didnt know you could use = inside of a list.
In response to National Guardsmen
um now it says code files\admin.dm:78:error: missing left-hand argument to in.