Jump to content




Printing an image to OpenPeripheral Glasses


  • You cannot reply to this topic
4 replies to this topic

#1 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 28 July 2014 - 11:38 PM

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.

#2 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 29 July 2014 - 03: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

#3 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 29 July 2014 - 08: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

#4 flaghacker

  • Members
  • 655 posts

Posted 29 July 2014 - 09: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 by flaghacker, 29 July 2014 - 09:05 PM.


#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 July 2014 - 06:31 AM

use paintutils.loadImage it will turn that map into a table of colours





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users