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

using advanced computers

Started by cmurtheepic, 20 November 2012 - 02:18 AM
cmurtheepic #1
Posted 20 November 2012 - 03:18 AM
help! i am a intermediate computercraft programmer. and i just got back into programming again and i want to learn how to use the advanced computer. (the basics) and or more advance uses (ways) like for instance typing, displaying, text or GUI, or UI in color
Kingdaro #2
Posted 20 November 2012 - 03:30 AM
Well the two main features of advanced computers are colors and mouse support. Here's an example that combines them both. It's relatively simple - chooses a random color from a list, and prints the user's x, y and mouse button when clicked.


local colorlist = {
  colors.red,
  colors.orange,
  colors.yellow,
  colors.green,
  colors.blue,
  colors.purple
}

while true do
  local _, button, mousex, mousey = os.pullEvent('mouse_click')
  local color = colorlist[math.random(1, #colorlist)]

  term.setTextColor(color)
  print(button..' at '..mousex..', '..mousey)
end

There's more information on color and mouse functions on the wiki.

http://computercraft.info/wiki/index.php?title=Term.setTextColor
http://computercraft.info/wiki/index.php?title=Term.setBackgroundColor
http://computercraft.info/wiki/index.php?title=Os.pullEvent
cmurtheepic #3
Posted 20 November 2012 - 09:15 AM
one thing that I really dont understand is, it seams to me that every other programmer i've seen or heard of knows just like how to work with anything new like peripherals to new tables and statements. please help me figure this out and i find out where they get their information :(/>/>
Kingdaro #4
Posted 20 November 2012 - 10:09 AM
Me, personally, if there's something I want to know about, I just go to the wiki. I mention it a lot, but it really is the best source to know anything you want about CC. If it isn't there, there's usually help on it in-game (the "help" command). The in-game help is limited in a lot of cases, though, so it really comes down to just screwing around and seeing what works and how it works, as long as you know the function names and such.

In other cases, the devs make demos and such that people branch off of and learn from.