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

PositionAPI

Started by jacob7ism, 12 November 2015 - 05:13 PM
jacob7ism #1
Posted 12 November 2015 - 06:13 PM
Hey! I'm kind of a newbie to programming in ComputerCraft/Lua, this is my first ever API I am actually publishing!


PositionAPI

————-

Making many things quite easier ;)/>

What the Position API does is return X and Y coordinates of different areas on the screen.
For example:
The function middle() returns the middle coordinates of your screen.

All the functions are "dynamic", as they can adapt to any computer screen.
Monitor support is coming in the near future.

Examples of some functions:

function middle() — This function returns X and Y coordinates of the middle of your screen

function bottomMid() — This function returns X and Y coordinates for the bottom middle of your screen

function topRight() — This function returns X and Y coordinates for the top right of your screen.

I could list all of them, but that'd take way too long.

I would do screenshots… but there wouldn't really be much point.

Link to the Pastebin code: vg7WTZWx
OR:
Type this in on your Computer:

pastebin get vg7WTZWx position

To install and setup the API, run the program. It will make a directory, put itself inside of it and then reboot your computer.

To load the API within a program, type this:

os.loadAPI("positionAPI/position")

I hope you enjoy! PLEASE give me feedback! I would greatly appreciate it! :lol:/>
Edited on 12 November 2015 - 11:05 PM
Creator #2
Posted 12 November 2015 - 07:08 PM
Well, this certainly is useful for GUIs. Try also adding a function centered text. You pass a the length of the text, and it return where you have to put the cursor to have a centered text.
jacob7ism #3
Posted 12 November 2015 - 09:27 PM
Thanks for the reply c:

I am working on the centered text function right now c:
Creator #4
Posted 12 November 2015 - 09:52 PM
You're welcome. By the way, this is a much better first program than NDFJay os or a door lock. If you need any help, just ask me or the community.
jacob7ism #5
Posted 12 November 2015 - 10:25 PM
Thanks. c: