code/__DEFINES/rust_g.dm
/proc/rustg_get_version | Gets the version of rust_g |
---|---|
rustg_setup_acreplace | Sets up the Aho-Corasick automaton with its default options. |
rustg_setup_acreplace_with_options | Sets up the Aho-Corasick automaton using supplied options. |
rustg_acreplace | Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
rustg_acreplace_with_replacements | Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
rustg_cnoise_generate | This proc generates a cellular automata noise grid which can be used in procedural generation methods. |
rustg_dbp_generate | This proc generates a grid of perlin-like noise |
rustg_dmi_icon_states | input: must be a path, not an /icon; you have to do your own handling if it is one, as icon objects can't be directly passed to rustg. |
rustg_git_revparse | Returns the git hash of the given revision, ex. "HEAD". |
/proc/rustg_git_commit_date | Returns the date of the given revision using the provided format. Defaults to returning %F which is YYYY-MM-DD. |
/proc/rustg_git_commit_date_head | Returns the formatted datetime string of HEAD using the provided format. Defaults to returning %F which is YYYY-MM-DD. This is different to rustg_git_commit_date because it only needs the logs directory. |
rustg_noise_poisson_map | Generates a 2D poisson disk distribution ('blue noise'), which is relatively uniform. |
/proc/rustg_sound_length | Provided a static RSC file path or a raw text file path, returns the duration of the file in deciseconds as a float. |
rustg_sound_length_list | Returns a nested key-value list containing "successes" and "errors" The format is as follows: list( RUSTG_SOUNDLEN_SUCCESES = list("sounds/test.ogg" = 25.34), RUSTG_SOUNDLEN_ERRORS = list("sound/bad.png" = "SoundLen: Unable to decode file."), ) |
/proc/rustg_unix_timestamp | Returns the timestamp as a string |
Define Details
rustg_acreplace
Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
Arguments:
- key - The key for the automaton
- text - Text to run replacements on
rustg_acreplace_with_replacements
Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
Arguments:
- key - The key for the automaton
- text - Text to run replacements on
- replacements - Replacements for this call. Must be the same length as the set-up patterns
rustg_cnoise_generate
This proc generates a cellular automata noise grid which can be used in procedural generation methods.
Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell.
Arguments:
- percentage: The chance of a turf starting closed
- smoothing_iterations: The amount of iterations the cellular automata simulates before returning the results
- birth_limit: If the number of neighboring cells is higher than this amount, a cell is born
- death_limit: If the number of neighboring cells is lower than this amount, a cell dies
- width: The width of the grid.
- height: The height of the grid.
rustg_dbp_generate
This proc generates a grid of perlin-like noise
Returns a single string that goes row by row, with values of 1 representing an turned on cell, and a value of 0 representing a turned off cell.
Arguments:
- seed: seed for the function
- accuracy: how close this is to the original perlin noise, as accuracy approaches infinity, the noise becomes more and more perlin-like
- stamp_size: Size of a singular stamp used by the algorithm, think of this as the same stuff as frequency in perlin noise
- world_size: size of the returned grid.
- lower_range: lower bound of values selected for. (inclusive)
- upper_range: upper bound of values selected for. (exclusive)
rustg_dmi_icon_states
input: must be a path, not an /icon; you have to do your own handling if it is one, as icon objects can't be directly passed to rustg.
output: json_encode'd list. json_decode to get a flat list with icon states in the order they're in inside the .dmi
rustg_git_revparse
Returns the git hash of the given revision, ex. "HEAD".
rustg_noise_poisson_map
Generates a 2D poisson disk distribution ('blue noise'), which is relatively uniform.
params:
seed
: str
width
: int, width of the noisemap (see world.maxx)
length
: int, height of the noisemap (see world.maxy)
radius
: int, distance between points on the noisemap
returns: a width*length length string of 1s and 0s representing a 2D poisson sample collapsed into a 1D string
rustg_setup_acreplace
Sets up the Aho-Corasick automaton with its default options.
The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call Arguments:
- key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
- patterns - A non-associative list of strings to search for
- replacements - Default replacements for this automaton, used with rustg_acreplace
rustg_setup_acreplace_with_options
Sets up the Aho-Corasick automaton using supplied options.
The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call Arguments:
- key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
- options - An associative list like list("anchored" = 0, "ascii_case_insensitive" = 0, "match_kind" = "Standard"). The values shown on the example are the defaults, and default values may be omitted. See the identically named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do.
- patterns - A non-associative list of strings to search for
- replacements - Default replacements for this automaton, used with rustg_acreplace
rustg_sound_length_list
Returns a nested key-value list containing "successes" and "errors" The format is as follows: list( RUSTG_SOUNDLEN_SUCCESES = list("sounds/test.ogg" = 25.34), RUSTG_SOUNDLEN_ERRORS = list("sound/bad.png" = "SoundLen: Unable to decode file."), )