I'm trying to change my scripts over to Lua from VBscript and I'm running into some complications. I keep getting an error saying that I'm trying to do math on a nil value.
If someone could help me out here it would be much appreciated.
function conv(number)
a = string.gsub(number, ",", "")
return a
end
function DoInfobar ()
CurGLV = tonumber(GetVariable("CurGLV"))
CurELV = tonumber(GetVariable("CurELV"))
HPcur = tonumber(GetVariable("HPcur"))
HPmax = tonumber(GetVariable("HPmax"))
CurEScore = tonumber(conv(GetVariable("CurEScore")))
CurPXP = string.gsub(GetVariable ("CurPXP"),",","")
CurGXP = string.gsub(GetVariable("CurGXP"),",","")
kills = tonumber(GetVariable("worthies"))
Money = tonumber(GetVariable ("Money"))
Scales = GetVariable("Scales")
Hunger = GetVariable("Hunger")
CurAlign = GetVariable("CurAlign")
Totalneeded = 100
a = 2
b = 500000
for i = 1, 37, 1 do
b = (a * 250000) + b
a = a + (i - 1)
c = (a * 250000)
if i == CurELV then
Elastlv = b
ETotalneeded = c
break
end --If
end -- for
CurEScore = tonumber(CurEScore) - tonumber(ELastlv)
alignments = {
W = { str = "white lord", color = "red" },
P = { str = "paladin", color = "red" },
C = { str = "crusader", color = "gold" },
G = { str = "good", color = "green" },
H = { str = "honorable", color = "green" },
N = { str = "neutral", color = "lime" },
M = { str = "malicious", color = "green" },
E = { str = "evil", color = "green" },
I = { str = "infamous", color = "gold" },
B = { str = "black knight", color = "red" },
L = { str = "lord of evil", color = "red" },
}
table.foreach (alignments,
function (k, v)
if alignments.str == CurAlign then
InfoColour (alignments.color)
end --if
end -- function
)
InfoClear ()
InfoBackground ("white")
InfoFont ("Arial", 12, 1)
InfoColour ("purple")
Info (GetInfo (2))
InfoColour ("black")
Info (" Dragon Grade: ")
InfoColour ("blue")
Info (CurGLV)
InfoColour ("blue")
Info (" E")
InfoColour ("blue")
Info (CurELV)
DoGauge(" HP: ", HPcur, HPmax, "darkgreen", "red")
DoGauge(" GXP: ", CurGXP, Totalneeded, "blue", "blue")
DoGauge(" EXP: ", CurEScore, ETotalneeded, "blue", "blue")
InfoColour ("black")
Info (" ALIGN: ")
Info (CurAlign)
InfoColour ("black")
Info (" Kills: ")
InfoColour ("green")
Info (kills)
end -- doinfobar
If someone could help me out here it would be much appreciated.