Class TextGauge
Creates a text based gauge, for use in miniconsoles and the like.
Info:
- Copyright: 2020 Damian Monogue,2021 Damian Monogue
- License: MIT, see LICENSE.lua
- Author: Damian Monogue
-
textgauge:new([options])
line 92
-
Creates a new TextGauge.
Parameters:
- options
table
The table of options you would like the TextGauge to start with.
Table of new options
| option name |
description |
default |
| width |
How many characters wide to make the gauge |
24 |
| fillCharacter |
What character to use for the 'full' part of the gauge |
: |
| overflowCharacter |
What character to use for >100% part of the gauge |
if not set, it uses whatever you set fillCharacter to |
| emptyCharacter |
What character to use for the 'empty' part of the gauge |
- |
| showPercentSymbol |
Should we show the % sign itself? |
true |
| showPercent |
Should we show what % of the gauge is filled? |
true |
| value |
How much of the gauge should be filled |
50 |
| format |
What type of color formatting to use? 'c' for cecho, 'd' for decho, 'h' for hecho |
c |
| fillColor |
What color to make the full part of the bar? |
"DarkOrange" or equivalent for your format type |
| emptyColor |
what color to use for the empty part of the bar? |
"white" or format appropriate equivalent |
| percentColor |
What color to print the percentage numvers in, if shown? |
"white" or fortmat appropriate equivalent |
| percentSymbolColor |
What color to make the % if shown? |
If not set, uses what percentColor is set to. |
| overflowColor |
What color to make the >100% portion of the bar? |
If not set, will use the same color as fillColor |
(optional)
Usage:
local TextGauge = require("MDK.textgauge")
myTextGauge = TextGauge:new()
gaugeText = myTextGauge:setValue(382, 830)
-
textgauge:setWidth(width)
line 105
-
Sets the width in characters of the gauge
Parameters:
- width
number
number of characters wide to make the gauge
-
textgauge:setFillCharacter(character)
line 118
-
Sets the character to use for the 'full' part of the gauge
Parameters:
- character
string
the character to use.
-
textgauge:setOverflowCharacter(character)
line 126
-
Sets the character to use for the 'overflow' (>100%) part of the gauge
Parameters:
- character
string
the character to use.
-
textgauge:setEmptyCharacter(character)
line 134
-
Sets the character to use for the 'full' part of the gauge
Parameters:
- character
string
the character to use.
-
textgauge:setFillColor(color)
line 142
-
Sets the fill color for the gauge.
Parameters:
- color
string
the color to use for the full portion of the gauge. Will be run through Geyser.Golor
-
textgauge:setOverflowColor(color)
line 149
-
Sets the overflow color for the gauge.
Parameters:
- color
string
the color to use for the full portion of the gauge. Will be run through Geyser.Golor
-
textgauge:setEmptyColor(color)
line 156
-
Sets the empty color for the gauge.
Parameters:
- color
string
the color to use for the empty portion of the gauge. Will be run through Geyser.Golor
-
textgauge:setPercentColor(color)
line 163
-
Sets the fill color for the gauge.
Parameters:
- color
string
the color to use for the numeric value. Will be run through Geyser.Golor
-
textgauge:setPercentSymbolColor(color)
line 169
-
Sets the fill color for the gauge.
Parameters:
- color
string
the color to use for the numeric value. Will be run through Geyser.Golor
-
textgauge:enableReverse()
line 175
-
Enables reversing the fill direction (right to left instead of the usual left to right)
-
textgauge:disableReverse()
line 180
-
Disables reversing the fill direction (go back to the usual left to right)
-
textgauge:enableShowPercent()
line 185
-
Enables showing the percent value of the gauge
-
textgauge:disableShowPercent()
line 190
-
Disables showing the percent value of the gauge
-
textgauge:enableShowPercentSymbol()
line 195
-
Enables showing the percent symbol (appears after the value)
-
textgauge:disableShowPercentSymbol()
line 200
-
Enables showing the percent symbol (appears after the value)
-
textgauge:setValue([current[, max]])
line 270
-
Used to set the gauge's value and return the string representation of the gauge
Parameters:
- current
number
current value. If no value is passed it will use the stored value. Defaults to 50 to prevent errors.
(optional)
- max
number
maximum value. If not passed, the internally stored one will be used. Defaults to 100 so that it can be used with single values as a percent
(optional)
Usage:
-
textgauge:print(...)
line 331
-
Synonym for setValue
Parameters: