ID:177122
 
I am making my own game from scratch. I have the login code made, but for some reason when it goes to modify the game values, the game considers them to be constant and does not edit them. Help?
Ryuo
Ryuo wrote:
I am making my own game from scratch. I have the login code made, but for some reason when it goes to modify the game values, the game considers them to be constant and does not edit them. Help?

This is certainly a problem in your code; however unless you post the Login() code and anything relevant to it, there's little anyone can do but shrug.

Lummox JR
In response to Lummox JR
Login code is:
world
mob = /mob/Creating_Character
name = "Dragon Warrior"
view = 6
version = 1
turf = /turf/water/
mob
Creating_Character
base_save_allowed = 0
Login()
spawn()
src.CreateCharacter()
proc
CreateCharacter()
var/mob/New_Mob = /mob/PC
var/nametmp = input("What is your name?","Name",src.key)
New_Mob.name = nametmp
New_Mob.class = input("Select a class for your character.", "Your Class") in list("Hero","Soldier","Wizard","Pilgrim","Slime")
New_Mob.Exp = 0
New_Mob.Level = 1
New_Mob.Gold = 50
New_Mob.GoldPenalty = 0
New_Mob.SpellBook = new/list()
New_Mob.SpellBook += "None"
switch(New_Mob.class)
if("Hero")
New_Mob.icon = 'hero.dmi'
New_Mob.icon_state = input("Select your icon.","Icons") in list("dw1nese","dw1nesue","dw1snes","dw1gbce","dw2nes","dw2g bc","dw3nes","dw3gbcm","dw3gbcf","dw4nesm","dw4nesf")
New_Mob.Hp = 14
New_Mob.HpMax = 14
New_Mob.Mp = 0
New_Mob.MpMax = 0
New_Mob.STR = 8
New_Mob.AGI = 5
New_Mob.VIT = 8
New_Mob.INT = 4
New_Mob.LUCK = 5
if("Soldier")
New_Mob.icon = 'soldier.dmi'
New_Mob.icon_state = input("Select your icon.","Icons") in list("dw3nesm","dw3nesf","dw3gbcm","dw3gbcf","dw4nes")
New_Mob.Hp = 17
New_Mob.HpMax = 17
New_Mob.Mp = 0
New_Mob.MpMax = 0
New_Mob.STR = 9
New_Mob.AGI = 2
New_Mob.VIT = 9
New_Mob.INT = 2
New_Mob.LUCK = 3
if("Pilgrim")
New_Mob.icon = 'Pilgrim.dmi'
New_Mob.icon_state = input("Select your icon.","Icons") in list("dw2nes","dw2gbc","dw3nesm","dw3nesf","dw3gbcm","dw3gbc f","dw4cristo","dw4nara")
New_Mob.Hp = 9
New_Mob.HpMax = 9
New_Mob.Mp = 8
New_Mob.MpMax = 8
New_Mob.STR = 4
New_Mob.AGI = 5
New_Mob.VIT = 4
New_Mob.INT = 5
New_Mob.LUCK = 3
if("Wizard")
New_Mob.icon = 'wizard.dmi'
New_Mob.icon_state = input("Select your icon.","Icons") in list("dw2nes","dw2gbc","dw3nesm","dw3nesf","dw3gbcm","dw3gbc f","dw4brey","dw4mara")
New_Mob.Hp = 6
New_Mob.HpMax = 6
New_Mob.Mp = 12
New_Mob.MpMax = 12
New_Mob.STR = 2
New_Mob.AGI = 3
New_Mob.VIT = 2
New_Mob.INT = 9
New_Mob.LUCK = 4
if("Slime")
New_Mob.icon = 'slime.dmi'
New_Mob.icon_state = "slime"
New_Mob.Hp = 8
New_Mob.HpMax = 8
New_Mob.VIT = 5
New_Mob.STR = 4
New_Mob.AGI = 9
New_Mob.INT = 2
New_Mob.LUCK = 3
In response to Ryuo
You appear to have created the new mob just fine, but I don't see any point where the player actually switches over to using it.

Lummox JR
In response to Lummox JR
I beg to differ. I don't believe var/mob/VARNAME = /path is correct syntax. It defines a var but does not create a new mob. var/mob/*mobpath*/*varname* = new() should work. Of course, you also have to set src.client.mob to the new mob. Don't forget to override the Login() proc for the new mob (don't use ..() in it) or else you hit an infinite loop.
In response to Garthor
Garthor wrote:
I beg to differ. I don't believe var/mob/VARNAME = /path is correct syntax. It defines a var but does not create a new mob. var/mob/*mobpath*/*varname* = new() should work.

Ah. Good point. I didn't even notice that; I did notice that although he sets vars for the new mob, he never uses it.

Of course, you also have to set src.client.mob to the new mob.

Yep, that's the part I meant.

Don't forget to override the Login() proc for the new mob (don't use ..() in it) or else you hit an infinite loop.

