mob
var
health
servbot
proc
CreateNewCharacter()
var/char_name = input("What is your name?","Create new")
SaveCharacter(char_name)
return char_name
SaveCharacter(char_name)
var/savefile/F = new("players.sav")
var/safe_name = ckey(char_name)
F.cd = "/[ckey]/[safe_name]"
F["full_name"] << char_name
var
obj/emote
M
trans = 0
Zenny = 10000
brains = 1
attack = 1
defense = 1
health = 10
New()
var/obj/emotion/normal/O = new()
O.icon = 'servbot.dmi'
emote = O
icon = 'servbot.dmi'
icon_state = "servbot"
Login()
usr << sound('Gesellschaft.mid',1)
var/savefile/F = new("players.sav")
F.cd = "/[ckey]"
var/list/characters = F.dir
var/newCharacterChoice = "<Create New Character>"
var/list/menu = new()
menu += characters
menu += newCharacterChoice
var/result = input("Which servbot will you command?","Servbot Selection") in menu
if(result == newCharacterChoice)
name = CreateNewCharacter()
usr.icon_state = input("What kind of Servbot do you want?","Welcome to Servbot Command!") in list("Blue","Red","Green","Orange")
usr.loc = locate(2,3,1)
if(usr.icon_state == "Blue")
usr:brains += 1
if(usr.icon_state == "Red")
usr:attack += 1
if(usr.icon_state == "Green")
usr:defense += 1
if(usr.icon_state == "Orange")
usr << "You're orange"
else
F.cd = "/[ckey]/[result]"
F["full_name"] >> name
..()
Stat()
statpanel("Servbot Status")
stat("Emotion",emote)
stat("Health",health)
stat("Zenny",Zenny)
statpanel("Servbot Protocols")
stat("Brains",brains)
stat("Attack",attack)
stat("Defense",defense)
statpanel("Inventory")
stat(contents)
ID:148632
Dec 1 2002, 12:48 pm
|
|
I'm just learning how to create save files, and I'm not quite finished with this one, and I was running a test run and it would let me make a new mob, select my icon, and put me on the map for play. but, when i try to continue a file, my mob deosn't show up. I can move and execute commands and that stuff but he doesn't show! Here's my mob code snippet; i hope it's not to much to read...
|
In response to Lummox JR
|
|
Lummox JR wrote:
A few horrible problems you have in there: You're using usr in Login(), which normally wouldn't be a big deal because it's semi-valid there, but src is always the correct choice. You're also using the : operator all over, which is just plain sloppy code. What's worse, you're using the : operator in some places because you put in usr instead of src, and usr is (as far as DM's concerned) just a regular /mob. So change usr to src there, and get rid of any src. or src: parts that are left over. Okay, I did that. But you have other problems. Why is most of the character creation code actually in Login() instead of CreateNewCharacter()? That should all be kept together. Where would I do this? I dont know what to move and what to leave. And saving only a character's name won't be at all useful to you, nor should SaveCharacter really require an argument if src.name is going to be correct. (It isn't, in the current code, but that's because of the code's other flaws.) So tell me what i have to do here. Lummox JR |
A few horrible problems you have in there: You're using usr in Login(), which normally wouldn't be a big deal because it's semi-valid there, but src is always the correct choice. You're also using the : operator all over, which is just plain sloppy code. What's worse, you're using the : operator in some places because you put in usr instead of src, and usr is (as far as DM's concerned) just a regular /mob. So change usr to src there, and get rid of any src. or src: parts that are left over.
In fact for safety's sake, and consistency's sake, put src into all your input() procs too, as the first argument (before the prompt asking what the player wants). This should be done in CreateNewCharacter() as well.
But you have other problems. Why is most of the character creation code actually in Login() instead of CreateNewCharacter()? That should all be kept together. And saving only a character's name won't be at all useful to you, nor should SaveCharacter really require an argument if src.name is going to be correct. (It isn't, in the current code, but that's because of the code's other flaws.)
Lummox JR