Here are some of the functions that exist in GlovePIE
NEW! Pixel colour Functions ScreenPixel(x, y): colour of screen pixel at (x, y) as an integer, in hexadecimal it looks like 0xRRGGBB. This is the opposite of the way the windows DLLs do it, but it is the way the internet and DirectX do it. To display it:
Debug = “0x”+ IntToHex(ScreenPixel(0, 0), 6)
You can also treat it like a vector:
[var.r, var.g, var.b] = ScreenPixel(0, 0)
debug = var.r+’, ‘+var.g+’, ‘+var.b
That will set var.r, var.g, and var.b to the values between 0 and 1 corresponding to the amount of red, green, and blue in the colour. The (0, 0) coordinates could be any pixel coordinates.
Trigonometry Functions All angles are measured in degrees by default.
The following trigonometry functions are implemented:
Standard trig functions: sin, cos, tan, sec, cosec, cotan
Logarithms (undoing raising something to some power):
Log10(x): returns the number you have to raise 10 to the power of, in order to get x. eg. Log10(1000) = 3
Log2(x): returns the number you have to raise 2 to the power of, in order to get x. eg. Log2(256) = 8
LogN(N, x): returns the number you have to raise N to the power of, in order to get x. eg. LogN(10, 1000) = 3
Ln(x): returns the number you have to raise e (2.71828) to the power of, in order to get x
LnXP1(x): the same as above, but for x+1 instead of x
Comparison functions IsZero(x): returns true if x is zero
IsInfinite(x): returns true if x is infinite
IsNaN(x): returns true if x is not a number
SameValue(a, b [, epsilon]): returns true if a and b are the same, or differ by no more than epsilon
InSet(x,a,b,c,d,e,f,g,...): returns true if x matches one of the values following it.
max(a,b): returns the maximum of two values. Preserves units.
min(a,b): returns the minimum of two values. Preserves units.
Range functions EnsureRange(x, a, b): Returns the closest value to x which is within the range [a, b]. Preserves units.
InRange(x, a, b): Returns true if x is within the range [a, b].
MapRange(x, a, b, c, d): Returns value x converted from the range [a, b] to the range [c, d]. Values outside the original range will map to the appropriate values outside the new range.
EnsureMapRange(x, a, b, c, d): The same as MapRange except values outside the range are mapped to the closest values inside the range.
NEW! DeadZone(x, a): Returns value x between -1 and 1, but with a deadzone around zero, so that values within the range [-a, a] of the zero point become 0, and other values between -1 and 1 are scaled to compensate. You should only use this function for values roughly between -1 and 1, like joystick values.
Random functions Random: Returns a random fractional number between 0 and 1.
Random(n): Returns a random whole number between 0 and n-1.
RandomRange(a,b): Returns a random whole number between a and b.
RandG(mean, StandDev): Returns a random number from gaussian distribution around mean. Preserves units.
succ(n): Returns n+1
Date/Time functions NEW! TimeStamp or GetTimeStamp: A precise timestamp measured in seconds, from an arbitrary starting point. Much more accurate than the other time functions (which are measured in days).
Now: Current time and date (in days since December 30, 1899)
Time: Current time (in fractions of a day)
Date: Current date (in days since December 30, 1899)
Tomorrow: Tomorrow's date (in days since December 30, 1899)
Yesterday: Yesterday's date (in days since December 30, 1899)
CurrentYear: Current year of the Gregorian calendar (in years).
DateOf(x): Returns the date part of the date and time in x (in days since December 30, 1899)
TimeOf(x): Returns the time part of the date and time in x (in fractions of a day)
NEW! Delta(x) How much x has changed since the previous GlovePIE frame. It will be negative if x has decreased.
Smooth(x, [ExtraFrames, [DeadbandDistance]]) Smooths out the value of x by averaging with the previous ExtraFrames frames. If it hasn’t changed by more than DeadbandDistance it doesn’t count as changed at all. By default DeadbandDistance is 0.
NEW! Kalman(x, noise1, noise2) Smooths using a Kalman filter, in theory. It has a tendency to diverge if you get the noise values wrong. Don’t ask me what the correct noise values are.
Pressed(x), Clicked(x), SingleClicked(x), DoubleClicked(x) Returns true or false.
HeldDown(x, MinTime) Returns true if x has been held down for at least MinTime.
KeepDown(x, MinTime) Keeps the result being true after x has stopped being true, until MinTime is up.