ID:178309
 
I have my own personal icon when I log in, but then my char pick window pops-up, and makes me pick a diff icon, what do I do, here is the code:

world
mob = /mob/creating_character //This sets the default mob path
name = "Tiny Chao Chatroom" //This sets the games name
turf = /turf/grass //This sets the default turf
mob/creating_character

Login()
..()
if(src.ckey == "airjoe") //if its you..
src.icon = 'GM.dmi'
var/hasicon=1
world << "[usr] has just entered '[world.name]'!"//We tell the world that someone has just joined the game now
usr << "Welcome to Tiny Chao Chatroom, this is v1.1"
usr << "NOTE: This is a chat, NOT a game, this is my first BYOND thing"
src.CreateCharacter()
Logout()
del(src)

proc/CreateCharacter()
var/char_name = input("Please put your character name in here.","Name") as null|text //The player makes their name here
var/mob/new_mob //We are declaring a new variable called "new_mob" which will be used in alittle minute
if(hasicon==0)
var/char = input(src,"Pick your color chao!") in ow","red","purple","green","pink","brainy(special)","Cancel/ Logout") //The player chooses his/her character here
if(char_name == "") //Here we tell the game to logout the player if he/she has a null name
src.Logout() //This calls up the logout()
if(char == "normal")
new_mob = new/mob/player/normal
if(char == "white")
new_mob = new/mob/player/white
if(char == "yellow")
new_mob = new/mob/player/yellow
if(char == "red")
new_mob = new/mob/player/red
if(char == "purple")
new_mob = new/mob/player/purple
if(char == "green")
new_mob = new/mob/player/green
if(char == "pink")
new_mob = new/mob/player/pink
if(char == "brainy(special)")
new_mob = new/mob/player/brainy
if(char == "Cancel/Logout")
src.Logout()
new_mob.name = char_name //This sets the players name to the one he/she made up before
src.client.mob = new_mob //Here we tell the game that there is a new mob/player in the game
usr.loc = locate(1,1,1) //Here me make the new player start off at the location of X:1, Y:1, Z:1.


/*The characters are defined below*/

mob/player
normal
icon = 'smile.dmi'
icon_state = "normal"
mob/player
white
icon = 'smile.dmi'
icon_state = "white"
mob/player
yellow
icon = 'smile.dmi'
icon_state = "yellow"
mob/player
red
icon = 'smile.dmi'
icon_state = "red"
mob/player
purple
icon = 'smile.dmi'
icon_state = "purple"
mob/player
green
icon = 'smile.dmi'
icon_state = "green"
mob/player
pink
icon = 'smile.dmi'
icon_state = "pink"
mob/player
brainy
icon = 'smile.dmi'
icon_state = "brainy"©
this is an official TM of Airjoe's Money, inc

don't copy
**** **** ********.dm:35:error:hasicon:undefined var
**** **** ********.dm:24:hasicon :warning: variable defined but not used
**** **** ********.dm:35:if :warning: if statement has no effect
In response to Airjoe
Airjoe wrote:
**** **** ********.dm:35:error:hasicon:undefined var
**** **** ********.dm:24:hasicon :warning: variable defined but not used
**** **** ********.dm:35:if :warning: if statement has no effect

The first error and the first warning, which are no doubt confusing because they seem to contradict each other, are because you have the line that declares hasicon (var/hasicon) indented in another block of code. That means that the var is only valid for that block. Thus the warning occurs because you leave the block without ever using that var. The error occurs because when you finally do use the var, it's in a place it hasn't been defined.

The solution: Before the if() block where you set hasicon=1, put in this line:
var/hasicon

The if statement that gives you the second warning:
if(hasicon==0)

This generates a warning because it does nothing; the code underneath it isn't indented, so it thinks the next line isn't part of the if() block. You're literally telling the compiler, "If hasicon is 0, do nothing, then move on to the next line." A better choice would be this:
if(!hasicon)
.... // do the icon selection in here; indent each line

Lummox JR
In response to Lummox JR
could you just re-write me the proper code?
In response to Airjoe
Airjoe wrote:
could you just re-write me the proper code?
if(client) del(src)

If that doesn't work, you should make the aforementioned changes yourself.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
The solution: Before the if() block where you set hasicon=1, put in this line:
var/hasicon

The if statement that gives you the second warning:
if(hasicon==0)

This generates a warning because it does nothing; the code underneath it isn't indented, so it thinks the next line isn't part of the if() block. You're literally telling the compiler, "If hasicon is 0, do nothing, then move on to the next line." A better choice would be this:
if(!hasicon)
> .... // do the icon selection in here; indent each line

Lummox JR



Actually, you have to have var/hasicon = 0, since null does not equal 0, it will always return true on the if(!hasicon).
In response to Garthor
Garthor wrote:
Actually, you have to have var/hasicon = 0, since null does not equal 0, it will always return true on the if(!hasicon).

That's not really correct; if(!hasicon) will be true if hasicon is null or 0, so it won't matter which one it's set to. If, however, the if() is left as if(hasicon==0), then it does matter which it's set to--which is why I suggested it be changed.

Lummox JR
In response to Lummox JR
How do I make a choice on the pop-up to make it close?

like:
var/char = input(src,"Pick your color chao!") in list("normal","white","yellow","red","purple","green","pink" ,"brainy(special)","close(GMs only)","Cancel/Logout") //The player chooses his/her character here
if(char_name == "") //Here we tell the game to logout the player if he/she has a null name
src.Logout() //This calls up the logout()
if(char == "normal")
new_mob = new/mob/player/normal
if(char == "white")
new_mob = new/mob/player/white
if(char == "yellow")
new_mob = new/mob/player/yellow
if(char == "red")
new_mob = new/mob/player/red
if(char == "purple")
new_mob = new/mob/player/purple
if(char == "green")
new_mob = new/mob/player/green
if(char == "pink")
new_mob = new/mob/player/pink
if(char == "brainy(special)")
new_mob = new/mob/player/brainy
if(char == "Cancel/Logout")
src.Logout()
if(char == "close"
close window
In response to Airjoe
well since no one knows how to close a window, I am lucky I do,

src.close