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

Basic color table help?

Started by Crownz4, 11 January 2014 - 10:18 AM
Crownz4 #1
Posted 11 January 2014 - 11:18 AM
Alright, all I am trying to accomplish is a colored table resembling something like this:



Yeah, basic. No touch screen functions, no buttons, just a "board" persay displaying something like that. It's all for looks in a certain part of my map. For the life of me I cannot get a table to work. I've been looking up some programs on youtube and google, but it's not coming together.

Can I please ask for some help on this? It's driving me nuts.
theoriginalbit #2
Posted 11 January 2014 - 07:58 PM
What's the code you've got so far? "not coming together" is very vague, what's the problems with it? i.e. what is it doing, what is it meant to do, etc?
surferpup #3
Posted 12 January 2014 - 04:16 AM
If by "table" you mean a lua table (similar to an array), there are a number of great posts on this subject as well as some excellent resources online elsewhere. Consider http://lua-users.org.../TablesTutorial

Basically, a table is a loosely defined collection of indexed values that may also have key values.


myTable =
{
	name = "Bob";
	age = 21;
	eyes = "brown"
}

In this case, myTable has 3 elements, each of which has an associated key value. So :


print (myTable.name) --will output Bob

Here is the same table without key values:


myTable =
{
	"Bob";
	 21;
	 "Brown"
}

In this case, you would use an index to reference the elements of the table:


print (myTable[1]) -- will output Bob

This barely scratches the surface on tables, but it is a start. You can create some pretty advanced data structures with tables in Lua. Try messing around in the interactive lua on a turtle or computer. From the shell (when a new computer or turtle boots up), type:

lua

You can make your own table and print statements to see what happens. Type ctrl-T to get back to the normal turtle or computer mode.
Edited on 12 January 2014 - 03:21 AM
TheOddByte #4
Posted 12 January 2014 - 02:50 PM
Well if it's just for display then why not just use 'paint <filename>' or 'monitor <side> paint <filename>' and use that as a display? .-.
You can then draw it onto a monitor like this

--# Wrap the monitor
local mon = peripheral.wrap("<Side>")

--# Redirect the terminal to the monitor
term.redirect( mon )

--# Clear the screen first
term.setBackgroundColor( colors.black )
term.clear()

--# Now load and draw the image
local image = paintutils.loadImage("<Filename>")
paintutils.drawImage( image, 1, 1 ) -- First 1 is x position and the second 1 is y position

--# And finally restore the term
term.restore()

But if you're looking for having text in it, It would be better to use NPaintPro by nitrogenfingers