I'm working on an interface and want to create some items in runtime. I have a <div> which is the container, and I want to create the items inside that container. The markup would look similar to this:
- Code: Select all
<div id="container">
<div></div> <-- these are the elements I want to create
<div></div>
...
</div>
And this is the Lua script. I'm taking the elements from an array:
- Code: Select all
function ShowItems()
local strItem = 0
for i=1,total_items,1 do
strItem = "<div class=\"element\">"
strItem = strItem.."<div class=\"icon\">"
strItem = strItem.."<div class=\"thumb "..items[i]["image"].."\"></div>"
strItem = strItem.."</div>"
strItem = strItem.."<div class=\"amount\">"
strItem = strItem.."<div class=\"have\">"..items[i]["amount"].."</div>"
strItem = strItem.."</div>"
strItem = strItem.."</div>"
gui.setText( GUI_ID , "container", strItem )
end
end
The problem is that I only get one item in the screen, although in the console I get it printed several times (= total_items).
How can I create all the items?
Thanks in advance!