ID:157778
 
My code at the moment:
    world
mob=/mob/NPC
mob
NPC
icon = 'brick.dmi'
icon_state = "Bob"
Login()
switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
if("dwarf")
src<<"You Have chosen, Dwarf!"
src.loc=locate(1,2,2)
if("elf")
src<<"You Have Chosen elf!"
src.loc=locate(1,1,3)

Say, the person chose Dwarf, how would I make what comes after different than if the person had chosen elf?

Thanks in advance. :)


Blafblabla wrote:
My code at the moment:
>     world
> mob=/mob/NPC
> mob
> NPC
> icon = 'brick.dmi'
> icon_state = "Bob"
> Login()
> switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
> if("dwarf")
> src<<"You Have chosen, Dwarf!"
> src.loc=locate(1,2,2)
> if("elf")
> src<<"You Have Chosen elf!"
> src.loc=locate(1,1,3)
>

Say, the person chose Dwarf, how would I make what comes after different than if the person had chosen elf?

Thanks in advance. :)


Well first thing first
                 if("dwarf")// the d in dwarf should be capital since in the input area its capitals ands well.

simple error
In response to Fierynathan
:D was a pretty simple error.

another thing, how to put a pop-up after one pop-up? I have two at login() but only one comes up :P. Can anyone help?
world
mob=/mob/NPC
mob
NPC
icon = 'brick.dmi'
icon_state = "Bob"
Login()
switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
if("Dwarf")
src<<"You Have chosen, Dwarf!"
src.loc=locate(1,2,2)
if("elf")
src<<"You Have Chosen elf!"
src.loc=locate(1,1,3)


world
mob=/mob/NPC
mob
NPC
icon = 'brick.dmi'
icon_state = "Bob"
Login()
switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
if("Mage")
src<<"You Have chosen,Mage!"
src.loc=locate(1,2,2)
if("Warrior")
src<<"You Have Chosen Warrior!"
src.loc=locate(1,1,3)

It's the second one that comes up. Hmm, was working a second ago but now this error appeared:
26:error: inconsistent indentation
line 26 is the second pop-up, icon = 'brick.dmi'
In response to Blafblabla
Blafblabla wrote:
:D was a pretty simple error.

another thing, how to put a pop-up after one pop-up? I have two at login() but only one comes up :P. Can anyone help?
> world
> mob=/mob/NPC
> mob
> NPC
> icon = 'brick.dmi'
> icon_state = "Bob"
> Login()
> switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
> if("Dwarf")
> src<<"You Have chosen, Dwarf!"
> src.loc=locate(1,2,2)
> if("elf")
> src<<"You Have Chosen elf!"
> src.loc=locate(1,1,3)
>
>
> world
> mob=/mob/NPC
> mob
> NPC
> icon = 'brick.dmi'
> icon_state = "Bob"
> Login()
> switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
> if("Mage")
> src<<"You Have chosen,Mage!"
> src.loc=locate(1,2,2)
> if("Warrior")
> src<<"You Have Chosen Warrior!"
> src.loc=locate(1,1,3)
>
>

It's the second one that comes up. Hmm, was working a second ago but now this error appeared:
26:error: inconsistent indentation
line 26 is the second pop-up, icon = 'brick.dmi'




