Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- (C) Button API made by (C) LeV__oid
- This ButtonAPI is used to make the creation of buttons easier
- Loading this API is easily done by writing "os.loadAPI("buttonAPI")" at the top of your script.
- From there on you will be able to call every function like so:
- (Example:)
- buttonAPI.mkBtn(5, 5, 13, 13, colors.lime, "Test")
- help() - Prints a list of all available functions this API adds.
- (Example:)
- buttonAPI.help()
- mkBtn(xmin, ymin, xmax, ymax, color, name) - Draws a Button to the screen starting at P1(xmin, ymin) and going to P2(xmax, ymax). It will have the specified color and Text.
- (Example:)
- buttonAPI.mkBtn(5, 5, 13, 13, colors.lime, "Test")
- Soon to be added:
- I am planning on adding a feature that will let you make sliders (for example: for the rod insertion of big reactors) and also filling bars/diagrams (for example: for showing how much RF/EU/Whatever is stored in whatever container)
- I am also planning on making this a standalone API because currently you will still have to set your mouseclick detection manually
- Thank you for trying out my API.
- Have fun!
- ]]--
- function help()
- term.setTextColor(colors.yellow)
- print("Functions: ")
- print("mkBtn(xmin, ymin, xmax, ymax, color, displayName)")
- print("Draws a Button starting at xmin and ymin, going to xmax and ymax with the specified color.")
- term.setTextColor(colors.white)
- end
- function mkBtn(xmin, ymin, xmax, ymax, color, name)
- if name == nil then
- name = "Test"
- end
- if color == nil then
- color = colors.lime
- end
- if xmin == nil or xmax == nil or ymin == nil or ymax == nil then
- error("Error: Expected xmin, ymin, xmax, ymax (color, name)")
- end
- paintutils.drawFilledBox(xmin, ymin, xmax, ymax, color)
- midX = (xmin + xmax) / 2
- midX = midX - (#name / 2)
- midX = math.floor(midX)
- midY = (ymin + ymax) / 2
- midY = math.floor(midY)
- term.setCursorPos(midX, midY)
- term.write(name)
- term.setBackgroundColor(colors.black)
- x = 0
- y = 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement