Code:
mob
Login()
src.home_village = input ("Which village are you from?") in list ("Avilla","Bvilla")
if("Avilla")
usr << "Those from Avilla are born with increased strength."
usr.Str += 5
else if("Bvilla")
usr << "Those from Bvilla are born with increased defence."
usr.Def += 5
var
home_village = " "
Str = 10
Def = 10
Problem description:
I have this problem when making a player choose his village for my demo game.
when i compile there aren't any errors but when i run and try to exucute this for a player from bvilla it gives them the avilla option.
how can i fix this should i try a different way to enter the lines which says:src.home_village = input ("Which village are you from?") in list ("Avilla","Bvilla")
or make vars for the villages?
ID:1923986
Aug 24 2015, 10:56 am (Edited on Aug 24 2015, 11:04 am)
(See the best response by Ter13.)
|
|
Aug 24 2015, 11:05 am
|
|
don't mind the indentation
|
Also, the problem is that your if statement doesn't have a left-hand label that is being checked against. if("somestring") is always true because "somestring" is not 0 or null. You can fix this two ways. One is to use a switch statement:
home_village = input ("Which village are you from?") in list ("Avilla","Bvilla") Or you can supply the left hand labels in an if/else chain. home_village = input ("Which village are you from?") in list("Avilla","Bvilla") IMO, the switch statement is the better solution. |