Posted 03 October 2014 - 10:35 PM
So, I'm trying to create a program like npaintpro, but my own version.
I've got the basics set up, but I can't work out how to do the bit where it changes the color of an actual pixel without a long and arduous routine.
Here's the code so far:
How am I being stupid, and how to fix it?
Thanks,
- Sam
I've got the basics set up, but I can't work out how to do the bit where it changes the color of an actual pixel without a long and arduous routine.
Here's the code so far:
y1x1=2
y2x1=2
y3x1=2
y4x1=2
y1x2=2
y2x2=2
y3x2=2
y4x2=2
y1x3=2
y2x3=2
y3x3=2
y4x3=2
y1x4=2
y2x4=2
y3x4=2
y4x4=2
x1 = {y1x1,y2x1,y3x1,y4x1}
x2 = {y1x2,y2x2,y3x2,y4x2}
x3 = {y1x3,y2x3,y3x3,y4x3}
x4 = {y1x4,y2x4,y3x4,y4x4}
term.setCursorPos(1,1)
paintutils.drawLine(1,17,2,17,colors.red)
paintutils.drawLine(3,17,4,17,colors.blue)
paintutils.drawLine(5,17,6,17,colors.green)
paintutils.drawLine(7,17,8,17,colors.yellow)
while true do
local event, but, x, y = os.pullEvent("mouse_click")
if but == 1 and x>=1 and x<=2 and y==17 then
color = 1
paintutils.drawLine(11,17,12,17,colors.red)
elseif but == 1 and x>=3 and x<=4 and y==17 then
color = 2
paintutils.drawLine(11,17,12,17,colors.blue)
elseif but == 1 and x>=5 and x<=6 and y==17 then
color = 3
paintutils.drawLine(11,17,12,17,colors.green)
elseif but == 1 and x>=7 and x<=8 and y==17 then
color = 4
paintutils.drawLine(11,17,12,17,colors.yellow)
elseif but == 1 and x>=9 and x<=10 and y==17 then
os.reboot()
else
if color == 1 then
color2 = "colors.red"
elseif color == 2 then
color2 = "colors.blue"
elseif color == 3 then
color2 = "colors.green"
elseif color == 4 then
color2 = "colors.yellow"
end
if but == 1 and x==1 and y==1 then --#The long and arduous part
y1x1 = color --#The long and arduous part
paintutils.drawPixel(x,y,color2) --#The long and arduous part
end
end
end
How am I being stupid, and how to fix it?
Thanks,
- Sam
Edited on 03 October 2014 - 08:36 PM