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

Grid-drawing API

Started by LDDestroier, 21 July 2016 - 04:26 AM
LDDestroier #1
Posted 21 July 2016 - 06:26 AM
Okay, more of a grid drawing function, but it works pretty well.
In my program PAIN, it draws a grid which helps indicate where you are on the canvas. So I decided, why not upload the part of PAIN that draws the grid as an easy-to-use API?

vBhrJPw3

HOW TO USE:
SpoilerThere's a basic how-to in the API file, but I'll put something here as well.

This API draws a custom grid between two sets of coordinates. That's it.
Here's a basic use of it.

os.loadAPI("grid") --that is the name of the API
local x1, y1 = 3,2   --This is the top-left coordinates.
local x2, y2 = 12,10   --This is the bottom-right coordinates.
local g = {  --This is the grid that will be drawn
  "+---",
  "|...",
  "|...",
}
local xscroll, yscroll = 0, 0   --These translate the grid.

grid.drawGrid(x1, y1, x2, y2, g)  --This will draw grid 'g' at (3,2) --> (12,10)

Here's a test program I cobbled together to demonstrate it.

pastebin get FfSi0fd9 test
Make sure to have the grid API in the root directory ("/") and name it "grid".
Edited on 21 July 2016 - 04:27 AM
LDDestroier #2
Posted 28 October 2016 - 05:04 PM
Bump. Does anyone have any opinion?