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

Printing an image to OpenPeripheral Glasses

Started by Selim, 28 July 2014 - 10:38 PM
Selim #1
Posted 29 July 2014 - 12:38 AM
I am trying to make a RPG game, and I would like to display the map on the glasses. Is there an easy way of doing this? I already made the file that a computer would post it on the monitor with, but I do not know how to port that over to Terminal Glasses.
hilburn #2
Posted 29 July 2014 - 04:22 AM
Well there are many ways of doing this, but the easiest would probably be to just use glass.addBox(…) as a direct replacement for term.setCursorPos(…) term.write(" ") in your code.

For example, if you defined an area to be the map from xmin,ymin to xmax,ymax and had a table which defined x,y coordinates on the terminal and the colour to draw them, your code would look something like this:


--# draw table in format {[1]={x=,y=,colour=},...}
width=xmax-xmin
height=ymax-ymin
box_width =
box_height = 
for box_no, details in pairs(draw) do
    glass.addBox(xmin+details.x*box_width,ymin+details.y*box_height,box_width,box_height,details.colour,0.5)
end

you might want to do it slightly differently depending on how you already have the map formatted but that's the general idea
Selim #3
Posted 29 July 2014 - 09:34 PM
Do you know of a good way of converting the map to a format that would be easy to work with? This is how the map is now: http://pastebin.com/45Cu19mQ
flaghacker #4
Posted 29 July 2014 - 10:04 PM
That's a pretty good format, assuming every letter is a pixel.

Have a look at the fs and string API, and if you don't already have, learn about tables.

EDIT: Typo
Edited on 29 July 2014 - 08:05 PM
theoriginalbit #5
Posted 30 July 2014 - 07:31 AM
use paintutils.loadImage it will turn that map into a table of colours