This shouldn't be an issue because he overrode Login() for /mob/Creating_Character only.

Lummox JR
In response to Lummox JR
Ah, didn't notice that.
My code is as this:
mob
Creating_Character
base_save_allowed = 0
Login()
spawn()
src.CreateCharacter()
proc
CreateCharacter()
var/mob/PC
var/nametmp = input("What is your name?","Name",src.key)
PC.name = nametmp
PC.class = input("Select a class for your character.", "Your Class") in list("Hero","Soldier","Wizard","Pilgrim","Slime")
PC.Exp = 0
PC.Level = 1
PC.Gold = 50
PC.GoldPenalty = 0
PC.SpellBook = new/list()
PC.SpellBook += "None"
switch(PC.class)
if("Hero")
PC.icon = 'hero.dmi'
PC.icon_state = input("Select your icon.","Icons") in list("dw1nese","dw1nesue","dw1snes","dw1gbce","dw2nes","dw2g bc","dw3nes","dw3gbcm","dw3gbcf","dw4nesm","dw4nesf")
PC.Hp = 14
PC.HpMax = 14
PC.Mp = 0
PC.MpMax = 0
PC.STR = 8
PC.AGI = 5
PC.VIT = 8
PC.INT = 4
PC.LUCK = 5
if("Soldier")
PC.icon = 'soldier.dmi'
PC.icon_state = input("Select your icon.","Icons") in list("dw3nesm","dw3nesf","dw3gbcm","dw3gbcf","dw4nes")
PC.Hp = 17
PC.HpMax = 17
PC.Mp = 0
PC.MpMax = 0
PC.STR = 9
PC.AGI = 2
PC.VIT = 9
PC.INT = 2
PC.LUCK = 3
if("Pilgrim")
PC.icon = 'Pilgrim.dmi'
PC.icon_state = input("Select your icon.","Icons") in list("dw2nes","dw2gbc","dw3nesm","dw3nesf","dw3gbcm","dw3gbc f","dw4cristo","dw4nara")
PC.Hp = 9
PC.HpMax = 9
PC.Mp = 8
PC.MpMax = 8
PC.STR = 4
PC.AGI = 5
PC.VIT = 4
PC.INT = 5
PC.LUCK = 3
if("Wizard")
PC.icon = 'wizard.dmi'
PC.icon_state = input("Select your icon.","Icons") in list("dw2nes","dw2gbc","dw3nesm","dw3nesf","dw3gbcm","dw3gbc f","dw4brey","dw4mara")
PC.Hp = 6
PC.HpMax = 6
PC.Mp = 12
PC.MpMax = 12
PC.STR = 2
PC.AGI = 3
PC.VIT = 2
PC.INT = 9
PC.LUCK = 4
if("Slime")
PC.icon = 'slime.dmi'
PC.icon_state = "slime"
PC.Hp = 8
PC.HpMax = 8
PC.VIT = 5
PC.STR = 4
PC.AGI = 9
PC.INT = 2
PC.LUCK = 3
There is no errors when I compile, but I get this runtime error...
runtime error: Cannot modify null.name.
proc name: CreateCharacter (/mob/Creating_Character/proc/CreateCharacter)
source file: Dragon Warrior.dm,17
usr: Ryuo (/mob/Creating_Character)
src: Ryuo (/mob/Creating_Character)
call stack:
Ryuo (/mob/Creating_Character): CreateCharacter()
Ryuo (/mob/Creating_Character): Login()
These are more details. Help someone? I tried what you suggested, no luck. =/
In response to Ryuo
Ryuo wrote:
CreateCharacter()
var/mob/PC
var/nametmp = input("What is your name?","Name",src.key)
PC.name = nametmp
...
There is no errors when I compile, but I get this runtime error...
runtime error: Cannot modify null.name.

As Garthor told you, you haven't actually created any mob yet. Declaring var/mob/PC makes the var, but it doesn't make the mob; PC is equal to null when you first declare it. If you change the line to this, it will work:
var/mob/PC = new
However, at the end of your CreateCharacter() proc you're still missing the crucial line that will actually use this mob. I'm not going to show you that line, because it's in just about every other example of character creation code, and because you should have been able to figure it out from my post (and from Garthors) but you apparently didn't pay enough attention to either of them.

Lummox JR
In response to Lummox JR
Actually, since new is a proc, you have to use ()'s after it. var/mob/PC = new(). Otherwise, you'll get an undefined var message. Also, why define nametmp? Just set the name directly. You might also want to put "as text" after the input.
In response to Garthor
Actually, using new without the () is perfectly valid.
In response to tenkuu
Bah.
In response to Garthor
The only time you really need to use () around new is when using named arguments, example:

obj
New(location,owner)
loc = location
mob
verb
create()
new/obj(locate(1,1,1),usr)