ID:139313
 
Code:
proc/Update()// NOTE: this is the only part of the code made by Spuzzum, I would change it but I see no point in doing this.
// NOTE: it also has the original commenting from Spuzzum.
if(num < 0) //if the meter is negative
num = 0 //set it to zero
else if(num > width) //if the meter is over 100%
num = width //set it to 100%
src.icon_state = "[round(src.num)]" // this sets the icon state of the meter to its rounded off number


Problem description: When i compile my source there are no errors or warnings but when i play the game and i lvl up i get the warning:
runtime error: type mismatch: 13.5 - Guest-629030247 (/mob/players/Monk)
proc name: Update (/mob/players/proc/Update)
source file: Basics.dm,897
usr: Guest-629030247 (/mob/players/Monk)
src: Guest-629030247 (/mob/players/Monk)
call stack:
Guest-629030247 (/mob/players/Monk): Update(Guest-629030247 (/mob/players/Monk))
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()
Guest-629030247 (/mob/players/Monk): Stat()


My guess is you're storing one of those variables as a string rather than a number.
In response to SuperAntx (#1)
Could you explain me what you mean with that?? im kinda new to coding and im trying to learn from my mistakes.

In response to Chaokai (#2)
Type mismatch means you're comparing different types. Comparing the number 1 to the text string "1" is probably what you're doing.

You could avoid the error by making sure both the num and width variables are stored as actual numbers, not text strings.
In response to SuperAntx (#3)
Thank you for the answer, now i understand type mismatch the error wasnt in the update proc but in another proc i found.

Thank you very much!
In response to Chaokai (#4)
Damn i thought i fixed it but still not ill show you some more of the code:

obj
var/num = 0 // current unrounded icon_state number
var/width
xmeter1 // hud mana meter
name = "XP"
icon = 'xpglobe.dmi'
screen_loc = "3,1"
icon_state = "0"
layer = MOB_LAYER+10
width = 16
var/counter = 1
Click() // haha. just like above, but on the exp meter
if(counter==1)
overlays += /obj/overlay/stone
if(counter==2)
overlays -= /obj/overlay/stone
overlays += /obj/overlay/woodsy
if(counter==3)
overlays -= /obj/overlay/woodsy
overlays += /obj/overlay/fancy
if(counter==4)
overlays -= /obj/overlay/fancy
counter++
if(counter>4)
counter=1
proc/Update()// NOTE: this is the only part of the code made by Spuzzum, I would change it but I see no point in doing this.
// NOTE: it also has the original commenting from Spuzzum.
if(num < 0) //if the meter is negative
num = 0 //set it to zero
else if(num > width) //if the meter is over 100%
num = width //set it to 100%
src.icon_state = "[round(src.num)]" // this sets the icon state of the meter to its rounded off number


mob/players
proc
Update(mob/M as mob) // calculations for the meters' visuals
for(var/obj/meter1/N in M.client.screen)
N.num = (src.HP/src.MAXHP)*N.width
N.Update()
for(var/obj/mmeter1/MM in M.client.screen)
MM.num = (src.MP/src.MAXMP)*MM.width
MM.Update()
for(var/obj/xmeter1/MM in M.client.screen)
MM.num = (src.exp-src.oldexp)/(src.expneeded-src.oldexp)*MM.width
MM.Update()


Maybe you can see whats wrong or should be edited??
What do you get when you subtract yourself from 13.5?

A runtime error.
In response to Chaokai (#5)
You have set oldexp to an invalid value (the player) at some point.

In the future, it's helpful if you go to the exact line of the error, rather than posting the wrong proc entirely.
In response to Garthor (#7)
hmm i know what you mean but i dont know how i can change it. The guy who coded this doesnt come online anymore for like a year :p do you have any tips in what kind of code i should change it?

sorry if im askin to much but i really want this fixed.

Greetings chaokai
In response to Chaokai (#8)
I'd suggest looking for anywhere you are assigning a value to the oldexp variable (anywhere with "oldexp=" or "oldexp =" probably) and look through the block of code to see what it is, exactly, you are assigning it. If you are assigning it a mob, then make it not do that.