ID:139938
 
Hello, Once again. So i finally got around to fixing up the "mob/player" system and ive come across a couple of errors now. so i tried the usual changing of the path of the things and what not to no success. so i changed more and still failed so my next resort was to forum search, not sure if i just suck at searching or not but i couldnt find anything that could help.

So anyways.

My code currently is (anything related to the problem(i think))

Code: Changing proc
//This is ran after the verb is clicked and creates grids for hair styles etc. and this is an offspring off the "decent game design by Lummox"
CreationChangeProc() //execute on click of new character button to move the clients windows to the creation screen.
client/proc
winset(usr, null, {"
window_default.child_left.left = "main_creation";
window_default.can-resize = "false";
window_default.statusbar = "true";
window_default.titlebar = "true";
window_default.macro = "null";
window_default.menu = "null";
"}
)
src.verbs -= typesof(/Start/GameStart/verb)
src.verbs += typesof(/Start/GameCreate/verb)

usr.BuildHairGrid()
usr.BuildSkinGrid()
usr.BuildHairColourGrid()
usr.BuildEyeGrid()
//usr.Preview() //currently does not output to grid for w.e reason (worked before implementing the mob/player etc


Code: The trouble maker i think
Start/GameStart
verb
NewCharacter() //execute for new char
var/mob/newchar
switch(alert("Please choose slot to play in","Character Creation","Slot One","Cancel","Slot Two"))
if("Slot One")
newchar = new/mob/human/player(locate(3,3,2)) //Tried not having this but i cant get the "slots" to save unless i use it -shrug-
newchar.slot = 1
newchar.created = 0
usr.client.CreationChangeProc() //This is giving me the problems
usr.client.mob = newchar //alongside this...

if("Slot Two")
newchar = new/mob/human/player(locate(3,3,2))
newchar.slot = 2
usr.client.CreationChangeProc()
usr.client.mob = newchar
if("Cancel")
return


Problem description: the code above works fine atleast i think it does, i could be easily proven wrong. The problem is that if i switch the command that transfers the values with the one that swaps the screen i get
runtime error: Cannot execute null.CreationChangeProc().
proc name: NewCharacter (/Start/GameStart/verb/NewCharacter)
source file: A. Login.dm,68
usr: Midgetbuster (/mob/logincharacter)
src: Midgetbuster (/client)
call stack:
Midgetbuster (/client): NewCharacter()


And i think if i can get it to work the way i want it to ill be able to launch another grid builder (noted by the //preview in changer proc) which is currently failing to build unless ran separately.

The error you posted is not a result of the code you posted, but rather something else you've tried. Namely, it would result from switching the client.mob=newmob and usr.client.CreationChangeProc() lines around. Regardless, the issue is your abuse of usr. In your CreationChangeProc(), you should be using the mob variable instead.
In response to Garthor
I know thats what causes the problem i already stated that.

"The problem is that if i switch the command that transfers the values(meaning client.mob) with the one that swaps the screen i get (meaning the change proc)"

And maybe you can alleviate on the rest of your message?
In response to Midgetbuster
"Alleviate" does not mean what you think it means.

Anyway, you need to stop using usr. Your problem is caused by using usr. The solution is to use something besides usr. The proper variable to use is mob, in the client/CreationChangeProc() proc.
In response to Garthor
Sorry. it was right in front of me.. Sorry for making you retype that.

Anyways, So im just stuck with the order in which i currently have my commands launching?

Changer first then setting the redefined vars? or is there a way for me to switch the order because my preview proc just uses a simply src << output(src,"grid") method and wont launch properly when doing the changer due to the mob being changed mid way or something.
In response to Midgetbuster
The mob isn't being changed "mid way". It's being changed precisely where you change it.

I'd suggest changing the mob BEFORE you start fiddling with settings for the player, because then you can just use client.mob. If you insist on doing it in the other order, you're going to need to pass the new mob as an argument to the proc and use that instead.
In response to Garthor
only reason i wanted to do it in the other order is because having the way it is now doesn't launch the preview proc while executing the create screen thing.

So i figured if the clients mob was changed before the launching of the screen changer it would work but heh iunno
In response to Midgetbuster
Midgetbuster wrote:
only reason i wanted to do it in the other order is because having the way it is now doesn't launch the preview proc while executing the create screen thing.

So i figured if the clients mob was changed before the launching of the screen changer it would work but heh iunno

I have no idea what you're talking about here, but a random guess is that you're abusing usr even more elsewhere and it's biting you in the ass. Again.
In response to Garthor
nah, thats the only place with usr abuse since i didnt know about that "mob" variable thing.

Im under the impression that usr abuse comes from the use of usr under procs (atleast i hope so cause thats what im basing it off lol)

but if you look up at the codes above its meant to also launch

mob/proc/Preview()
src << output(src, "grid_preview:2,2")


which simply creates a preview of the user
In response to Midgetbuster
Lines which are commented out rarely do anything.
In response to Garthor
it was commented out cause it wasnt doing anything :p.

Prolly should of removed those =\ before posting the code lol

EDIT: Thanks for pointing out my usr abuse that was appreciated, Anyways problem resolved fiddled with some other stuff and got it working properly now :)