ID:155147
 
ok, so i know if you find yourself repeating code...your doing it wrong.

So that being said, how can i accomplish this...

mob
Login()
usr << "Welcome to One Piece Legends"
Beginning
switch(alert("Login","","New Character","Load Character","Delete Character"))
if("New Character")
switch(alert("Which Slot do you wish to Select?","","Slot 1","Slot 2","Slot 3"))
if("Slot 1")
if(fexists("Slot1/[usr.key].sav"))
switch(alert("Warning a save file has been found would you like to overwrite this slot?","","Yes","No"))
if("Yes")
fdel("Slot1/[usr.key].sav")
usr.logged = 1
usr.cansave = 1
usr.usingslot = "1"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(00001,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'


if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
else
usr<<"Slot 1 Creation Complete"
world << "[name] has appeared in the world for their first time!"
src.loc=locate(207,268,2)
client.eye=usr
return
if("No")
goto Beginning
else
usr.logged = 1
usr.cansave = 1
usr.usingslot = "1"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(00001,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'
if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
view() << "[src] has appeared!"
usr<<"Slot 1 Creation Complete"
else
src.loc=locate(207,268,2)
world << "[src] has logged in!"
usr<<"Slot 1 Creation Complete"
return
if("Slot 2")
if(fexists("Slot2/[usr.key].sav"))
switch(alert("Warning a save file has been found would you like to overwrite this slot?","","Yes","No"))
if("Yes")
fdel("Slot2/[usr.key].sav")
usr.logged = 1
usr.cansave = 1
usr.usingslot = "2"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(10000,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'

// switch(input("Please Select Your Skin Tone:","Skin Tone?") in list("Lightest","Light","Medium","Dark","Darkest"))
// if("Light")
if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
else
usr<<"Slot 2 Creation Complete"
world << "[name] has appeared in the world for their first time!"
src.loc=locate(207,268,2)
client.eye=usr
return
if("No")
goto Beginning
else
usr.logged = 1
usr.cansave = 1
usr.usingslot = "2"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(10000,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'
if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
view() << "[src] has appeared!"
usr<<"Slot 2 Creation Complete"
else
src.loc=locate(207,268,2)
world << "[src] has logged in!"
usr<<"Slot 2 Creation Complete"
return

if("Slot 3")
if(fexists("Slot3/[usr.key].sav"))
switch(alert("Warning a save file has been found would you like to overwrite this slot?","","Yes","No"))
if("Yes")
fdel("Slot3/[usr.key].sav")
usr.logged = 1
usr.cansave = 1
usr.usingslot = "3"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(10000,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'

// switch(input("Please Select Your Skin Tone:","Skin Tone?") in list("Lightest","Light","Medium","Dark","Darkest"))
// if("Light")
if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
else
usr<<"Slot 3 Creation Complete"
world << "[name] has appeared in the world for their first time!"
src.loc=locate(207,268,2)
client.eye=usr
return
if("No")
goto Beginning
else
usr.logged = 1
usr.cansave = 1
usr.usingslot = "3"
name = input("Please enter your name:", "Your name") as text
src.Name=src.name
src.ID = rand(10000,99999)
switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
icon='Male.dmi'
if("Female")
icon='Female.dmi'
if(key=="Komuroto")
src.verbs += typesof (/mob/DM/verb)
src.loc=locate(207,268,2)
view() << "[src] has appeared!"
usr<<"Slot 3 Creation Complete"
else
src.loc=locate(207,268,2)
world << "[src] has logged in!"
usr<<"Slot 3 Creation Complete"
return
if("Load Character")
switch(alert("Which Slot do you wish to Select?","","Slot 1","Slot 2","Slot 3"))
if("Slot 1")
if(fexists("Slot1/[usr.key].sav"))
usr.SaveSlot1Load()
else
alert("No save file were found.")
goto Beginning
if("Slot 2")
if(fexists("Slot2/[usr.key].sav"))
usr.SaveSlot2Load()
else
alert("No save file were found.")
goto Beginning
if("Slot 3")
if(fexists("Slot3/[usr.key].sav"))
usr.SaveSlot3Load()
else
alert("No save file were found.")
goto Beginning
if("Delete Character")
switch(alert("Which Slot do you wish to Select?","","Slot 1","Slot 2","Slot 3"))
if("Slot 1")
switch(alert("Delete Save Slot 1 ?","Save Slot Delete","Yes","No"))
if("Yes")
usr.client.screen = null
if(fexists("Slot1/[usr.key].sav"))
fdel("Slot1/[usr.key].sav")
goto Beginning
else
goto Beginning
if("No")
goto Beginning
if("Slot 2")
switch(alert("Delete Save Slot 2 ?","Save Slot Delete","Yes","No"))
if("Yes")
usr.client.screen = null
if(fexists("Slot2/[usr.key].sav"))
fdel("Slot2/[usr.key].sav")
goto Beginning
else
goto Beginning
if("No")
goto Beginning
if("Slot 3")
switch(alert("Delete Save Slot 3 ?","Save Slot Delete","Yes","No"))
if("Yes")
usr.client.screen = null
if(fexists("Slot3/[usr.key].sav"))
fdel("Slot3/[usr.key].sav")
goto Beginning
else
goto Beginning
if("No")
goto Beginning


without all the needless repeating, that i have clearly done? It works, but Its too long...obviously.
Well it doesn't really affect the game, so it is pointless in a way. If you want to get it out of the way you should make a separate code file for it.
In response to Dr.DraX
I rather wait to hear what others have to say before deciding on that.
In response to Komuroto
Komuroto wrote:
I rather wait to hear what others have to say before deciding on that.

Go ahead, I don't want to interfere on what you want.
Looks to me like something out of a rip.

Either way, a simple method for shortening all of this is to say:
var/slot = switch(whatever)


Then, everywhere you reference a slot number, use that variable. So instead of:
if(fexists("Slot1/[usr.key].sav"))

And:

usr.usingslot = "1"


You would use:
if(fexists("[slot]/[usr.key].sav"))

And:

usr.usingslot = slot


This way, all of those sets you have where the only difference is which slot it uses can be shortened by 2/3, making any editing you need to do to them much simpler.

You could also break this up into several procs, such as SelectScreen(), to handle choosing an option, DeleteChar(), for deleting your characters, CreateChar(), for creating your characters, and LoadChar(), for, you guessed it, loading your characters. You would also be able to get rid of that goto spam in favor of simply calling the starting proc, in this case SelectScreen(), again.
In response to Dr.DraX
Dr.DraX wrote:
Well it doesn't really affect the game, so it is pointless in a way. If you want to get it out of the way you should make a separate code file for it.

Using good programming practices is pointless? Where was I when this was decided??

It may not make a huge difference to the player, but good practices like making things fast and easy to edit/understand is never pointless. In this particular example it may not be a big deal because it likely isn't going to need to be drastically changed anymore, but doing similar things in other areas without knowing how to handle them properly could lead to some major headaches down the road.
I think someone else touched on a good solution. Here's something to help you along. The key here is the sSlotNum variable usage. I made sure this compiled so I had to comment out some stuff. I also added a few { } to help me quickly format/edit it. Hope it helps.

mob
{
var
{
logged;
cansave
usingslot
Name
ID
}
verb
{
MainMenu()
{
Mob_HandleCharacterSelection();
}
}
proc
{
Mob_GetSlot()
{
var/sSlotNum;

switch(alert("Which Slot do you wish to Select?","","Slot 1","Slot 2","Slot 3"))
if("Slot 1")
sSlotNum = "1"
if("Slot 2")
sSlotNum = "2"
if("Slot 3")
sSlotNum = "3"

return sSlotNum
}
Mob_HandleCharacterSelection()
{
usr << "Welcome to One Piece Legends"
switch(alert("Login","","New Character","Load Character","Delete Character"))
{
if("New Character")
var/sSlotNum = Mob_GetSlot();


logged = 1
cansave = 1
usingslot = sSlotNum
name = input("Please enter your name:", "Your name") as text
Name = src.name
usr.ID = rand(00001,99999)

switch(input("Please Select Your Gender:","Gender?") in list("Male","Female"))
if("Male")
usr << "icon"
//icon='Male.dmi'
if("Female")
usr << "icon"
//icon='Female.dmi'
if(fexists("Slot[sSlotNum]/[key].sav"))
switch(alert("Warning a save file has been found would you like to overwrite this slot?","","Yes","No"))
if("Yes")
fdel("Slot[sSlotNum]/[key].sav")
// Handle Admin stuff in another way.
if("No")
spawn()
Mob_HandleCharacterSelection();
else
// Handle Admin stuff in another way
loc = locate(207,268,2)
world << "[src] has logged in!"
usr << "Slot [sSlotNum] Creation Complete"
if("Load Character")
var/sSlotNum = Mob_GetSlot();
if(fexists("Slot[sSlotNum]/[key].sav"))
SaveSlotLoad(sSlotNum)
else
alert("Invalid character!");
spawn()
Mob_HandleCharacterSelection();
if("Delete Character")
var/sSlotNum = Mob_GetSlot();
switch(alert("Delete Save Slot [sSlotNum] ?","Save Slot Delete","Yes","No"))
if("Yes")
client.screen = null
if(fexists("Slot[sSlotNum]/[key].sav"))
fdel("Slot[sSlotNum]/[usr.key].sav")
spawn()
Mob_HandleCharacterSelection();
}
}
SaveSlotLoad(var/slotNum)
{

}
}
}
In response to Tsfreaks
ah tsfreaks, my favorite, community member!

Thanks, always enjoy your input.
In response to Robertbanks2
Dont worry robert, i chose to ignore his comment
In response to Tsfreaks
Oh and one more thing.

Upon login, with what you've written, I am suppose to call upon the procs: which that i understand.

But when you put mainmenu() into a verb, that throws me off.

How do I make the src logging-in activate that verb, and also keep it out of statpannels?

set hidden = 1 right?
In response to Komuroto
Remove the verb and place the call in Login().
mob
Login()
Mob_HandleCharacterSelection()
..()
In response to Tsfreaks
i should've known that :P sorry.

NOW I'LL HAVE to incorporate my save/load info