playxlib
static |
CastToBool(v, default)
Casts a console command arg to a bool. |
static |
CastToNumber(v, default)
Casts a console command arg to a number. |
static |
CastToString(v, default)
Casts a console command arg to a string. |
static |
EmptyToNil(s)
Returns nil if a string is empty, otherwise it will return the string. |
static |
FindMatch(str, patterns)
Attempts to match a list of patterns against a string, and returns the first match, or nil if there were no matches. |
static |
HTMLEscape(str)
HTML encodes a string. |
static |
HTMLUnescape(s)
Unescape HTML. |
static |
IsSquare(width, height)
Takes a width and height and returns a boolean to indicate whether the shape is optimally a square. |
static |
IsTrue(s)
Tries to interpret a string as a boolean. |
static |
JSEscape(str)
Encodes a string to be placed into a JavaScript string. |
static |
ParseCSV(data)
Parses a string containing data formatted in CSV into a table. |
static |
ParseQuery(str)
Parses a query. |
static |
ParseTags(s, delim)
Gets the tags out of a string. |
static |
ParseTimeString(str)
Parses a human-readable time string. |
static |
PointLineDistance(line1, line2, point)
Returns the smallest distance between a point and a line in 3D space. |
static |
PointLineSegmentDistance(line1, line2, point)
Returns the smallest distance between a point and a line segment in 3D space. |
static |
PointLineSegmentProjection(line1, line2, point)
Returns the projection of a point onto a line segment in 3D space. |
static |
ReadableTime(t)
Turns seconds into minutes and seconds. |
static |
URLEscape(s)
Percent encodes a value for URLs. |
static |
URLEscapeTable(vars)
Percent encodes a table for the query part of a URL. |
static |
URLUnescape(str)
URL unescapes a string. |
static |
UTCTime(t)
Gets a timestamp in UTC. |
static |
WriteCSV(data)
Turns a table into CSV data. |
playxlib.CastToBool(v, default)
Casts a console command arg to a bool.
Parameters:
v
default
Return value:
- Boolean
playxlib.CastToNumber(v, default)
Casts a console command arg to a number.
Parameters:
v
default
Return value:
- Boolean
playxlib.CastToString(v, default)
Casts a console command arg to a string.
Parameters:
v
default
Return value:
- Boolean
playxlib.EmptyToNil(s)
Returns nil if a string is empty, otherwise it will return the string.
Parameters:
s
- StringReturn value:
- Value
playxlib.FindMatch(str, patterns)
Attempts to match a list of patterns against a string, and returns the first match, or nil if there were no matches.
Parameters:
str
- The stringpatterns
- Table of patternsReturn value:
- Table of results, or bil
playxlib.HTMLEscape(str)
HTML encodes a string.
Parameters:
str
Return value:
- Encoded string
playxlib.HTMLUnescape(s)
Unescape HTML. This function fudges the job, and it does not handle all of HTML's named entities.
Parameters:
s
- The stringReturn value:
- Unescaped string
playxlib.IsSquare(width, height)
Takes a width and height and returns a boolean to indicate whether the shape is optimally a square. This is used by the engine code to determine whether a square screen is better than a rectangular screen for a certain set of screen dimensions.
Parameters:
width
height
Return value:
- Boolean
playxlib.IsTrue(s)
Tries to interpret a string as a boolean. "true," "y," etc. are considered to be true.
Parameters:
s
- StringReturn value:
- Boolean
playxlib.JSEscape(str)
Encodes a string to be placed into a JavaScript string.
Parameters:
str
- String to encodeReturn value:
- Encoded
playxlib.ParseCSV(data)
Parses a string containing data formatted in CSV into a table. Fields can be quoted with double quotations or be unquoted, and characters can be escaped with a backslash. This CSV parser is very forgiving. The return table has each line in a new entry, and each field is then a further entry in a table. Not all the rows may have the same number of fields in the returned table.
Parameters:
data
- CSV dataReturn value:
- Table containg data
playxlib.ParseQuery(str)
Parses a query.
Parameters:
str
- String to parseReturn value:
- Table with keys and values
playxlib.ParseTags(s, delim)
Gets the tags out of a string.
Parameters:
s
delim
- DelimiterReturn value:
- Table
playxlib.ParseTimeString(str)
Parses a human-readable time string. Returns the number in seconds, or nil if it cannot detect a format. Blank strings will return 0.
Parameters:
str
Return value:
- Time
playxlib.PointLineDistance(line1, line2, point)
Returns the smallest distance between a point and a line in 3D space.
Parameters:
line1
- Line's first pointline2
- Line's second pointpoint
- PointReturn value:
- Distance
playxlib.PointLineSegmentDistance(line1, line2, point)
Returns the smallest distance between a point and a line segment in 3D space.
Parameters:
line1
- Line's first pointline2
- Line's second pointpoint
- PointReturn value:
- Distance
playxlib.PointLineSegmentProjection(line1, line2, point)
Returns the projection of a point onto a line segment in 3D space.
Parameters:
line1
- Line's first pointline2
- Line's second pointpoint
- PointReturn value:
- Distance
playxlib.ReadableTime(t)
Turns seconds into minutes and seconds.
Parameters:
t
- TimeReturn value:
- String
playxlib.URLEscape(s)
Percent encodes a value for URLs.
Parameters:
s
- StringReturn value:
- Encoded
playxlib.URLEscapeTable(vars)
Percent encodes a table for the query part of a URL.
Parameters:
vars
- Table of keys and valuesReturn value:
- Encoded string
playxlib.URLUnescape(str)
URL unescapes a string. Doesn't handle %####
Parameters:
str
- StringReturn value:
- Unescaped string
playxlib.UTCTime(t)
Gets a timestamp in UTC.
Parameters:
t
- TimeReturn value:
- Time
playxlib.WriteCSV(data)
Turns a table into CSV data.
Parameters:
data
- Table to convertReturn value:
- CSV data