link in the installation area
if there is anything I should add/change on this post or the API please let me know
Screenshots
Spoiler
The setup for appearance demonstrationBasic Colors
red is off, green(lime) is on
With different colors
line 1&3 are off, 2&4 are on
line 1&2 are regular paired, 3&4 are the colored pair
left column is button and text, column middle just background, right column just text
Spoiler
http://pastebin.com/pMSgMrErInstalling
pastebin get pMSgMrEr button
And in startupos.loadAPI("button")
you can name the api anything. but keep in mind your code will have to reflect the different name. so button.wrap() would now be [the name you gave it].wrap()Spoiler
button.wrap(side)
button.new.b(id, text, xmin, xmax, ymin, ymax, func, argpass)
button.new.l(id, text, x, y, func, argpass)
button.e.color(id, T, on, off)
button.e.x(id, T, value)
button.e.y(id, T, value)
button.e.text(id, value)
button.e.label(id, value)
button.e.func(id, value)
button.e.argpass(id, value)
button.e.display(id, value)
button.e.click(id, value)
button.e.status(id, value)
button.e.hidden(id,value)
button.e.s.color(T, S, color)
button.e.s.scale(scale)
button.get.b(id)
button.get.l(id)
button.get.s()
button.get.f(id)
button.delete(id)
button.display()
button.check(x,y)
button.cycle()
Spoiler
The following is to set up the API to display the buttonsbutton.wrap(side)
side: the side the advanced monitor is on. available options: (front, back, left, right, top, bottom,term)NOTE: term is to use the computer as the touchscreen and not an advanced monitor attached to the computer
This is required to tell the API where to display the buttons
button.new.b(id, text,xmin,xmax,ymin,ymax,func,argpass)
id: unique identifier (note buttons and labels share id)text: the text to be shown
xmin: left most point to be used in the button
xmax: right most point to be used in the button
ymin: top most point to be used in the button
ymax: bottom most point to be used in the button
func: function to be called when the button is clicked
argpass: argument to be passed to the function
NOTE: function must be given to this function as a variable (without the "()" at the end). arg pass also will only save one item or table.
button.new.l(id,text,x,y,func,argpass)
id: unique identifier (note buttons and labels share id)text: the text to be shown
x: the horizontal start point
y: the vertical start point
func: function to be called when the button is clicked
argpass: argument to be passed to the function
NOTE: function must be given to this function as a variable (without the "()" at the end). arg pass also will only save one item or table.
The following edit the buttons options id in the following is the button's id when button.new.b (button.new.l for labels) was used
button.e.color(id, T, on, off)
T: edit the text color or background available options: back, text, backgroundon: the new on color available options: 16 colors supported by computercaraft (see color API) can be named or the number
off: the new off color available options: 16 colors supported by computercaraft (see color API) can be named or the number
button.e.x(id, T, value)
T:edit mon or max available options: min, maxvalue the new value of min or max
NOTE: if a number is passed for T the lower pf the 2 numbers is the new min the higher is the new max
button.e.y(id, T, value)
T:edit mon or max available options: min, maxvalue the new value of min or max
NOTE: if a number is passed for T the lower pf the 2 numbers is the new min the higher is the new max
button.e.text(id, value)
value the new text to be used for displayNOTE: button will not resize for longer text but will keep it centered unless it would hang over the left side
button.e.label(id, value)
value the buttons new labelNOTE: this is only really used to help the API determine what default colors to use
button.e.func(id, value)
value the new function the button should usebutton.e.argpass(id, value)
value the new argument the API should pass to the button's functionbutton.e.display(id, value)
value should the button be displayed? (y/n) available options: yes, on, true, no, off, falseNOTE: leaving value blank toggles the display setting of the button
button.e.click(id, value)
value can the button be clicked on? (y/n) available options: yes, on, true, no, off, falseNOTE: leaving value blank toggles the click setting of the button
button.e.status(id, value)
value the current status of the button available options: yes, on, true, no, off, falseNOTE: leaving value blank toggles the status setting of the button
button.e.hidden(id,value)
value can the button be clicked if it is not shown? (y/n) available options: yes, on, true, no, off, falseNOTE: leaving value blank toggles the hidden setting of the button
button.e.s.color(T, S, color)
T: edit the defult color for the text or background available options: back, text, backgroundS: edit the on, off, non color available options: on, off, non
color the new color to use available options: 16 colors supported by computercaraft (see color API) can be named or the number
NOTE: non refers no non button color. non button background is the background used for any area not used by a button
button.e.s.scale(scale)
scale the new scale of the monitor available options: any number usable by a computercraft monitorNOTE: if term is used for wrap, this function does nothing.
button.get.b(id)
button.get.l(id)
id: get the information on a button/label with the idbutton.get.s()
gets setting informationbutton.get.f(id)
id: returns a table with function and arguments to pass based on the ID does not call the functionbutton.delete(id)
id: the Unique id of the button you want to delete from the systembutton.display()
this tells the API to draw the buttons on the monitor set by the button.wrap() commandbutton.check(x,y)
x: the x value of the os.pullEvent("monitor_touch")y: the y value of the os.pullEvent("monitor_touch")
button.cycle()
this just cycles the display, os.pullEvent and check automaticlySpoiler
code used to make the screenshots pastebin FqTRzQJvfollowing code can be used for toggling the status of a button and passing the staus of that button to the output
function redstone ()
button.status("redstone")
rs.setOutput("left", button.get.b("redstone").status)
end
Spoiler
Button/Label/FuncThe following is the table structure of a variable if you store data using button.get.b() when passing an id, if no id is passed the entire table is given and is id indexed. Note that button in the following is if you used the variable b
b.x.min
b.x.max
b.y.min
b.y.max
b.text.on
b.text.off
b.text.show
b.back.on
b.back.off
b.display
b.click
b.hidden
b.label
b.status
Settingthis is the variable structure if button.get.s() was used and stored in the Setting variable
Setting.back.on
Setting.back.off
Setting.back.non
Setting.text
Setting.text.on
Setting.text.off
Setting.text.non
Setting.scale
Setting.size
Setting.size.x
Setting.size.y
this is the variable structure if button.get.f() was used and stored in the func variablefunc.func
func.argpass
Spoiler
get it to use the terminal as well as peripheralshave it use different monitors at the same time
simplify function calls
better/more examples
Spoiler
before I can help you with my API, I will need the code you are working with and the error that is being given. I will only do support for the API in this thread, or ask a pro of I see it there.Spoiler
The date given is the date of the update, the pastebin link is for the version associated pastebin3/12/14 Pastebin
- Added support for the computer you are using as the touchscreen
- Added a way to delete unwanted buttons buttons
- Fixed an error that would cause buttons/labels with nil functions to crash the API, and they now behave properly. (paste bin code not changed)
- Initial release