ID:146103
 
Code:
ob
proc
Save()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["usr"] << usr
Write(F)

world/mob = /mob/ChoosingCharacter

mob
proc
NewGame()
var/prompt_title = "Character Creation"
var/help_text = "What is your Character's name?"
var/default_value = "[src.ckey]"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
alert("You have not chosen a name, please go back and do so now.")
src.NewGame()
return

switch(alert("Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
if("Male")
name = char_name
icon = 'boy.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 15
defense = 15
magicattack = 10
magicdefense = 10
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Boy"
style_level = 0
style_exp = 0
style_maxexp = 100
if("Female")
name = char_name
icon = 'girl.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 10
defense = 10
magicattack = 15
magicdefense = 15
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Girl"
style_level = 0
style_exp = 0
style_maxexp = 100

usr.loc = locate(5,2,2)
usr.sight = 0
world<<"[src.name] has entered the stuggle for power."

mob
ChoosingCharacter
Login()
Load
Rules()
src.loc = locate(5,5,1)
switch(alert("Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
if("Load Character")
if(fexists("./savefiles/[src.ckey].sav"))
var/savefile/S = new("./savefiles/[src.ckey].sav")
S["usr"] >> src
world << "[src.name] has entered the struggle for power."
src.UserLocate()
else
alert("No previous character found!")
goto Load
if("New Character")
if(fexists("./savefiles/[src.ckey].sav"))
switch(alert("You already have an exsisting!\nIf you choose to create a new character, your previous character will be deleted.","Continue?","Yes","No"))
if("Yes")
src.NewGame()
else
goto Load
else
src.NewGame()
if("Exit")
Logout()

mob
proc
UserLocate()
if(hometown == "Shirre")
src.loc = locate(5,2,2)
if(hometown == "Abbey")
src.loc = locate(5,2,3)


Problem description: After taking a look at FlameSage's lib, I decided to add a bit of it into my login. For some reason though, the load works, the save works, and the new character works, but once you load your character, the initial "Load/Create/Exit" window comes up again... Any idea why its looping?

Here are a few ideas you should think about.

Firstly, No Put Usr In Proc, Ungh. Refer to The Usr Lecture.

Secondly, Goto is bad. You don't need to use goto here. Instead you can use while() loops, like while(!src.name)

After you fix that, repost the code if it still does not work.
In response to N1ghtW1ng
world
name = "Eternal Power"

mob
proc
Save()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] << src
Write(F)
Load()
var/savefile/S = new("./savefiles/[src.ckey].sav")
S["src"] >> src
world << "[src.name] has entered the struggle for power."
src.UserLocate()

world/mob = /mob/ChoosingCharacter

mob
proc
NewGame()
var/prompt_title = "Character Creation"
var/help_text = "What is your Character's name?"
var/default_value = "[src.ckey]"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
alert("You have not chosen a name, please go back and do so now.")
src.NewGame()
return

switch(alert("Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
if("Male")
name = char_name
icon = 'boy.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 15
defense = 15
magicattack = 10
magicdefense = 10
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Boy"
style_level = 0
style_exp = 0
style_maxexp = 100
if("Female")
name = char_name
icon = 'girl.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 10
defense = 10
magicattack = 15
magicdefense = 15
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Girl"
style_level = 0
style_exp = 0
style_maxexp = 100

src.loc = locate(5,2,2)
src.sight = 0
world<<"[src.name] has entered the stuggle for power."

mob
ChoosingCharacter
Login()
Load
Rules()
src.loc = locate(5,5,1)
switch(alert("Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
if("Load Character")
if(fexists("./savefiles/[src.ckey].sav"))
src.Load()
else
alert("No previous character found!")
goto Load
if("New Character")
if(fexists("./savefiles/[src.ckey].sav"))
switch(alert("You already have an exsisting!\nIf you choose to create a new character, your previous character will be deleted.","Continue?","Yes","No"))
if("Yes")
src.NewGame()
else
goto Load
else
src.NewGame()
if("Exit")
Logout()

mob
proc
UserLocate()
if(hometown == "Shirre")
src.loc = locate(5,2,2)
if(hometown == "Abbey")
src.loc = locate(5,2,3)


Problem still exists.
In response to Plagu3r
mob
proc
Save()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] << src
Write(F)
Load()
var/savefile/S = new("./savefiles/[src.ckey].sav")
S["src"] >> src
world << "[src.name] has entered the struggle for power."
src.UserLocate()

world/mob = /mob/ChoosingCharacter

mob
proc
NewGame()
var/prompt_title = "Character Creation"
var/help_text = "What is your Character's name?"
var/default_value = "[src.ckey]"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
alert("You have not chosen a name, please go back and do so now.")
src.NewGame()
return

switch(alert("Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
if("Male")
name = char_name
icon = 'boy.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 15
defense = 15
magicattack = 10
magicdefense = 10
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Boy"
style_level = 0
style_exp = 0
style_maxexp = 100
if("Female")
name = char_name
icon = 'girl.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 10
defense = 10
magicattack = 15
magicdefense = 15
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Girl"
style_level = 0
style_exp = 0
style_maxexp = 100

src.loc = locate(5,2,2)
src.sight = 0
world<<"[src.name] has entered the stuggle for power."

mob
ChoosingCharacter
Login()
Rules()
src.loc = locate(5,5,1)
switch(alert("Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
if("Load Character")
if(fexists("./savefiles/[src.ckey].sav"))
src.Load()
else
alert("No previous character found!")
Logout()
if("New Character")
if(fexists("./savefiles/[src.ckey].sav"))
switch(alert("You already have an exsisting!\nIf you choose to create a new character, your previous character will be deleted.","Continue?","Yes","No"))
if("Yes")
src.NewGame()
else
Logout()
else
src.NewGame()
if("Exit")
Logout()

mob
proc
UserLocate()
if(hometown == "Shirre")
src.loc = locate(5,2,2)
if(hometown == "Abbey")
src.loc = locate(5,2,3)


Still..
In response to Plagu3r
mob
proc
Save()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] << src
Write(F)
Load()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] >> src
world << "[src.name] has entered the struggle for power."
src.UserLocate()

mob
proc
UserLocate()
if(hometown == "Shirre")
src.loc = locate(5,2,2)
if(hometown == "Abbey")
src.loc = locate(5,2,3)

LoadGameCheck()
if(fexists("./savefiles/[src.ckey].sav"))
src.Load()
else
alert("No existing characters!")
Logout()

NewGameCheck()
if(fexists("./savefiles/[src.ckey].sav"))
switch(alert("You already have an exisiting file!\nWould you like to delete this file?","[world.name]","Yes","No"))
if("Yes")
src.NewGame()
if("No")
Logout()
else
src.NewGame()

NewGame()
var/prompt_title = "Character Creation"
var/help_text = "What is your Character's name?"
var/default_value = "[src.ckey]"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
alert("You have not chosen a name, please go back and do so now.")
src.NewGame()

switch(alert("Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
if("Male")
name = char_name
icon = 'boy.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 15
defense = 15
magicattack = 10
magicdefense = 10
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Boy"
style_level = 0
style_exp = 0
style_maxexp = 100
if("Female")
name = char_name
icon = 'girl.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 10
defense = 10
magicattack = 15
magicdefense = 15
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Girl"
style_level = 0
style_exp = 0
style_maxexp = 100

src.loc = locate(5,2,2)
src.sight = 0
world<<"[src.name] has entered the stuggle for power."

mob
Login()
Rules()
src.loc = locate(5,5,1)
switch(alert("Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
if("Load Character")
src.LoadGameCheck()
if("New Character")
src.NewGameCheck()
if("Exit")
Logout()


Any ideas guy..?
In response to Plagu3r
Plagu3r wrote:
world
> name = "Eternal Power"
>
> mob
> proc
> Save()
> var/savefile/F = new("./savefiles/[src.ckey].sav")
> F["src"] << src
> Write(F)
> Load()
> var/savefile/S = new("./savefiles/[src.ckey].sav")
> S["src"] >> src
> world << "[src.name] has entered the struggle for power."
> src.UserLocate()
>
> world/mob = /mob/ChoosingCharacter
>
> mob
> proc
> NewGame()
> var/prompt_title = "Character Creation"
> var/help_text = "What is your Character's name?"
> var/default_value = "[src.ckey]"
> var/char_name = input(src, help_text, prompt_title, default_value) as null|text
>
> if (!char_name)
> alert("You have not chosen a name, please go back and do so now.")
> src.NewGame()
> return
>
> switch(alert("Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
> if("Male")
> name = char_name
> icon = 'boy.dmi'
> level = 1
> hp = 50
> maxhp = 50
> mp = 25
> maxmp = 25
> strength = 15
> defense = 15
> magicattack = 10
> magicdefense = 10
> speed = 1
> gold = 2000
> exp = 0
> maxexp = 200
> modlevel = 0
> focus = 0
> weapon = 0
> armor = 0
> access = 0
> style = "Young Boy"
> style_level = 0
> style_exp = 0
> style_maxexp = 100
> if("Female")
> name = char_name
> icon = 'girl.dmi'
> level = 1
> hp = 50
> maxhp = 50
> mp = 25
> maxmp = 25
> strength = 10
> defense = 10
> magicattack = 15
> magicdefense = 15
> speed = 1
> gold = 2000
> exp = 0
> maxexp = 200
> modlevel = 0
> focus = 0
> weapon = 0
> armor = 0
> access = 0
> style = "Young Girl"
> style_level = 0
> style_exp = 0
> style_maxexp = 100
>
> src.loc = locate(5,2,2)
> src.sight = 0
> world<<"[src.name] has entered the stuggle for power."
>
> mob
> ChoosingCharacter
> Login()
> Load
> Rules()
> src.loc = locate(5,5,1)
> switch(alert("Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
> if("Load Character")
> if(fexists("./savefiles/[src.ckey].sav"))
> src.Load()
> else
> alert("No previous character found!")
> goto Load
> if("New Character")
> if(fexists("./savefiles/[src.ckey].sav"))
> switch(alert("You already have an exsisting!\nIf you choose to create a new character, your previous character will be deleted.","Continue?","Yes","No"))
> if("Yes")
> src.NewGame()
> else
> goto Load
> else
> src.NewGame()
> if("Exit")
> Logout()
>
> mob
> proc
> UserLocate()
> if(hometown == "Shirre")
> src.loc = locate(5,2,2)
> if(hometown == "Abbey")
> src.loc = locate(5,2,3)

Problem still exists.


i might be wrong but i might aswell throw a bone out for you

// for your new char thing you got this so uhmmm
> ****src.loc = locate(5,2,2)****
> src.sight = 0
> world<<"[src.name] has entered the stuggle for power."

// but for your load you got a proc going to change the loc.

Load()
> var/savefile/S = new("./savefiles/[src.ckey].sav")
> S["src"] >> src
> world << "[src.name] has entered the struggle for power."
> ****src.UserLocate()****

// maybe im wrong .. but yeah. that might be it
In response to Echtolion
I don't think thats it. The initial locate is telling a new character to go there. On load, the system checks the hometown of the player and gives them correct coordinates according to the UserLocate.
In response to Plagu3r
Plagu3r wrote:
I don't think thats it. The initial locate is telling a new character to go there. On load, the system checks the hometown of the player and gives them correct coordinates according to the UserLocate.

initial load is 5,2,2 or something, when done with a new char its 5,5,5.. uhmm atleast i think so
In response to Echtolion
The first locate, from the Login proc, is 5,5,1. That is the game screen. The second locate is 5,5,2, from the new character proc, which is the first map.
In response to Plagu3r
You are still abusing usr. Some procs like alert(), input(), view(), oview(), range(), orange(), viewers(), and oviewers() default to usr. Basically you would have to do switch(alert(src,....)).
In response to N1ghtW1ng
I just went through every bit of coding and changed all the things you had explained to me. But still, the error is STILL there.
In response to Plagu3r
mob
proc
Save()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] << src
Write(F)
Load()
var/savefile/F = new("./savefiles/[src.ckey].sav")
F["src"] >> src
world << "[src.name] has entered the struggle for power."
src.UserLocate()

mob
proc
UserLocate()
if(hometown == "Shirre")
src.loc = locate(5,2,2)
if(hometown == "Abbey")
src.loc = locate(5,2,3)

LoadGameCheck()
if(fexists("./savefiles/[src.ckey].sav"))
src.Load()
else
alert("No existing characters!")
Logout()

NewGameCheck()
if(fexists("./savefiles/[src.ckey].sav"))
switch(alert(src,"You already have an exisiting file!\nWould you like to delete this file?","[world.name]","Yes","No"))
if("Yes")
src.NewGame()
if("No")
Logout()
else
src.NewGame()

NewGame()
var/prompt_title = "Character Creation"
var/help_text = "What is your Character's name?"
var/default_value = "[src.ckey]"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
alert(src,"You have not chosen a name, please go back and do so now.")
src.NewGame()

switch(alert(src,"Please choose your gender.\nYour gender will determine what classes you can use later in the game.","Gender","Male","Female"))
if("Male")
name = char_name
icon = 'boy.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 15
defense = 15
magicattack = 10
magicdefense = 10
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Boy"
style_level = 0
style_exp = 0
style_maxexp = 100
if("Female")
name = char_name
icon = 'girl.dmi'
level = 1
hp = 50
maxhp = 50
mp = 25
maxmp = 25
strength = 10
defense = 10
magicattack = 15
magicdefense = 15
speed = 1
gold = 2000
exp = 0
maxexp = 200
modlevel = 0
focus = 0
weapon = 0
armor = 0
access = 0
style = "Young Girl"
style_level = 0
style_exp = 0
style_maxexp = 100

src.loc = locate(5,2,2)
src.sight = 0
world<<"[src.name] has entered the stuggle for power."

mob
Login()
Rules()
src.loc = locate(5,5,1)
switch(alert(src,"Welcome to [world.name].\nWhat would you like to do?","[world.name]","Load Character","New Character","Exit"))
if("Load Character")
src.LoadGameCheck()
if("New Character")
src.NewGameCheck()
if("Exit")
Logout()
In response to Plagu3r
Why isn't <code>..()</code> somewhere in Login()?
In response to Mega fart cannon
Well, if it did something that actually helped me, I would love it. :D
In response to Plagu3r
Plagu3r wrote:
Well, if it did something that actually helped me, I would love it. :D

It calls the parent proc, which may or may not solve your problem.
In response to Audeuro
I tried it before I posted that last post. :D
In response to Plagu3r
Bump?
In response to Plagu3r
Anyone?
In response to Plagu3r
This must be one of those things that no one has ever seen before..