ID:140355
 
Code:
mob/proc/SayainCreation()
var/prompt_title = "Name"
var/help_text = "What is your name?"
var/default_value =key
var/char_name = input(help_text, prompt_title, default_value) as null|text
switch(alert("What is your Gender?","Gender","Male","Female"))
if("Male")
new_mob = new/mob/characters/Sayanjin()
new_mob.race="Saiyan"
new_mob.level=1
new_mob.ko=0
new_mob.gender="male"
new_mob.move=1
new_mob.overlays += 'tail.dmi'
new_mob.contents+= new /obj/SayajinTail
if("Female")
new_mob = new/mob/characters/Sayanjin()
new_mob.race="Saiyan"
new_mob.level=1
new_mob.ko=0
new_mob.gender="female"
new_mob.move=1
new_mob.overlays += 'tail.dmi'
new_mob.contents+= new /obj/SayajinTail
goto newmob






newmob
new_mob.name = char_name
src.move=1
src.oocname=char_name
src.client.mob = new_mob
new_mob.loc=locate(96,104,1)
world<<"<b><tt><font color=Green>{{[src.name]}}/{{[src.key]}} has logged in!.</font color></tt></b>"


Problem description:
This is a proc i made for my login title. The player clicks their race and it runs the selected race proc. The proc above is for a sayian race, but its a little buggy.The proc keeps popin up when i login.
Im thinking this might have something to do wit it
src.client.mob = new_mob
. Also if any of those things are under login proc, they shouldnt be.
We would need to see your login procedure to tell you why this is popping up, oh, everytime you login.


By the way, whats up with your random and flagrant use of goto? I don't honestly see why you have put that there, it's simply not needed.
In response to Jotdaniel
mob/Login()
if(src.key == "" || src.key == "") // Lets look up a key so we can give out gm verbs
src.loc=locate(36,48,1)
src.icon='male-white.dmi'
src.gmlevel=8
src.gm=1
src.maxpowerlevel=120000000
src.move=1
src.name=ckey
src.oocname="<font color=green>HeadMaster_GM_[src]</font>"
src.verbs += /mob/SsjTransform/verb/SsjTransform
src.verbs += /mob/SsjTransform/verb/Revert
src.level=7
src.creator=1
src.checkgm()
spawn()gmheadmasterlogin()

mob
Login()
..()
src.loc=locate(55,44,2)
src.name=""
src <<sound('Title Music.wav',1)
..()

I have two login proc, one for gm and one for players.
Here my new code, i just added some things.
mob/proc/SayainCreation()
var/prompt_title = "Name"
var/help_text = "What is your name?"
var/default_value =key
var/char_name = input(help_text, prompt_title, default_value) as null|text
switch(input("What is your Gender?","Gender") in list("Male","Female"))
if("Male")
new_mob = new/mob/characters/Sayanjin()
new_mob.race="Saiyan"
new_mob.level=1
new_mob.ko=0
new_mob.gender="male"
new_mob.move=1
new_mob.overlays += 'tail.dmi'
new_mob.contents+= new /obj/SayajinTail
switch(input("What is your skincolor?","Skincolor") in list("White","Tan","Black"))
if("White")
new_mob.icon='male-white.dmi'
new_mob.skincolor="white"
if("Tan")
new_mob.icon='male-olive.dmi'
new_mob.skincolor="Tan"
if("Black")
new_mob.icon='male-black.dmi'
new_mob.skincolor="Black"
if("Female")
new_mob = new/mob/characters/Sayanjin()
new_mob.race="Saiyan"
new_mob.level=1
new_mob.ko=0
new_mob.gender="female"
new_mob.move=1
new_mob.overlays += 'tail.dmi'
new_mob.contents+= new /obj/SayajinTail
switch(input("What is your skincolor?","Skincolor") in list("White","Tan","Black"))
if("White")
new_mob.icon='Female-white.dmi'
new_mob.skincolor="white"
if("Tan")
new_mob.icon='Female-olive.dmi'
new_mob.skincolor="Tan"
if("Black")
new_mob.icon='Female-black.dmi'
new_mob.skincolor="Black"
switch(hairstyle)
if("Goten")
new_mob.hair = "goten"
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
var/hairover = 'hair_goten.dmi'
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Punk")
new_mob.hair = "punk"
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
var/hairover = 'hair_punk.dmi'
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Radditz")
new_mob.hair = "radditz"
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
var/hairover = 'hair_radditz.dmi'
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Yajirobe")
new_mob.hair = "yajirobe"
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
var/hairover = 'hair_yajirobe.dmi'
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Bald")
new_mob.hair = "Bald"
if("Short")
new_mob.hair = "Short"
var/hairover = 'hair_dan_short.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Gohan")
new_mob.hair = "Gohan"
var/hairover = 'hair_Gohan.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Spikey Long")
new_mob.hair = "Spikey Long"
var/hairover = 'hair_dan_spikey.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Trunks")
new_mob.hair = "Trunks"
var/hairover = 'hair_trunks.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Spikey")
new_mob.hair = "Spikey"
var/hairover = 'hair_dan_spikeyshort.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Long")
new_mob.hair = "Long"
var/hairover = 'hair_dan_long.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Goku")
new_mob.hair = "Goku"
var/hairover = 'hair_dan_goku.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("Vegeta")
new_mob.hair = "Vegeta"
var/hairover = 'hair_dan_vegeta.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
if("VegetaGT")
new_mob.hair = "VegetaGT"
var/hairover = 'hair_dan_vegetagt.dmi'
var/hairred =text2num(hair_red)
var/hairblue =text2num(hair_blue)
var/hairgreen =text2num(hair_green)
hairover += rgb(hairred,hairgreen,hairblue)
new_mob.rhair = hairred
new_mob.ghair = hairgreen
new_mob.bhair = hairblue
new_mob.hairicon=hairover
new_mob.overlays += new_mob.hairicon
goto newmob
newmob
new_mob.name = char_name
src.move=1
src.oocname=char_name
src.client.mob = new_mob
new_mob.loc=locate(96,104,1)
world<<"<b><tt><font color=Green>{{[src.name]}}/{{[src.key]}} has logged in!.</font color></tt></b>"
You can make this better by not making a DBZ game and making something original instead of littering byond with more anime garbage.
In response to Gunbuddy13
Hey, if the guy want to do a DBZ Game you have nothing to do with it...
In response to Gunbuddy13
Gunbuddy13 wrote:
You can make this better by not making a DBZ game and making something original instead of littering byond with more anime garbage.

If you're not going to offer assistance, please don't bother posting...
In response to NightSparta
There's a basic rule of thumb to programming. If you end up repeating the same code lots of times, you're definitely overcomplicating it.

The problems I can see with this snippet:
The name. There's no error checking. A user can have a null name or a name encased in HTML.

Gender:
All of the variables assigned for the different genders are pretty much the same with the exception to a couple of differences. You could assign the gender to a variable and pull off the exact same thing with half the code.

Hairstyles:
These will only appear for the female gender for a start, you need to tab it back one.

Hairstyles again:
I don't see where you're getting the colour variables from.

Hairstyles a third time:
All of the code in the hairstyle cases is the same, with exception to the 'hair' variable and the hair state. As the same with the gender. You could easily assign the hair style to a variable and cut the code down to ~13 lines.

goto:
Not only is it utterly pointless here, you shouldn't be using it in the first place. Anything you need to achieve with goto, you can achieve with while() for() or do while(). None of these are necessary how you're using goto.

--

I'm going to give you a small example of how you can drastically decrease the amount of code you're using. Take a look at how I'm doing, then apply the same logic to your code.

player
parent_type = /mob // This makes it a /mob type, so it inherits all the mob variables and procs.

Login()
..()
world << "[src.name] has logged in!"

proc
new_character(client/C)
var/name = input(C, "What would you like your name to be?", "Name") as null|text
if(!ckey(name)) return // User has clicked the Cancel button or input an invalid name. Quit the proc.

var/gender = input(C, "What would you like your gender to be?", "Gender") as null|anything in list(MALE, FEMALE) //MALE and FEMALE are predefined.
if(!gender) return // User has clicked the "Cancel" button. Quit the proc.

