This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ebernerd's profile picture

Having Problems with Paintutils.DrawFilledBox()

Started by ebernerd, 24 May 2015 - 01:05 AM
ebernerd #1
Posted 24 May 2015 - 03:05 AM
So, I'm trying to make it autocreate buttons. Basically, you tell it where, what colors, and what to say, and it will fill in the rest. Here's the code.


local function button(text,x,y,bgcolor,textcolor)
paintutils.drawFilledBox(x,y,#text+4,y+2,bgcolor)
s.bg(bgcolor)
term.setCursorPos(x+1,y+1)
s.text(textcolor)
write(text)
end

For some reason or another, the first one it makes works fine, the second one is wrong, and the third is even more wrong. Screenie:
Spoiler

The first one works just fine. The second doesn't draw the box right, and the third no box at all. Can someone tell me why this happens?

Thank you!
Bomb Bloke #2
Posted 24 May 2015 - 03:31 AM
All parameters for drawFilledBox are absolute. You're wanting something like:

paintutils.drawFilledBox(x,y,#text+3+x,y+2,bgcolor)
ebernerd #3
Posted 24 May 2015 - 03:32 AM
Thank you Bomb Bloke!