only 1 should appear since you can on do one thing at login in an idea( not sure if this works haven't tested.

> world
> mob=/mob/NPC
> mob
> NPC
> icon = 'brick.dmi'
> icon_state = "Bob"
> Login()
> switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
> if("Dwarf")
> src<<"You Have chosen, Dwarf!"
> src.loc=locate(1,2,2)
> if("elf")
> src<<"You Have Chosen elf!"
> src.loc=locate(1,1,3)
switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
> if("Mage")
> src<<"You Have chosen,Mage!"
> src.loc=locate(1,2,2)
> if("Warrior")
> src<<"You Have Chosen Warrior!"
> src.loc=locate(1,1,3)
>
>


p.s u may want to remove the src.loc since your player is going to tele to two places
In response to Fierynathan
Fierynathan wrote:
Blafblabla wrote:
:D was a pretty simple error.

another thing, how to put a pop-up after one pop-up? I have two at login() but only one comes up :P. Can anyone help?
> > world
> > mob=/mob/NPC
> > mob
> > NPC
> > icon = 'brick.dmi'
> > icon_state = "Bob"
> > Login()
> > switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
> > if("Dwarf")
> > src<<"You Have chosen, Dwarf!"
> > src.loc=locate(1,2,2)
> > if("elf")
> > src<<"You Have Chosen elf!"
> > src.loc=locate(1,1,3)
> >
> >
> > world
> > mob=/mob/NPC
> > mob
> > NPC
> > icon = 'brick.dmi'
> > icon_state = "Bob"
> > Login()
> > switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
> > if("Mage")
> > src<<"You Have chosen,Mage!"
> > src.loc=locate(1,2,2)
> > if("Warrior")
> > src<<"You Have Chosen Warrior!"
> > src.loc=locate(1,1,3)
> >
> >

It's the second one that comes up. Hmm, was working a second ago but now this error appeared:
26:error: inconsistent indentation
line 26 is the second pop-up, icon = 'brick.dmi'




only 1 should appear since you can on do one thing at login in an idea( not sure if this works haven't tested.

> > world
> > mob=/mob/NPC
> > mob
> > NPC
> > icon = 'brick.dmi'
> > icon_state = "Bob"
> > Login()
> > switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
> > if("Dwarf")
> > src<<"You Have chosen, Dwarf!"
> > src.loc=locate(1,2,2)
> > if("elf")
> > src<<"You Have Chosen elf!"
> > src.loc=locate(1,1,3)
> switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
> > if("Mage")
> > src<<"You Have chosen,Mage!"
> > src.loc=locate(1,2,2)
> > if("Warrior")
> > src<<"You Have Chosen Warrior!"
> > src.loc=locate(1,1,3)
> >
> >

p.s u may want to remove the src.loc since your player is going to tele to two places

hmm, I tried that, but just gave me 9 errors :P
all the same:
inconsistent indentation


my code is now like this:
world
mob=/mob/NPC
mob
NPC
icon = 'brick.dmi'
icon_state = "Bob"
Login()
switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
if("Dwarf")
src<<"You Have chosen, Dwarf!"

if("elf")
src<<"You Have Chosen elf!"

switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
if("Mage")
src<<"You Have chosen,Mage!"

if("Warrior")
src<<"You Have Chosen Warrior!"

In response to Blafblabla
so does it work or error? if error im not sure lol
In response to Fierynathan
is error :P
I tried removing the .loc =locate, but it didn't work. :(
In response to Blafblabla
Only one is getting executed because the second Login() replaces the first one. In order to execute the overridden one, you need to call the ..() proc. However, you're really much better off simply merging them into one proc.

The indentation suggested by Fierynathan for this was incorrect: the second switch() statement should be even with the first.

As for your question about how to do different things depending on your selection, you'd need to just put more things inside each if() statement. However, that only works for rather simple things (like telling you "You are a Dwarf" or "You are a Human"). If, for example, you want to change the potential selection for classes on selecting your class, WITHOUT having to write in a different switch() statement for each selection, you'll need to do something like this:

var/list/possible_classes
switch(input("race") in list("Dwarf", "Human"))
if("Dwarf")
loc = blah
possible_classes = list("Cleric", "Warrior")
if("Human")
loc = bleh
possible_classes = list("Mage", "Cleric", "Warrior")
switch(input("class") in possible_classes)
if("Mage")
//...
if("Cleric")
//...
if("Warrior")
//...
In response to Blafblabla
world
mob=/mob/NPC
mob
var/race
var/class
NPC
icon = 'brick.dmi'
icon_state = "Bob"

Login()
src.race=input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
if("Dwarf")
src<<"You Have chosen, Dwarf!"
src.loc=locate(location)
src.class=input("What class would you like to be?","Choose a Class") in list ("Warrior","Mage")
if("Warrior")
...
if("Mage")
...//place in here stats that define this class.
if("elf")
src<<"You Have Chosen elf!"
src.loc=locate(location)
src.class=input("What class would you like to be?","Choose a Class") in list ("Warrior","Mage")
if(...)//do the same as above.
In response to Gamekrazzy
You screwed up the syntax horribly there, as well as advocating a design that is atrocious (if you had to choose a race, class, and diety, and each one only had, say, four options... there would be 84 separate if() statements, and whichever diety you choose help you if you choose to try to change anything in that mess).
In response to Garthor
Garthor wrote:
You screwed up the syntax horribly there, as well as advocating a design that is atrocious (if you had to choose a race, class, and diety, and each one only had, say, four options... there would be 84 separate if() statements, and whichever diety you choose help you if you choose to try to change anything in that mess).

Honestly, I was thinking way too fast. I had to go to work and only had several minutes to write it. Anyways the design there is good, it's just simple inconsistant indentation.
world
mob=/mob/NPC
mob
NPC
icon = 'brick.dmi'
icon_state = "Bob"
Login()
switch(input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))//XD, here is where your problem is you need to indent here.
if("Dwarf")
src<<"You Have chosen, Dwarf!"

if("elf")
src<<"You Have Chosen elf!"

switch(input("What class would you like to be?","Choose a Class") in list ("Mage","Warrior"))
if("Mage")
src<<"You Have chosen,Mage!"

if("Warrior")
src<<"You Have Chosen Warrior!"

In response to Gamekrazzy
Thanks, but still errors. :P
In response to Blafblabla
ok, what are the errors this time?
In response to Gamekrazzy
Here are the errors+ the code:
mob
var/race
var/class
NPC
icon = 'brick.dmi'
icon_state = "Bob"

Login()
{Line 221
src.race=input("What race would you like to be?","Choose a Race") in list ("Dwarf","elf"))
}
if("Dwarf")
src<<"You Have chosen, Dwarf!"
src.loc=locate(location)
src.class=input("What class would you like to be?","Choose a Class") in list ("Warrior","Mage")
if("Warrior")
...
if("Mage")
...//place in here stats that define this class.
if("elf")
src<<"You Have Chosen elf!"
src.loc=locate(location)
src.class=input("What class would you like to be?","Choose a Class") in list ("Warrior","Mage")
if(...)//do the same as above.




Foojian.dm:221:error: ): expected }
Foojian.dm:221:error: location of top-most unmatched {
In response to Blafblabla
on line 221, you have 1 too many parentheses at the end.
In response to Garthor
Garthor wrote:
Only one is getting executed because the second Login() replaces the first one. In order to execute the overridden one, you need to call the ..() proc. However, you're really much better off simply merging them into one proc.

The indentation suggested by Fierynathan for this was incorrect: the second switch() statement should be even with the first.

As for your question about how to do different things depending on your selection, you'd need to just put more things inside each if() statement. However, that only works for rather simple things (like telling you "You are a Dwarf" or "You are a Human"). If, for example, you want to change the potential selection for classes on selecting your class, WITHOUT having to write in a different switch() statement for each selection, you'll need to do something like this:

var/list/possible_classes
> switch(input("race") in list("Dwarf", "Human"))
> if("Dwarf")
> loc = blah
> possible_classes = list("Cleric", "Warrior")
> if("Human")
> loc = bleh
> possible_classes = list("Mage", "Cleric", "Warrior")
> switch(input("class") in possible_classes)
> if("Mage")
> //...
> if("Cleric")
> //...
> if("Warrior")
> //...



You want find something better then this, so use it already