Changes

Jump to navigation Jump to search
1 byte removed ,  10:47, 28 March 2013
m
no edit summary
If you want to format your numbers to make the table easier to understand, you could use the Lua <code>string.format</code> function, e.g.
<precode><codepre>
price = string.format("%08d", price)
</codepre></precode>
which will left-pad your price with 0s.
Another easy thing is string manipulation (OK, the example is very silly, but you see what is meant):
<precode><codepre>
function xml.functions.model(t)
model_name = xml.text(t, "./")
context.eTD()
end
</codepre></precode>
But where Lua really shines is when it comes to constructions such as loops and conditionals. Here is an easy example for a conditional:
<precode><codepre>
local price = tonumber(xml.text(t, "./"))
context.bTD()
context(price)
end
</codepre></precode>
Have fun finding more ways to do interesting things with Lua and xml!
--[[User:Thomas|Thomas]] 09:35, 28 March 2013 (CET)
gardener
111

edits

Navigation menu