Basically I'm building a countdown timer in LUA, getting the data from webparser, and then updating the skin with the information I want already formated. This may seem like an arse-backwarse way to do it, but I took this challenge on so I could learn a bit of LUA.
I've run the LUA through LUAforWindows to debug it (changing the webparser output in sOrigA, sOrigB, and sOrigC to the actual values returned by webparser), and it works fine. My assumption is that something is happening to the webparser output when the LUA script tries to read it.
The error I'm getting is:
Code: Select all
Script: DragonTime.lua:83: attempt to index local 'str' (a nil value)
The MPrint1, 2, and 3 meters are there for testing purposes, so I could see exactly what the webparser was spitting out.
DragonTime.ini
Code: Select all
[Rainmeter]
Author=methos237 (James Polk)
Update=1000
Debug=1
[Variables]
;==========![ Server needs to match the way it appears on the GuildWarsTemple URL ]!============================
;==========![ If your server name has multiple words and/or apostrophies (i.e. Ferguson's Crossing) ]!==========
;==========![ Make sure you omit (leave out) the apostrophies and replace the spaces with a minus sign (-) ]!===
;==========![ For Example: Ferguson's Crossing becomes fergusons-crossing]!=====================================
server=jade-quarry
[Metadata]
Name=GW2 Timers - DragonTime
Version=1.0
; Webparse ===============
[mGetTimer]
Measure=Plugin
Plugin=Plugins\WebParser.dll
RegExp="(?siU)zxcInfo\((.*)\);.*zxcInfo\((.*)\);.*zxcInfo\((.*)\);.*"
URL="http://guildwarstemple.com/dragontimer/#server#/"
UpdateDivider=3600
UpdateRate=1
Debug=1
[mDragonTime1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetTimer]
StringIndex=1
[mDragonTime2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetTimer]
StringIndex=2
[mDragonTime3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetTimer]
StringIndex=3
; LUA call ===============
[mLuaTimer]
Measure=script
ScriptFile="#CURRENTPATH#DragonTime.lua"
UpdateDivider=1
; Display the data ===============
[MPrint1]
Meter=STRING
MeasureName=mDragonTime1
MeterStyle=sText
Y=15
Text=%1
SolidColor=0,0,0,1
[MPrint2]
Meter=STRING
MeasureName=mDragonTime2
MeterStyle=sText
Y=15R
Text=%1
SolidColor=0,0,0,1
[MPrint3]
Meter=STRING
MeasureName=mDragonTime3
MeterStyle=sText
Y=15R
Text=%1
SolidColor=0,0,0,1
[MLuaPrint1]
Meter=String
MeterStyle=sText
ClipString=0
Y=30R
[MLuaPrint2]
Meter=String
MeterStyle=sText
ClipString=0
Y=15R
[MLuaPrint3]
Meter=String
MeterStyle=sText
ClipString=0
Y=15R
[sText]
FontSize=12
StringStyle=BOLD
StringAlign=LEFTCENTER
FontColor=0,0,0,255
W=1000
H=30
AntiAlias=1
[sText1]
FontSize=12
StringStyle=BOLD
StringAlign=RIGHT
FontColor=0,0,0,255
W=1000
H=30
AntiAlias=1
[sText2]
FontSize=12
StringStyle=BOLD
StringAlign=RIGHT
FontColor=#GREEN#
W=1000
H=30
AntiAlias=1
[sText1]
FontSize=12
StringStyle=BOLD
StringAlign=RIGHT
FontColor=#RED#
W=1000
H=30
AntiAlias=1
DragonTime.lua
Code: Select all
function initialize()
sOrigA=SKIN:GetMeasure('mDragonTime1')
sOrigB=SKIN:GetMeasure('mDragonTime2')
sOrigC=SKIN:GetMeasure('mDragonTime3')
end
function Update()
d1 = sParse(1)
d2 = sParse(2)
d3 = sParse(3)
--assert(type(sOrigA)=='string','Rut-Roh Raggy! Didn\'t get data from the website (Make sure you typed the server name right in DragonTime.ini - Line:12')
SKIN:Bang('[!SetOption MLuaPrint1 Text \"'..tostring(d1[1])..'\"][!SetOption MLuaPrint1 MeterStyle '..tostring(d1[3])..']')
SKIN:Bang('[!SetOption MLuaPrint2 Text \"'..tostring(d2[1])..'\"][!SetOption MLuaPrint1 MeterStyle '..tostring(d2[3])..']')
SKIN:Bang('[!SetOption MLuaPrint3 Text \"'..tostring(d3[1])..'\"][!SetOption MLuaPrint1 MeterStyle '..tostring(d3[3])..']')
SKIN:Bang('[!SetVariable msg1 \"'..tostring(d1[2])..'\"][!SetVariable msg2 \"'..tostring(d2[2])..'\"][!SetVariable msg3 \"'..tostring(d3[2])..'\"]')
return ("Success")
end
function sParse(tID)
tA=sSplit(sOrigA,",")
tB=sSplit(sOrigB,",")
tC=sSplit(sOrigC,",")
if tID==1 then
tData=tA
elseif tID==2 then
tData=tB
elseif tID==3 then
tData=tC
else
print(sCurrentConfig..' Returned an Error at sDragonParse')
end
local secs,opening,respawn,mess1,mess2,mess3=tData[2],tData[3],tData[4],tData[5],tData[6],tData[7]
if tonumber(secs) <0 then
i=math.abs(secs)+1
else i=secs-1 end
iHR = math.floor(i % 3600)
iH = math.floor(i / 3600)
iM = math.floor(iHR / 60)
iS = math.floor(i % 60)
if tonumber(secs) > 0 then
sMsg = mess1
sStyle = sText1
elseif tonumber(secs) + tonumber(opening) > 0 then
sMsg = mess2
sStyle = sText2
else
sMsg = mess3
sStyle = sText3
end
if tonumber(secs) <0 then
if iH ~= 0 then
str = string.format("-%01d : %02d : %02d", iH, iM, iS)
else str = string.format("-%02d : %02d", iM, iS)
end
else if iH ~= 0 then
str = string.format("%01d : %02d : %02d", iH, iM, iS)
else str = string.format("%02d : %02d", iM, iS)
end
end
local t={str, sMsg, sStyle}
return t
end
function sSplit(str,delimiter)
str = str:gsub("(%,%s)",","):gsub("%'", ""):gsub("Event%(s%) Outdated", "Events Outdated,")
assert(type(str)=="string","bad argument #1 to 'split' (string expected, got "..type(str))
assert(type(delimiter)=="string","bad argument #2 to 'split' (string expected, got "..type(delimiter))
local t = {}
for m in str:gmatch("(.-)%"..delimiter) do
table.insert(t,m)
end
return t
end