experience counter - I need help!

Posted by DanPrice on Thu 30 May 2002 02:49 PM — 4 posts, 18,299 views.

Australia #0
Iim trying to make an experience counter that just "counts" my experience. So, i made this trigger:

You receive * experience points.

and this calls this script:

Sub SCRExpCount (strName, strLine, aryWildcards)
dim newexp, exp
exp = world.GetVariable ("exp")
newexp = arywildcards(1)
exp = exp + newexp
world.setvariable "exp", exp
end sub

however, the number in the variable just 'melds' together, eg if i had 2500 as the variable and killed a mob that gives me 3500 it puts in 25003500
Im guessing this is as its treating it as a string, but i cant change this (because im not very good a coding :P). Can anyone help?
Canada #1

exp = CInt(exp) + CInt(NewExp)

The CINT function converts the value to an integer (number).
Canada #2
By the way, if you want to make this subroutine shorter, you could do this:

Sub SCRExpCount (strName, strLine, aryWildcards) 
  World.SetVariable "exp", CInt(World.GetVariable("exp")) + CInt(aryWildcards(1))
End Sub
#3
It's adding two strings, typecast them to integers