Posted 07 March 2017 - 11:26 PM
Sliders
Sliders is an API I wrote to help me keep track of all the liquid in my railcraft tanks through "Progress bars". But it is able to do so much more than that. Anything that you might be able to convert into percentages, you can put in a slider.
Functions
Spoiler
createSlider()Spoiler
createSlider has 5 required arguments.- name: name of the Slider, can be any string
- x: Starting point of the slider on the x-axis
- y: Starting point of the slider on the y-axis
- Length: Length of the slider.
- Height: Height of the slider.
- sliderColor: Color of the actual slider (The parts that's getting filled up) default = colors.gray
- barColor: Background color. (the whole thing) default = colors.white.
sliders.createSlider("Slider_1", 2, 2, 49, 3, colors.lime, colors.red)
which creates a slider looking like this:IMPORTANT: THIS FUNCTION DOESN'T ACTUALLY DRAW THE SLIDER!
updateSlider()
Spoiler
updateSlider() takes 2 arguments.- name: name of an existing slider
- value: the percentage of the bar that should be filled up (has to be between 0 and 100)
sliders.updateSlider("slider_1", 50)
Which updates the slider to 50%IMPORTANT: THIS FUNCTION DOESN'T ACTUALLY DRAW THE SLIDER
setMonitor()
Spoiler
This function takes a side and wraps to the monitor at that side. This function is very important if you want to draw to a monitor.
example
sliders.setMonitor("right")
draw()
Spoiler
draw() draws the sliders. The function has 2 optional arguments.
- name(s): can either be a single name of an existing slider or you can pass a table to it and it will draw all the sliders in that table.
- drawText: boolean; true or false. set this to false if you don't want the % text in the middle of the slider.
Example Program:
Spoiler
os.loadAPI("sliders")
sliders.createSlider("slider_1", 2, 2, 49, 3, colors.lime, colors.red)
while true do
for i = 0, 100 do
sliders.updateSlider("slider_1", i)
sliders.draw()
sleep(0.1)
end
end
Output:
Install
pastebin get V22szV0M sliders
From there on just load the api in your own script and use it :)/>
Feel free to post pictures of your usage or ways I could improve the API.