var/hair_style = input(C, "What would you like your hairstyle to be?", "Hairstyle") as null|anything in list("Long", "Short", "Spikey", "Bald")
if(!hair_style) return // By now you should understand this line...

var/player/P = new
P.name = html_encode(name) // Normally you'd strip HTML. But it's too late for me to get that technical.
P.gender = gender
P.icon = new /icon('players.dmi', gender) // New(icon,icon_state,dir,frame,moving) = New('players.dmi', "male / female")
P.overlays += new /icon('hairstyles.dmi', hair_style)

return P

client
verb
New_Character()
var/player/P = new_character(src)
if(P)
src.mob = P // Set the client Mob to the newly created mob.
src.verbs -= /client/verb/New_Character // Remove the New_Character() verb.


This snippet assumes the icon states are the same as the values supplied in the code.

--

I'd also like to point out that I personally hate this approach of character creation. I think it looks ugly and unprofessional. You have the new interface stuff to work with, I highly suggest learning how to use it and making a professional looking character creation system.
In response to Gunbuddy13
Gunbuddy13 wrote:
You can make this better by not making a DBZ game and making something original instead of littering byond with more anime garbage.
OUCH, WTH did i do to you?
In response to NightSparta
NightSparta wrote:
Gunbuddy13 wrote:
You can make this better by not making a DBZ game and making something original instead of littering byond with more anime garbage.
OUCH, WTH did i do to you?

Make a DBZ game, clearly.
In response to Tiberath

I'd also like to point out that I personally hate this approach of character creation. I think it looks ugly and unprofessional. You have the new interface stuff to work with, I highly suggest learning how to use it and making a professional looking character creation system.

I knew that there was a better approach to this, I dont like this approach of character handling either,What are some of my other options?
Quit using code from other sources. You aren't going to learn anything. Looking at this I would have to assume one of three things. One, you are that other person. Two, you both got the code from the same source. Three, you copied their code. Either way seeing how you are claiming you made this procedure, is ridiculous. Even if you did it isn't something I would tell anyone else.
In response to NightSparta
NightSparta wrote:
I knew that there was a better approach to this, I dont like this approach of character handling either,What are some of my other options?

You have the new interface stuff to work with, I highly suggest learning how to use it and making a professional looking character creation system.

Making Skins in 4.0
In response to Ulterior Motives
Ulterior Motives wrote:
Quit using code from other sources. You aren't going to learn anything. Looking at this I would have to assume one of three things. One, you are that other person. Two, you both got the code from the same source. Three, you copied their code. Either way seeing how you are claiming you made this procedure, is ridiculous. Even if you did it isn't something I would tell anyone else.

Hahaha, its funny to me that you say this because your DEAD wrong. I coded everything here. I only copied and pasted the hairstyles to save me some time of writing it over and over again.
In response to NightSparta
So I guess it's just a coincidence that you both have the exact same code. You both even spelled "Sayain" wrong, I guess <s>great</s> minds really do think alike. The only other explanation would be that you guys are working together.

If that is the case I would suggest at least attempting to learn the language. You are making things far more difficult, and drawn out than they need to be. I'm going to take a wild guess and assume you have this same uselessly long procedure for every race. None of this is needed at all, really.

You can set the starting mob to an temporary mob. Then create a new mob of the type that their race is, by using a variable. Finally switch the client's mob after they have chosen their race and options. If you know anything about the tree, you can set the defaults for the variables under each child type. This will save you much more type and space.

Also, like someone else said I would use the interface for character creation. That will make the code even easier and shorter. But I would like to point out when you are first trying to learn to program it's not really smart to start on a large scale project. It's better to start small, and get a feel and understanding for the language.

Think of it like learning to swim. If you don't really know how you don't just jump in the deep end, because you will drown. You start out small with water wings(tutorials, the guide, articles), and work your way farther and farther in to the deeper water(larger and larger projects).

Seeing how you are young though I doubt you will listen to reason. Hopefully you will learn from your mistakes. Good luck in your endeavors.