ID:2008689
 
(See the best response by Ter13.)
Code:
mob/other/choosing_character
Login()
usr.loc=locate(rand(50,100),rand(50,100),10)
usr.sight = 1
src.sight = 1
spawn()
src.ChooseCharacter()

proc
ChooseCharacter()
var/list/characters = src.CharacterList()
var/newCharacterChoice = "New Character"
var/DeleteCharacterChoice = "Delete Character"
var/list/menu = new()
menu += characters
menu += newCharacterChoice
menu += DeleteCharacterChoice

var/result = input("Choose an option", "One Punch Man") in menu
usr.sight=1
if (result == newCharacterChoice)
src.CreateNewCharacter()
if (result == DeleteCharacterChoice)
src.DeleteCharacter()
src.ChooseCharacter()
else
var/success = src.client.LoadMob(result)


Problem description:
The menu is not showing up i added newCharacterhoice and everything. and changed usr.sight to 1, although im getting no error.
Any reason you are using usr and src in Login()?
In response to Akto
not the source but the usr so they can see map I already deleted source when i relised it was there.
So... you want them to see.. shouldn't sight be 0 then?
You should never use usr in login.

What's your world.mob variable set to? Make sure that the player is actually that type.
mob/Login()
src.loc=locate(45,38,1)
src.icon_state = ""
src << output("<font color = red>Welcome to One Punch Man, we owe no affiliation to one punch man so don't sue us XD</font>","chatbox")
world << output("<tt><font color = red>{-><font color = blue>[src] has logged in!<font color = red><-}</tt>","chatbox")
world
//name = "One Punch Man"
name = "One Punch Man"
mob/Logout()
del(src)

client/proc/SaveMob()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = ckeyEx(src.mob.name)
F["/[ckey]/[char_ckey]"]<<src.mob

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob

client/Del()
if (istype(src.mob, /mob/other/choosing_character))
return ..()

src.SaveMob()
return ..()


mob/other/choosing_character
Login()
usr.loc=locate(rand(1,150),rand(1,150),1)
usr.sight = 0
spawn()
src.ChooseCharacter()

Hopefully you can get it from that because idk what it is or what you even mean
In response to Akto
When sight is 0 for me the player can move wherever they want I want them to see the map but not be able to move the map.
Best response
world.mob is a variable that determines the default type of mob will be given to a player when they log in.

world
mob = /mob/other/choosing_character


^Now when you log in, the client will connect to a new /mob/other/choosing_character.

As for your other problem. You don't actually need to put the player on the map at all. You can use client.eye to do this.

mob/other/choosing_character
Login()
client.eye = locate(rand(50,100),rand(50,100),10)
client.perspective = EYE_PERSPECTIVE
spawn()
ChooseCharacter()
proc
ChooseCharacter()
while(client) //this is a safer way of repeating the function than what you were doing
var/list/menu = src.CharacterList() + "New Character" + "Delete Character"

var/result = input("Choose an option", "One Punch Man") as anything in menu
switch(result)
if("New Character")
CreateNewCharacter()
if("Delete Character")
DeleteCharacter()
else
client.LoadMob(result)


We also need to fix the eye object and perspective whenever the player loads successfully. So let's say your player type is mob/player:

mob/player
Login()
client.eye = src
client.perspective = MOB_PERSPECTIVE


This will set the client eye back to the default value. Since the choosing_character mob isn't actually located on the map, they can't move anywhere, and their eye will stay fixed on a specific point on the map like you want.
In response to Ter13
Using Your code I tweaked it a little bit and i got the following errors Start.dm:50:error: result: undefined var
Start.dm:45:warning: : empty switch statement. I didnt know result is an undefined var and an empty switch statement makes no sense?!?!?
mob/other/choosing_character
Login()
client.eye = locate(rand(1,150),rand(1,150),1)
client.perspective = EYE_PERSPECTIVE
spawn()
ChooseCharacter()

proc
ChooseCharacter()
while(client)
var/list/menu = "New Character" + "Delete Character" + src.CharacterList()

switch(input("Choose an option", "One Punch Man") as anything in menu)
if("New Character")
CreateNewCharacter()
if("Delete Character")
DeleteCharacter()
else
src.client.LoadMob(result)

Your indentation is wrong under the switch statement, and I made a minor revision that fixed the first error minutes after posting. Sorry.

