Posted 22 July 2015 - 10:37 PM
Hi there!
This is an API, or rather a bundle of APIs, for helping to create GUIs in ComputerCraft.
The main package is the Monitor API which, though useless on its own, can help you draw GUIs on the monitor you give to it.
The meat of the Monitor API is its modules, which are:
Next, type the following command:
You'll be prompted to download and install the ButtonAPI and the LabelAPI. (Note: at this point in time, these programs will not be overwritten if they already exist. Coming in a near future update)
After the ButtonAPI and/or LabelAPI are installed, you're ready to start using them.
An example program to use these APIs would be this:
The ButtonAPI and LabelAPI are by no means limited to the MonitorAPI. You can use them on their own if you want to!
ButtonAPI: http://pastebin.com/NHwyuPaq
LabelAPI: http://pastebin.com/nRju8tyb
For a more excessive documentation on all APIs, go here: http://pastebin.com/cjdA6wve
Versions:
MonitorAPI: v1.0.1
ButtonAPI: v1.3.1
LabelAPI: v1.0.0
These APIs follow Semantic Versioning, more info on that here: http://semver.org/
Changelog:
Changelogs will be here when I update the APIs
This is an API, or rather a bundle of APIs, for helping to create GUIs in ComputerCraft.
The main package is the Monitor API which, though useless on its own, can help you draw GUIs on the monitor you give to it.
The meat of the Monitor API is its modules, which are:
- ButtonAPI;
- LabelAPI
pastebin get 3Ub6z7fA MonitorAPI
Next, type the following command:
MonitorAPI install
You'll be prompted to download and install the ButtonAPI and the LabelAPI. (Note: at this point in time, these programs will not be overwritten if they already exist. Coming in a near future update)
After the ButtonAPI and/or LabelAPI are installed, you're ready to start using them.
An example program to use these APIs would be this:
-- Load the API
os.loadAPI('MonitorAPI')
-- Attach a monitor
local monitor = peripheral.wrap('right')
MonitorAPI.setMonitor(monitor)
-- Add a header
LabelAPI.setHeader('My program')
-- Add a button
btn1 = ButtonAPI.new(2, 2, 'My button')
-- Give it a different color, default inactive color is red, default active color is green
btn1:setInactiveColor(colors.blue)
btn1:setActiveColor(colors.purple)
-- Give it a callback
-- The button parameter in the callback is the clicked button
btn1:setCallback(function (button)
print('In the callback!')
end)
-- Draw all the things!
MonitorAPI.draw()
The ButtonAPI and LabelAPI are by no means limited to the MonitorAPI. You can use them on their own if you want to!
ButtonAPI: http://pastebin.com/NHwyuPaq
LabelAPI: http://pastebin.com/nRju8tyb
For a more excessive documentation on all APIs, go here: http://pastebin.com/cjdA6wve
Versions:
MonitorAPI: v1.0.1
ButtonAPI: v1.3.1
LabelAPI: v1.0.0
These APIs follow Semantic Versioning, more info on that here: http://semver.org/
Changelog:
Changelogs will be here when I update the APIs