Script engine.utils
Utility functionality used by a lot of the base classes
Functions
table.genrange (a, b, v)
Generate a containing indexes between a and b and set to value v
table.minus_keys (t1, t2)
Return a new table containing the keys from t1 without the keys from t2
table.clone (tbl, deep, k_skip)
Returns a clone of a table
table.merge (dst, src, deep, k_skip, k_skip_deep, addnumbers)
Merges two tables in-place.
table.mergeAddAppendArray (dst, src, deep, k_skip, k_skip_deep)
Merges additively the named fields and append the array part Yes this is weird and you'll probably not need it, but the engine does :)
table.update (dst, src, deep)
Adds missing keys from the src table to the dst table.
table.readonly (src)
Creates a read-only table
table.shuffle (t)
Shuffles the content of a table (list)
string.toTString (str)
Parse a string and return a tstring
tstring:toString ()
Tablestrings degrade "peacefully" into normal formated strings
tstring:format ()
Tablestrings can not be formated, this just returns self
util.adjacentCoords (x, y, no_diagonals, no_cardinals)
A list of adjacent coordinates depending on core.fov.set_algorithm.
util.findAllReferences (t, what)
Find a reference to the given value inside a table and all it contains
core.fov.set_permissiveness (val)
Sets the permissiveness of FoV based on the shape of blocked terrain
core.fov.set_actor_vision_size (val)
Sets the FoV vision size of the source actor (if applicable to the chosen FoV algorithm).
core.fov.set_algorithm (val)
Sets the algorithm used for FoV (and LoS).
core.fov.set_vision_shape (val)
Sets the vision shape or distance metric for field of vision, talent ranges, AoEs, etc.
util.findFreeGrid (sx, sy, radius, block, what)
Finds free grids around coords in a radius.
util.setForceSafeBoot ()
Safeboot mode
__dump_fct (f)
Ultra weird, this is used by the C serialization code because I'm too dumb to make lua_dump() work on windows ...
require_first (...)
Tries to load a lua module from a list, returns the first available
util.steamCanCloud ()
Is steamcloud available?
Tables
line
create a basic bresenham line (or hex equivalent)
Fields
os.crash
Alias os.exit to our own exit method for cleanliness
Functions
- table.genrange (a, b, v)
-
Generate a containing indexes between a and b and set to value v
Parameters:
- a
- b
- v
- table.minus_keys (t1, t2)
-
Return a new table containing the keys from t1 without the keys from t2
Parameters:
- t1
- t2
- table.clone (tbl, deep, k_skip)
-
Returns a clone of a table
Parameters:
- tbl The original table to be cloned
- deep Boolean to determine if recursive cloning occurs
- k_skip A table containing key values set to true if you want to skip them.
Returns:
-
The cloned table.
- table.merge (dst, src, deep, k_skip, k_skip_deep, addnumbers)
-
Merges two tables in-place.
The table.NIL_MERGE is a special value that will nil out the corresponding dst key.
Parameters:
- dst The destination table, which will have all merged values.
- src The source table, supplying values to be merged.
- deep Boolean that determines if tables will be recursively merged.
- k_skip A table containing key values set to true if you want to skip them.
- k_skip_deep Like k_skip, except this table is passed on to the deep recursions.
- addnumbers Boolean that determines if two numbers will be added rather than replaced.
- table.mergeAddAppendArray (dst, src, deep, k_skip, k_skip_deep)
-
Merges additively the named fields and append the array part
Yes this is weird and you'll probably not need it, but the engine does :)
Parameters:
- dst
- src
- deep
- k_skip
- k_skip_deep
- table.update (dst, src, deep)
-
Adds missing keys from the src table to the dst table.
Parameters:
- dst The destination table, which will have all merged values.
- src The source table, supplying values to be merged.
- deep Boolean that determines if tables will be recursively merged.
- table.readonly (src)
-
Creates a read-only table
Parameters:
- src
- table.shuffle (t)
-
Shuffles the content of a table (list)
Parameters:
- t
- string.toTString (str)
-
Parse a string and return a tstring
Parameters:
- str
- tstring:toString ()
- Tablestrings degrade "peacefully" into normal formated strings
- tstring:format ()
- Tablestrings can not be formated, this just returns self
- util.adjacentCoords (x, y, no_diagonals, no_cardinals)
-
A list of adjacent coordinates depending on core.fov.set_algorithm.
Parameters:
- x x-coordinate of the source tile.
- y y-coordinate of the source tile.
- no_diagonals Boolean that restricts diagonal motion.
- no_cardinals Boolean that restricts cardinal motion.
Returns:
-
Array of {x, y} coordinate arrays indexed by direction from source.
- util.findAllReferences (t, what)
-
Find a reference to the given value inside a table and all it contains
Parameters:
- t
- what
- core.fov.set_permissiveness (val)
-
Sets the permissiveness of FoV based on the shape of blocked terrain
Parameters:
- val can be any number between 0.0 and 1.0 (least permissive to most permissive) or the name of a shape: square, diamond, octagon, firstpeek. val = 0.0 is equivalent to "square", and val = 1.0 is equivalent to "diamond" "firstpeek" is the least permissive setting that allows @ to see r below: @## ..r Default is "square"
- core.fov.set_actor_vision_size (val)
-
Sets the FoV vision size of the source actor (if applicable to the chosen FoV algorithm).
Parameters:
- val
should be any number between 0.0 and 1.0 (smallest to largest). Default is 1. val = 1.0 will result in symmetric vision and targeting (i.e., I can see you if and only if you can see me)
for applicable fov algorithms ("large_ass").
- val
- core.fov.set_algorithm (val)
-
Sets the algorithm used for FoV (and LoS).
Parameters:
- val should be a string: "recursiveshadowcasting" (same as "default"), or "largeactorrecursiveshadowcasting" (same as "largeass") "largeass" is symmetric if "actorvisionsize" is set to 1. Note: Hexagonal vision shape currently only supports "recursiveshadowcasting", but all algorithms will eventually be supported in hex grids. For backwards compatibility, if val is "hex" or "hexagon", then grid is changed to hex (one should instead call core.fov.setvision_shape("hex"))
- core.fov.set_vision_shape (val)
-
Sets the vision shape or distance metric for field of vision, talent ranges, AoEs, etc.
Parameters:
- val should be a string: circle, circleround (same as circle), circlefloor, circleceil, circleplus1, octagon, diamond, square. See "src/fov/fov.h" to see how each shape calculates distance and height. "circleround" is aesthetically pleasing, "octagon" is a traditional roguelike FoV shape, and "circleplus1" is similar to both "circleround" and "octagon" Default is "circleround"
- util.findFreeGrid (sx, sy, radius, block, what)
-
Finds free grids around coords in a radius.
This will return a random grid, the closest possible to the epicenter
Parameters:
- sx the epicenter coordinates
- sy the epicenter coordinates
- radius the radius in which to search
- block true if we only consider line of sight
- what a table which can have the fields Map.ACTOR, Map.OBJECT, ..., set to true. If so it will only return grids that are free of this kind of entities.
- util.setForceSafeBoot ()
- Safeboot mode
- __dump_fct (f)
-
Ultra weird, this is used by the C serialization code because I'm too dumb to make lua_dump() work on windows ...
Parameters:
- f
- require_first (...)
-
Tries to load a lua module from a list, returns the first available
Parameters:
- ...
- util.steamCanCloud ()
- Is steamcloud available?