ID:179153
 
How would I go about making a character creation in the browser?

I have seen it in afew games and it looks kinda nice. So I was wondering if anyone could help me and point me out in the right direction as to where to go.

Lee
Mellifluous wrote:
How would I go about making a character creation in the browser?

I have seen it in afew games and it looks kinda nice. So I was wondering if anyone could help me and point me out in the right direction as to where to go.

The first thing you'll need to do is override client.Topic(), which is used to respond to links clicked within the browser or text area.
client/Topic(...)  // I don't remember the argument order
if(mob.initializing_character)
if("class" in href_list)
var/classname=href_list["class"]
if(classname in CharClasses)
mob << "You are now \a [classname]."
mob.class=classname
mob.icon=CharClasses[classname]
mob.initializing_character&=~1
else return
if("stats" in href_list)
var/list/s=ParseStats(href_list["stats"]) // make your own parsing proc
if(ValidStats(s))
mob.AssignStats(s)
mob.initializing_character&=~2
else
mob << "Those aren't valid stats."
if(!mob.initializing_character)
mob << browse(null)
mob.FinishInit() // done initializing!
..() // this is important in client/Topic()

Obviously this depends a lot on how you parse the data, etc. You have to put in error checks and make sure a player can't use the same URL later, or else unpredictable things could happen.

In whatever HTML document you send to the user, you'll have to do a few things. First, make sure all links that will send to client.Topic() use "byond://" to start with. Second, preload all graphics using browse_rsc().
ShowCharacterSelection(mob/M)
M << browse_rsc('paper.gif')
var/txt="<HTML><BODY BACKGROUND='paper.gif'>"
for(var/classname in classname
// preload each class icon as "class_[classname].dmi"
M << browse_rsc(CharClasses[classname],"class_[classname].dmi")
txt+="<A HREF='byond://?class=[classname]'>" +\
"<IMG SRC='class_[classname].dmi' WIDTH=32 HEIGHT=32> [classname]</A>"
txt+="</BODY></HTML>"
M << browse(txt)

That's a rough, oversimplified example of what you should do. The actual HTML page you put up would naturally be more complex.

Lummox JR
In response to Lummox JR
Well instead of looking at Lummox's code, make it simple for you and use Deadron's Character Form, but you need to subscribe to byondscape for access.
In response to Super16
Super16 wrote:
Well instead of looking at Lummox's code, make it simple for you and use Deadron's Character Form, but you need to subscribe to byondscape for access.

I am a BYONDscape subscriber :-P

Hehe, I will look over both of these. Also thanks Lummox ^_^

Lee
In response to Mellifluous
It would also be a good idea to download Dantom.htmllib.
In response to Nadrew
Nadrew wrote:
It would also be a good idea to download Dantom.htmllib.

I already have that too :-P

I have everything downloaded from BYONDscape with the exception of DDT. Thats the only thing I havent downloaded so far ^_^

Lee