But since this is an lua specific questions i thought it best to ask here.
I am having trouble with reading the file that i want to create. I thought to read the file the create a variable that i can use that follows a typesale.target from this file.
function Initialize()
sFileName = SELF:GetOption('FileName')
end -->Initialize
function Update()
hFile = io.open(sFileName)
if not hFile then print('File error'); return 'File error'; end
io.close(hFile)
sale = {}
for lines in io.lines(FileName)
table.insert(lines, sale)
Need something here to create typesale.target typesale.actual
end
return (#sale)
end -->Update
But the more i try this way the more i find myself in a corner. Is there a better way to do this.
What i want to do with the end result is use the numbers in a bargraph meter that will show progress of the sales area. i hope this makes sense.
function Initialize()
sFileName = SELF:GetOption('FileName')
end -- Initialize
function Update()
hFile = io.open(sFileName)
if not io.type(hFile)=='file' then
print('File error')
return 'File error'
else
sale = {}
local text=io.read('*all')
io.close(hFile)
for tag,contents in string.gmatch(text,'<([^%s>]+)(.-)%/>') do
sale[string.lower(tag)]=Keys(contents,{target=0,actual=0,projected=0})
end
end
return #sale
end -- Update
function Keys(a,b) -- Converts Key="Value" sets to a table
local tbl=b or {}
string.gsub(a,'(%a+)=(%b"")',function(c,d)
local strip=string.match(d,'"(.+)"')
tbl[string.lower(c)]=tonumber(strip) or strip
end)
return tbl
end -- Keys
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
function Initialize()
sFileName = SELF:GetOption('FileName')
end -- Initialize
function Update()
hFile = io.open(sFileName)
if not io.type(hFile)=='file' then
print('File error')
return 'File error'
else
sale = {}
local text=io.read('*all')
io.close(hFile)
for tag,contents in string.gmatch(text,'<([^%s>]+)(.-)%/>') do
sale[string.lower(tag)]=Keys(contents,{target=0,actual=0,projected=0})
end
end
return #sale
end -- Update
function Keys(a,b) -- Converts Key="Value" sets to a table
local tbl=b or {}
string.gsub(a,'(%a+)=(%b"")',function(c,d)
local strip=string.match(d,'"(.+)"')
tbl[string.lower(c)]=tonumber(strip) or strip
end)
return tbl
end -- Keys
No i think that will work for me perfectly... Do you no that will return the numbers in a variable form correct so machinessales.target=100000 right
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .