ID:1099637
 
(See the best response by FIREking.)
Code:
mob
Login()
icon = input("Make your own Avatar or Select?") in list ("Make","Select")
if (icon = "Select")
icon = input("What gender?") in list ('male.dmi','female.dmi')
usr.icon_state = input("Avatar?") in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki" )
if (icon = "Make")
icon = input("What gender?") in list ('male.dmi','female.dmi')


Problem description:
I'm trying to make selections for my Logging in screen. It's Supposted to first show if you wanna make a Character or Select premade ones, but the "if" coding doesn't work. I'm not sure if im using the "If" right. Heres what i got for my Login, if anyone can help fix this, much appreciated.

You gotta use the relational operator, not the assignment operator.

= : assignment
== : relational

= assigns values
var/X = 10 // X is assigned 10 
var/turf/T = src.loc


== tests for truth
if(X == 10) // True if X = 10
In response to Lugia319
I'm not sure if I understand still, this is now what it looks like, but Compiler keeps saying
error: inconsistent indentation
Code:
mob
Login()
icon = input("Make your own Avatar or Select an Avatar?") in list ("Make","Select")
if(icon == "Select")
icon = input("What gender?") in list ('male.dmi','female.dmi')
if(icon == 'male.dmi')
usr.icon_state = input("Avatar?") in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki" )
if(icon == 'female.dmi')
usr.icon_state = input("Avatar?") in list ("Emi Senduo","Misaki Tokera")
if(icon == "Make")
icon = input("What gender?") in list ('male.dmi','female.dmi')

usr.Move(locate(5,3,1))

Your indentation looks fine to me. If you've copy/pasted that code, that could create a problem.
In response to Lugia319
all typed, i just can't get it to work yet.
Which line is the error?
In response to Lugia319
The lines encoded in gray

