ID:170492
 
Error:

runtime error: type mismatch
proc name: DblClick (/mob/Human_Master/DblClick)
source file: npc.dm,15
usr: Plague (/mob/Human)
src: Human Master (/mob/Human_Master)
call stack:
Human Master (/mob/Human_Master): DblClick(Dragonball - Journey of Power (83,8,1) (/turf/grass))

Coding:

mob
Human_Master
icon = 'npc.dmi'
icon_state = "humandojo"
npc = 1
DblClick()
if(!usr.dojo)
alert("Welcome to the Dojo.")
alert("In order to leave this Dojo you must complete certain tasks to become a warrior with a Novice fighting style.")
alert("First, let me test your ki level and determine your Center of Gravity.")
usr.SetCGrav()
alert("Now that I have determined your Center of Gravity, go and begin to train and become a great warrior. Come back to me when you think you have reached your limit.")
usr.dojo = 1
else
if(usr.powerlevel < 10)
alert("You are still not strong enough to leave this island. Come back soon though.")
else
alert("Ahh, my son you have finally reached the limit of my training. Here, enjoy your new fighting style.")
usr.style = "Novice"
alert("Oh yea, you might want to learn a little bit about your fighting style.")
alert("Your fighting style determines how you attack and also increases your damage.")
alert("This style was fairly easy to acquire, but the next styles will not be as easy.")
alert("Good luck my young warrior!")


Any idea here?
Well, looking in our Runtime Error Ref (Thanks to Crispy), we look for the type mismatch error:

"You tried to perform a mathematic operation that doesn't make sense. For example, addition involving a number and a text string, or any other two var types that don't mix easily. (Hint: Use num2text() and text2num() to convert between numbers and text.)

Another possible cause of a type mismatch error is that you tried to add something to a list, but the list wasn't actually created. See "Cannot read null.Find()" below for ways to properly define a list."

Well, this has nothing to do with lists, so the only thing that could possibly be wrong here is

if(usr.powerlevel < 10)


Therefore, usr.powerlevel is probably some sort of text value. The truth is, depending on your game, mob.powerlevel should probably be a numerical variable, and not a text one.

Of course, there's the obvious design error to repair, but if you must keep mob.powerlevel as a text variable (Not Recommended!), then use text2num():

mob
Human_Master
icon = 'npc.dmi'
icon_state = "humandojo"
npc = 1
DblClick()
if(!usr.dojo)
alert("Welcome to the Dojo.")
alert("In order to leave this Dojo you must complete certain tasks to become a warrior with a Novice fighting style.")
alert("First, let me test your ki level and determine your Center of Gravity.")
usr.SetCGrav()
alert("Now that I have determined your Center of Gravity, go and begin to train and become a great warrior. Come back to me when you think you have reached your limit.")
usr.dojo = 1
else
if(text2num(usr.powerlevel) < 10)
alert("You are still not strong enough to leave this island. Come back soon though.")
else
alert("Ahh, my son you have finally reached the limit of my training. Here, enjoy your new fighting style.")
usr.style = "Novice"
alert("Oh yea, you might want to learn a little bit about your fighting style.")
alert("Your fighting style determines how you attack and also increases your damage.")
alert("This style was fairly easy to acquire, but the next styles will not be as easy.")
alert("Good luck my young warrior!")


In the future, please don't make a completely new topic for things like this. This is merely a continuation of your previous problem, so it should therefore be in the previous problem's thread.
In response to Wizkidd0123
Thanks Wizz. You've been alot of help.
In response to Wizkidd0123
I think usr.powerlevel is probably null in this case, which would cause the same error.

Instead of using text2num(), which will merely mask this error and not fix another potential one, I'd make sure powerlevel is being initialized correctly. Probably it's something like this:

var/powerlevel


...when it should in fact look more like this:

var/powerlevel = 0


If the var is always meant to be a number, it should be initialized with a number.

Lummox JR