Posted 14 March 2013 - 07:04 AM
Hello there!
This is my first API, so please be respectful.
This API makes it easier to draw and create buttons on computercraft.
Feel free to use it in any way you want!
How it works:
Explanation of variables:
xCoord1 = the x coordinate of the start of a button
yCoord1 = the y coordinate of the start of a button
xCoord2 = the x coordinate of the end of a button
yCoord2 = the y coordinate of the end of a button
text = the text on the button
buttonColour = the colour of the button
buttonTextColour = the colour of the text on the button
buttonNumber = the number of the button that is activated (for example 2 if the second button that you added with button.add() is activated)
monitorSide = the side where the monitor is next to the computer
input = the input that the user wrote down
xCoord = the x coordinate of the cursor position
yCoord = the y coordinate of the cursor position
backgroundColour = the background colour
textColour = the colour of the text that the user types in
How to use it:
First, add an button by typing in:
Installation:
Download the ButtonAPI.zip
Go to: %appdata% => .minecraft => mod => ComputerCraft.zip => lua => rom
Then open the ButtonAPI.zip and extract all the folders into here.
Start up minecraft and have fun! :D/>
!!! Important: It's possible that the API doesn't work for a lower version than 1.5, because it uses the peripheral API. !!!
Downloads:
Mediafire: http://www.mediafire...k71nw7by45k1fqj
Dropbox: https://www.dropbox....2/ButtonAPI.zip
[attachment=1062:ButtonAPI.zip]
This is my first API, so please be respectful.
This API makes it easier to draw and create buttons on computercraft.
Feel free to use it in any way you want!
How it works:
-- Draws a button but doesn't do anything when someone clicked on it.
button.drawButton(xCoord1, yCoord1, xCoord2, yCoord2, text, buttonColour, buttonTextColour)
-- Adds a button to the button list
button.addButton(xCoord1, yCoord1, xCoord2, yCoord2, text, buttonColour, buttonTextColour)
-- Clears the button list
button.clearButton()
-- Shows all the buttons from the button list on the computer
-- Returns the number of the button which is activated
buttonNumber = button.showComputer()
-- Shows all the buttons from the button list on a monitor
-- Returns the number of the button which is activated
buttonNumber = button.showMonitor(monitorSide)
-- Shows all the buttons from the button list on the computer
-- Reads what the user types
-- Returns the number of the button which is activated and a empty string or returns 1 and what the user typed in
buttonNumber, input = button.showComputerRead(xCoord, yCoord, textColour, buttonColour)
-- Shows all the buttons from the button list on a monitor
-- Reads what the user types
-- Returns the number of the button which is activated and a empty string or returns 1 and what the user typed in
buttonNumber, input = button.showMonitorRead(xCoord, yCoord, monitorSide, backgroundColour, textColour)
Explanation of variables:
xCoord1 = the x coordinate of the start of a button
yCoord1 = the y coordinate of the start of a button
xCoord2 = the x coordinate of the end of a button
yCoord2 = the y coordinate of the end of a button
text = the text on the button
buttonColour = the colour of the button
buttonTextColour = the colour of the text on the button
buttonNumber = the number of the button that is activated (for example 2 if the second button that you added with button.add() is activated)
monitorSide = the side where the monitor is next to the computer
input = the input that the user wrote down
xCoord = the x coordinate of the cursor position
yCoord = the y coordinate of the cursor position
backgroundColour = the background colour
textColour = the colour of the text that the user types in
How to use it:
First, add an button by typing in:
button.addButton(xCoord1, yCoord1, xCoord2, yCoord2, text, buttonColour, buttonTextColour)
Then show the button on the screen by using one of these functions:
buttonNumber = button.showComputer()
buttonNumber = button.showMonitor(monitorSide)
buttonNumber, input = button.showComputerRead(xCoord, yCoord, backGroundColour, textColour)
buttonNumber, input = button.showMonitorRead(xCoord, yCoord, text, backGroundColour, textColour)
You can also draw a button without any use:
button.drawButton(xCoord1, yCoord1, xCoord2, yCoord2, text, buttonColour, buttonTextColour)
If you want to clear the list of all the buttons that are added by button.addButton(), type in:
button.clearButton()
Installation:
Download the ButtonAPI.zip
Go to: %appdata% => .minecraft => mod => ComputerCraft.zip => lua => rom
Then open the ButtonAPI.zip and extract all the folders into here.
Start up minecraft and have fun! :D/>
!!! Important: It's possible that the API doesn't work for a lower version than 1.5, because it uses the peripheral API. !!!
Downloads:
Mediafire: http://www.mediafire...k71nw7by45k1fqj
Dropbox: https://www.dropbox....2/ButtonAPI.zip
[attachment=1062:ButtonAPI.zip]