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

[Help] custom background colors

Started by AnDwHaT5, 23 February 2013 - 11:00 AM
AnDwHaT5 #1
Posted 23 February 2013 - 12:00 PM
Ok, so im trying to add a background which can be customized to my new OS by mouse_click event but idk how to change the original coding or red to say blue with one mouse click. I tried true statements I/O statements and i just don't know how to do it. Here is the code its to the desktop of FireBallOS.




term.setBackgroundColor(colors.red)
term.clear()
term.setCursorPos(1,1)
print(" --------		-------	   --------	[Fire]")
print("[ File   ]	  [ Shock ]	 [ Disk   ]   [Wolf]")
print("[ Browser]	  [Browser]	 [  namer ]")
print(" --------		-------	   --------	   ")
while true do
local event, button, X, Y = os.pullEvent("mouse_click")
XY = X..","..Y
local event, button, X, Y = os.pullEvent("mouse_click")
XY = X..","..Y
if XY == "1,1" then
shell.run("fb")
elseif XY == "2,1" then
shell.run("fb")
elseif XY == "3,1" then
shell.run("fb")
elseif XY == "4,1" then
shell.run("fb")
elseif XY == "5,1" or XY == "6,1" or XY == "7,1" or XY == "8,1" or XY == "9,1" or XY == "10,1" then
shell.run("fb")
elseif XY == "1,2" or XY == "2,2" or XY == "3,2" or XY == "4,2" or XY == "5,2" or XY == "6,2" or XY == "7,2" or XY == "8,2" or XY == "9,2" or XY == "10,2" then
shell.run("fb")
elseif XY == "1,3" or XY == "2,3" or XY == "3,3" or XY == "4,3" or XY == "5,3" or XY == "6,3" or XY == "7,3" or XY == "8,3" or XY == "9,3" or XY == "10,3" then
shell.run("fb")
elseif XY == "1,4" or XY == "2,4" or XY == "3,4" or XY == "4,4" or XY == "5,4" or XY == "6,4" or XY == "7,4" or XY == "8,4" or XY == "9,4" or XY == "10,4" then
shell.run("fb")
elseif XY == "17,1" or XY == "18,1" or XY == "19,1" or XY == "20,1" or XY == "21,1" or XY == "22,1" or XY == "23,1" or XY == "24,1" or XY == "25,1" or XY == "17,2" or XY == "18,2" or XY == "19,2" or XY == "20,2" or XY == "21,2" or XY == "22,2" or XY == "23,2" or XY == "24,2" or XY == "25,2" or XY == "17,3" or XY == "18,3" or XY == "19,3" or XY == "20,3" or XY == "21,3" or XY == "22,3" or XY == "23,3" or XY == "24,3" or XY == "25,3" or XY == "17,4" or XY == "18,4" or XY == "19,4" or XY == "20,4" or XY == "21,4" or XY == "22,4" or XY == "23,4" or XY == "24,4" or XY == "25,4" then
shell.run("shockbrowser")
shell.run("desktop")
end
end



I just want the background that can be changed green blue yellow grey red orange and purple. I just cant seem to do it…
AnDwHaT5 #2
Posted 23 February 2013 - 12:02 PM
Lol before anyone goes off this is bearly at beta stage so dont think im not adding more ok i still have alot to do the the desktop. ALOT
LBPHacker #3
Posted 23 February 2013 - 12:15 PM
You have to redraw the screen with the selected color. I'm not sure what do you exactly want, heck, I don't even know what does shell.run("fb") do - and don't say me that "It runs a program called fb".

So redraw the screen when the user changes the background color and you're done.

BTW I think "if X > 16 and X < 26 and Y < 5 then" is much shorter, more efficient and easier to understand than "if XY == "17,1" or XY == "18,1" or XY == "19,1" or XY == "20,1" or XY == "21,1" or XY == "22,1" or XY == "23,1" or XY == "24,1" or XY == "25,1" or XY == "17,2" or XY == "18,2" or XY == "19,2" or XY == "20,2" or XY == "21,2" or XY == "22,2" or XY == "23,2" or XY == "24,2" or XY == "25,2" or XY == "17,3" or XY == "18,3" or XY == "19,3" or XY == "20,3" or XY == "21,3" or XY == "22,3" or XY == "23,3" or XY == "24,3" or XY == "25,3" or XY == "17,4" or XY == "18,4" or XY == "19,4" or XY == "20,4" or XY == "21,4" or XY == "22,4" or XY == "23,4" or XY == "24,4" or XY == "25,4" then"
AnDwHaT5 #4
Posted 23 February 2013 - 12:20 PM
hahaha i didnt know how to do that but what do you mean by the selected color. I'm fairly new to the updated cc im better with tekkit. How would it help to redraw. Like is there a variable i can use for the color and then when activated it will change???
LBPHacker #5
Posted 23 February 2013 - 12:24 PM
Nope. I mean, when you select the color, redraw the screen with that. But try it again. How can the user change the color? With a separate menu or something like that? (BTW look at your PMs)