Code:
mob
Login()
icon = input("Make your own Avatar or Select an Avatar?") in list ("Make","Select")
if(icon == "Select
/* icon = input("What gender?") in list ('male.dmi','female.dmi')
if(icon == 'male.dmi')
usr.icon_state = input("Avatar?") in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki" )
if(icon == 'female.dmi')
usr.icon_state = input("Avatar?") in list ("Emi Senduo","Misaki Tokera */

if(icon == "Make")
/* icon = input("What gender?") in list ('male.dmi','female.dmi'*/

usr.Move(locate(5,3,1))

You're missing a right paren after "Select"
In response to Lugia319
Sorry, Deleted it when making post, it's there on program and prior posts
I plugged it in an got no errors. Your code is fine. The indentation error must be elsewhere.
In response to Lugia319
Odd, Those were where the Compiler says the Errors are.
Inconsistent Indentation error means one of your lines is using spaces while another is using tabs. In DM, you must either only use spaces or only use tabs. You can not mix the two. You also have to indent under conditionals if the conditional has more than one line of code after it, unless you use brackets and semi colons.
In response to FIREking
Thanks the compiler don't show errors anymore, but now it won't follow the "if" Correctly, it goes to each select box i've made.

Code:
mob
Login()
icon = input("Make your own Avatar or Select an Avatar?") in list ("Select","Make")
if("Select")
icon = input("What gender?") in list ('male.dmi','female.dmi')
if('male.dmi')
usr.icon_state = input("Avatar?") in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki")
if('female.dmi')
usr.icon_state = input("Avatar?") in list ("Emi Senduo","Misaki Tokera")
if("Make")
icon = input("What gender?") in list ('male.dmi','female.dmi')

usr.Move(locate(5,3,1))


Result:
If i click Select or Make, it asks "Male or Female", then to character selections of males, and even if i select say Jaden Yuki, it goes to the Female selection then asks "Male or Female" from Make.


Code:
mob
Login()
icon = input("Make your own Avatar or Select an Avatar?") in list ("Select","Make")
if(icon == "Select")
icon = input("What gender?") in list ('male.dmi','female.dmi')
if(icon == 'male.dmi')
usr.icon_state = input("Avatar?") in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki")
if(icon == 'female.dmi')
usr.icon_state = input("Avatar?") in list ("Emi Senduo","Misaki Tokera")
if(icon == "Make")
icon = input("What gender?") in list ('male.dmi','female.dmi')

usr.Move(locate(5,3,1))


Result:
Click Make or Select, it skips the rest and goes to map with out Avatar.
You can't set icon directly to text, because DM will change it immediate to a null file, which isn't text. Since its not text, then icon != "Select" (it equals null).

Use an temp input variable.

var/my_selection = input("question") as null | anything in list("choices")
if(!my_selection) //user disconnected or didn't select anything
return
...
if(my_selection == "a choice")
//do stuff
In response to FIREking
That helped but it still won't show the Avatar.

Code:
mob
Login()
var/selection = input("Make your own Avatar or Select an Avatar?") as null | anything in list("Select","Make")
if(!selection) //user disconnected or didn't select anything
return
if(selection == "Select")
var/gender = input("What gender?") as null | anything in list ('male.dmi','female.dmi')
if(gender == 'male.dmi')
usr.icon_state = input("Avatar?") as null | anything in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki")
if(gender == 'female.dmi')
usr.icon_state = input("Avatar?") as null | anything in list ("Emi Senduo","Misaki Tokera")
/*if(selection == "Make")
var/gender = input("What gender?") in list ('male.dmi','female.dmi')
if(gender == 'male.dmi')

if(gender == 'female.dmi')*/


usr.Move(locate(5,3,1))

NOTE: the parts between /* */ are to be edited later when i make the editing pieces.
gender is a built in variable. I recommend using something else.
In response to Lugia319
ok, but the problem involves the Avatar not showing on the map.
Also, any clue on how to make this only work once when someone logs in for the first time?
In response to KidNeos2
Best response
KidNeos2 wrote:
ok, but the problem involves the Avatar not showing on the map.
Also, any clue on how to make this only work once when someone logs in for the first time?

The reason the avatar doesn't show on the map is because you're not setting the icon, ever. Also, you're weirdly setting the built in gender value to an icon file, which will do nothing.

When you set a built in value, DM will do whatever it can to ensure that value is what you expect it to be (gender will always be a number, because the macro MALE is a number). If I instruct DM to set gender = 'male.dmi', its going to immediately switch it to 0 because 'male.dmi' isn't a number.

Here's what you should do...

mob
Login()
var/selection = input(src, "Make or select?") as null | anything in list("Select", "Make")
if(!selection)
del(src) //user made no selection, forever in limbo so delete them
return
if(selection == "Select")
var/user_gender = input(src, "What gender?") as null | anything in list("male", "female")
if(!user_gender)
user_gender = "male" //force male cuz they wouldn't decide
if(user_gender == "male")
src.gender = MALE
src.icon = 'male.dmi'
src.icon_state = input(src, "Avatar?") as null | anything in list ("Jaden Yuki","Aichi Asia","Yusei Fudo","Yugi Moto","Yuma Tsukumo","Kai Toshiki")
if(!src.icon_state) src.icon_state = "Jaden Yuki"
else
src.gender = FEMALE
src.icon = 'female.dmi'
src.icon_state = input(src, "Avatar?") as null | anything in list ("Emi Senduo","Misaki Tokera")
if(!src.icon_state) src.icon_state = "Emi Senduo"
src.loc = locate(5,3,1) //we don't call move because it could return false and not set the location

Please note that the input proc uses usr by default. Use src instead.

As for Move, it could be that it fails due to a densed atom. Forcefully setting the loc variable should fix this problem.
In response to Jemai1
Jemai1 wrote:
Please note that the input proc uses usr by default. Use src instead.

As for Move, it could be that it fails due to a densed atom. Forcefully setting the loc variable should fix this problem.

There is a very rare case scenario where setting loc doesn't actually move you. I forget the case scenario I found, but its possible.

Also, I never use input() so pardon that.
Page: 1 2