ID:262709
 
Code:
world/New()
..()
spawn()
exam()
Levelup()

mob/var/level=0
world/New()
Levelup()

proc
Levelup()
if(usr.taijutsu >=30| usr.genjutsu >= 30 || usr.ninjutsu >= 30)
usr.level=1
usr << "<b>You are Level [usr.level] now!</b>"


Problem description:I get a runtime error then the game closes -_- i dont know why

First off, from what I see, you're calling that level up proc twice with world/New(). That does not look needed. What i've learned is that you should keep what is loaded when you first enter the game to only want is needed if you want to reduce lag.

Secondly, you are using usr in a proc, which is not needed. You should use src, which is the default for some things. Also, I honestly don't know what the | operator is for, I have never needed to use it. The help menu description is not very helpful for it.

For full debugging, we would need to see your spawn and exam procs as well, but this what I say would make it work better as of now:

world/New()// We're you going for this, or client/New()?
..()
spawn()
exam()
Levelup()

mob/var
level=0//This is better if you have a lot of mob vars, easier to list them.

proc
Levelup()
if(taijutsu >=30 || genjutsu >= 30 || ninjutsu >= 30)
level=1//Do you want this, or level++?
src<<"<b>You are level [src.level]!</b>"

In response to Justin Knight
=_= that did nothing but give me errors, this is what i have now.
mob/var/level=0
mob/New()
Levelup(src)
proc
Levelup(mob/M)
if(M.taijutsu >=30 && M.genjutsu >= 30 && M.ninjutsu >= 30)
M.level=1//Do you want this, or level++?
M<<"<b>You are level [M.level]!</b>"
In response to Kurosaki_Ichigo-San
It probably gave you errors because it's supposed to be mob/proc. I won't help you any more than that though, because you copied and pasted exactly what I showed you.

All that tells me is that you are an inexperienced coder that doesn't even take the time out to correct his own code, but copy and paste someone elses, commenting and all. Code problems is for coding help not "hey hey I got a problem ..." " ... here's what might be wrong" "dude I copied and pasted and it didn't work, give me better code to copy and paste because I don't want to learn how to code, I just want to copy other people's work."
In response to Justin Knight
wtf are you talkin about, i did edit it >_>
In response to Kurosaki_Ichigo-San
Kurosaki_Ichigo-San wrote:
proc
Levelup(mob/M)
if(M.taijutsu >=30 && M.genjutsu >= 30 && M.ninjutsu >= 30)
M.level=1//Do you want this, or level++?
M<<"<b>You are level [M.level]!</b>"


Wrong. M belongs here no more than usr did. You do not need M at all in this proc. Levelup() affects only one mob: src. You already know src. Need you no M.

Lummox JR
In response to Lummox JR
so just replace the M with src? I did and i get this runtime error >_>

runtime error: Cannot execute null.Find().
proc name: New (/client/New)
usr: null
src: Kurosaki_Ichigo-San (/client)
call stack:
Kurosaki_Ichigo-San (/client): New()
Kurosaki_Ichigo-San (/client): New()
runtime error: Cannot read null.name
proc name: SaveMob (/client/proc/SaveMob)
usr: null
src: Kurosaki_Ichigo-San (/client)
call stack:
Kurosaki_Ichigo-San (/client): SaveMob()
Kurosaki_Ichigo-San (/client): Del()
In response to Kurosaki_Ichigo-San
Kurosaki_Ichigo-San wrote:
so just replace the M with src? I did and i get this runtime error >_>

runtime error: Cannot execute null.Find().
proc name: New (/client/New)

That's not exactly in Levelup(), now, is it?

I said change M to src in that proc. I said this proc does not need M. Why in the world would I be referring to all your code?

Lummox JR
In response to Lummox JR
Lummox i have to thank you for one of your word doc's called "Code Red" cause that helped me fix it =) But now the system doesnt level me up lol when i get those stats.
In response to Kurosaki_Ichigo-San
I made a small little demo for you:
mob/var
level=1
exp=0
var/list/level_reqs = list(1=30,2=60,3=120)
mob/proc/LevelUp()
if(exp>=level_reqs[level])
level++
src << "Your level is now [level]."
mob/verb/Increase_Exp()
exp+=10
LevelUp()
mob/Stat()
statpanel("Stats")
stat("Level:",level)
stat("Exp:",exp)

Run that in it's own evironment. Focus on the LevelUp() proc, and how the list works. Also, when stats change you have to call the LevelUp() proc.

Hiead
In response to Hiead
Using an associative list for a level system is a truly heinous idea. Level systems should be extensible, which this method isn't. Experience needed should always be calculated from a formula.

Lummox JR
In response to Lummox JR
The basis behind using something like 1=30 as opposed to simply using 30 came from the thought that, if this were used for many levels, it's easier to see where you're at when you can see like "for level 50, you need x amount of exp," as opposed to "you need x amount of exp, but let me count to see what level I'm adjusting."

I agree that a formula should be used, but I wanted to provide a working system along the basis that Kurosaki was trying to do.

Hiead
In response to Hiead
Hiead wrote:
The basis behind using something like 1=30 as opposed to simply using 30 came from the thought that, if this were used for many levels, it's easier to see where you're at when you can see like "for level 50, you need x amount of exp," as opposed to "you need x amount of exp, but let me count to see what level I'm adjusting."

Count? No idea what you're on about there. Why would any kind of iterative operation be involved? It's a simple levelup proc. You run level through a formula, you get an experience threshold.

It's obvious (rather, it should be obvious) that using a formula gives you the information you need, and for all levels. If you want that to be clearer in the code, you can always put in comments to show some examples.

I agree that a formula should be used, but I wanted to provide a working system along the basis that Kurosaki was trying to do.

But using an associative list is totally bogus here. It's not a working system; it's merely a system that works up to level 3. You could hard-code extensions, but eventually you'd always run out of levels. Why not do it right the first time?