Posted 14 December 2014 - 04:39 PM
Hey all, I'm having trouble with openperipheral glasses.
I need to draw text over an icon, but whenever I addText it goes behind the addIcon. It is drawn after the icon, as seen with the code, but it draws behind the icon.
for those who didn't run it, as seen when the computer draws the GUI, it draws the box in the back, the text in the middle, and the icon in the front.
I need to draw text over an icon, but whenever I addText it goes behind the addIcon. It is drawn after the icon, as seen with the code, but it draws behind the icon.
b = peripheral.wrap("right")
s = peripheral.wrap("left")
--print(s.listMethods())
posx = {2,23,40,57,74,91,108,125,142,159}
posy = {1,18,35,52}
tpos = {{2,4},{3,4},{4,4},{5,4},{6,4},{7,4},{8,4},{9,4},{10,4},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{2,2},{3,2},{4,2},{5,2},{6,2},{7,2},{8,2},{9,2},{10,2},{2,3},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{1,4},{1,3},{1,2},{1,1}}
x = s.getPlayerNames()
player = x[1]
data = s.getPlayerData(player)
b.clear()
b.addBox(0,0,177,70,0xc6c6c6)
for i = 1,4 do
b.addBox(2,(i*17)-16,16,16,0x8b8b8b)
end
for z = 1,9 do
for i = 1,4 do
b.addBox((z*17)+6,(i*17)-16,16,16,0x8b8b8b)
end
end
for f = 1,4 do
for i = 1,10 do
--b.addIcon(posx[i],posy[f],1,0)
end
end
b.addBox(23,51,152,1,0x3f3f3f)
for k,v in pairs(data.inventory) do
if v.qty ~= 0 then
--print(textutils.serialize(v))
b.addIcon(posx[tpos[k][1]],posy[tpos[k][2]],v.id,v.dmg)
if v.qty ~= 1 then
x = string.sub(v.qty,string.find(v.qty,"."))
b.addText((posx[tpos[k][1]]+20)-9*#x,posy[tpos[k][2]]+9,x)
end
end
end
its a short code, but does a good job of what I want. feel free to run it if you want, but I'd prefer to take credit for my work if anybody wants to use it.for those who didn't run it, as seen when the computer draws the GUI, it draws the box in the back, the text in the middle, and the icon in the front.