Also, you messed up the menu list builder. The two strings can't come before the characterlist function. What will happen, is you will wind up with this:

list("New CharacterDelete Character",char1,char2,char3,etc)

When you add two strings together, they just get jammed together as one string. But when a list is on the left of an addition operation, the right value will be added to the list. Since addition operators have the same precedence, this will cause the result (the same list) to become the left hand operation for the second addition operation, which will add the second string to the list.

This will only work if the list comes first in the operation.
In response to Ter13
Its no problem I make mistakes all the time, but I am still getting the result error, result was defined in the page of code.
Again, I made two minor changes to the code you tried to implement. Go back up and look for the other change.
In response to Ter13
Thank you again however back to the original problem I still am not able to view the New Character Load Character and im assuming my player mob is
mob/Login()
src.loc=locate(45,38,1)
src.icon_state = ""
src.sight = 0
client.eye = src
client.perspective = MOB_PERSPECTIVE
although I am pretty surue something is amiss
Did you change the world.mob var to the correct type?
In response to Ter13
yes but then i got this error when I started game up.
runtime error: type mismatch: "New CharacterDelete Character" + /list (/list)
proc name: ChooseCharacter (/mob/other/choosing_character/proc/ChooseCharacter)
usr: (src)
src: Dragonpearl123 (/mob/other/choosing_character)
src.loc: null
call stack:
Dragonpearl123 (/mob/other/choosing_character): ChooseCharacter()
Dragonpearl123 (/mob/other/choosing_character): Login()
If you aren't going to read what I'm typing, why are you still asking questions?

http://www.byond.com/forum/?post=2008689#comment17927263
In response to Ter13
Oh im sorry I read what you typed and I moved it around its just pressed undo button trying to undo some stuff and I didnt know it undid itself I saw the error before I posted, the only thing now is that it keeps showing up when I press New Character and Delete Character but I'll keep working on it.
the only thing now is that it keeps showing up when I press New Character and Delete Character but I'll keep working on it.

The main menu will keep showing up until the creating_character mob no longer has a client.

And yeah, it's okay. It's just something that happens around here a lot. I'll explain something, someone won't understand/bother to read, then ask a question later that indicates that they didn't read. Sorry to seem snappish. It's just... You know, I do my best to make sure that I completely solve a problem to the best of my ability in one go. Learning to debug, reread, and second-guess yourself is a big part of learning to program.
In response to Ter13
Also I'm pretty sure the error is in here.
var/help_text = "What is your name?"
var/default_value = ""
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
src.ChooseCharacter()
return

var/ckey_name = ckey(char_name)
var/list/characters = CharacterList()
if (characters.Find(ckey_name))
alert("Try another name.")
src.CreateNewCharacter()
return
It is like a continuous loop.
Alright. Yeah, this is a problem you haven't run into yet, but when you call ChooseCharacter() from CreateNewCharacter() which was called from ChooseCharacter(), it does something called deepening the stack.

The stack keeps track of which functions were called in order. A function can't finish until all blocking functions called from it were finished.

What you are doing here is creating a state machine. A state machine shouldn't hop around from function to function. It should fall back to a loop.

So the structure would look like this:

ChooseCharacter()
|
+-->CreateNewCharacter()
|
+-->DeleteCharacter()


What your current structure looks like:

ChooseCharacter()
|
+-->CreateNewCharacter()
|   |                      |
|   +-->ChooseCharacter()
|   |   |
|   |   +-->CreateNewCharacter()
|   |   |   |
|   |   |   +-->(THIS REPEATS INFINITELY, BTW)
|   |   |
|   |   +-->DeleteCharacter()
|   |
|   +-->CreateNewCharacter()


The stack keeps deepening with your current approach forever.

Now that you ChooseCharacter() runs a loop until the choosing_character mob no longer has a client. That means you don't need to call ChooseCharacter() again. You just need to return.

    var/char_name
var/list/characters = CharacterList()
do
char_name = input(src, "What is your name?","New Character") as null|text //not everything needs to be a variable.
if(!char_name)
return //eject back to ChooseCharacter() because it's a loop

if (ckey(char_name) in characters)
alert("Try another name.")
char_name = null //name was invalid, make the name null to continue asking for the name
while(!char_name) //repeat until char_name is no longer null


And there you have it. It's best not to call the function that called a function, or to call a function from itself. If you are doing that, 9 times out of 10, you should be using a loop of some sort.
Page: 1 2