Goonstation 13 - Modules - TypesDefine Details

_std/rust_g.dm

/proc/rustg_get_versionGets the version of rust_g
rustg_setup_acreplaceSets up the Aho-Corasick automaton with its default options.
rustg_setup_acreplace_with_optionsSets up the Aho-Corasick automaton using supplied options.
rustg_acreplaceRun the specified replacement engine with the provided haystack text to replace, returning replaced text.
rustg_acreplace_with_replacementsRun the specified replacement engine with the provided haystack text to replace, returning replaced text.
rustg_cnoise_generateThis proc generates a cellular automata noise grid which can be used in procedural generation methods.
rustg_dbp_generateThis proc generates a grid of perlin-like noise
rustg_dmi_icon_statesinput: 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_revparseReturns the git hash of the given revision, ex. "HEAD".
rustg_git_commit_dateReturns the date of the given revision in the format YYYY-MM-DD. Returns null if the revision is invalid.
rustg_encode_base64Encode a given string into base64
rustg_decode_base64Decode a given base64 string
rustg_iconforge_generateGenerates a spritesheet at: [file_path][spritesheet_name]_[size_id].png The resulting spritesheet arranges icons in a random order, with the position being denoted in the "sprites" return value. All icons have the same y coordinate, and their x coordinate is equal to icon_width * position.
rustg_iconforge_generate_asyncReturns a job_id for use with rustg_iconforge_check()
rustg_iconforge_checkReturns the status of an async job_id, or its result if it is completed. See RUSTG_JOB DEFINEs.
rustg_iconforge_cleanupClears all cached DMIs and images, freeing up memory. This should be used after spritesheets are done being generated.
rustg_iconforge_cache_validTakes in a set of hashes, generate inputs, and DMI filepaths, and compares them to determine cache validity. input_hash: xxh64 hash of "sprites" from the cache. dmi_hashes: xxh64 hashes of the DMIs in a spritesheet, given by rustg_iconforge_generate with hash_icons enabled. From the cache. sprites: The new input that will be passed to rustg_iconforge_generate(). Returns a CacheResult with the following structure: list( "result": "1" (if cache is valid) or "0" (if cache is invalid) "fail_reason": "" (emtpy string if valid, otherwise a string containing the invalidation reason or an error with ERROR: prefixed.) ) In the case of an unrecoverable panic from within Rust, this function ONLY returns a string containing the error.
rustg_iconforge_cache_valid_asyncReturns a job_id for use with rustg_iconforge_check()
rustg_redis_connect_rqConnects to a given redis server.
/proc/rustg_redis_disconnect_rqDisconnects from a previously connected redis server
rustg_redis_lpushhttps://redis.io/commands/lpush/
rustg_redis_lrangehttps://redis.io/commands/lrange/
rustg_redis_lpophttps://redis.io/commands/lpop/
/proc/rustg_unix_timestampReturns the timestamp as a string
rustg_worley_generateThis proc generates a noise grid using worley noise algorithm

Define Details

rustg_acreplace

Run the specified replacement engine with the provided haystack text to replace, returning replaced text.

Arguments:

rustg_acreplace_with_replacements

Run the specified replacement engine with the provided haystack text to replace, returning replaced text.

Arguments:

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:

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:

rustg_decode_base64

Decode a given base64 string

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_encode_base64

Encode a given string into base64

rustg_git_commit_date

Returns the date of the given revision in the format YYYY-MM-DD. Returns null if the revision is invalid.

rustg_git_revparse

Returns the git hash of the given revision, ex. "HEAD".

rustg_iconforge_cache_valid

Takes in a set of hashes, generate inputs, and DMI filepaths, and compares them to determine cache validity. input_hash: xxh64 hash of "sprites" from the cache. dmi_hashes: xxh64 hashes of the DMIs in a spritesheet, given by rustg_iconforge_generate with hash_icons enabled. From the cache. sprites: The new input that will be passed to rustg_iconforge_generate(). Returns a CacheResult with the following structure: list( "result": "1" (if cache is valid) or "0" (if cache is invalid) "fail_reason": "" (emtpy string if valid, otherwise a string containing the invalidation reason or an error with ERROR: prefixed.) ) In the case of an unrecoverable panic from within Rust, this function ONLY returns a string containing the error.

rustg_iconforge_cache_valid_async

Returns a job_id for use with rustg_iconforge_check()

rustg_iconforge_check

Returns the status of an async job_id, or its result if it is completed. See RUSTG_JOB DEFINEs.

rustg_iconforge_cleanup

Clears all cached DMIs and images, freeing up memory. This should be used after spritesheets are done being generated.

rustg_iconforge_generate

Generates a spritesheet at: [file_path][spritesheet_name]_[size_id].png The resulting spritesheet arranges icons in a random order, with the position being denoted in the "sprites" return value. All icons have the same y coordinate, and their x coordinate is equal to icon_width * position.

hash_icons is a boolean (0 or 1), and determines if the generator will spend time creating hashes for the output field dmi_hashes. These hashes can be heplful for 'smart' caching (see rustg_iconforge_cache_valid), but require extra computation.

Spritesheet will contain all sprites listed within "sprites". "sprites" format: list( "sprite_name" = list( // <--- this list is a [SPRITE_OBJECT] icon_file = 'icons/path_to/an_icon.dmi', icon_state = "some_icon_state", dir = SOUTH, frame = 1, transform = list([TRANSFORM_OBJECT], ...) ), ..., ) TRANSFORM_OBJECT format: list("type" = RUSTG_ICONFORGE_BLEND_COLOR, "color" = "#ff0000", "blend_mode" = ICON_MULTIPLY) list("type" = RUSTG_ICONFORGE_BLEND_ICON, "icon" = [SPRITE_OBJECT], "blend_mode" = ICON_OVERLAY) list("type" = RUSTG_ICONFORGE_SCALE, "width" = 32, "height" = 32) list("type" = RUSTG_ICONFORGE_CROP, "x1" = 1, "y1" = 1, "x2" = 32, "y2" = 32) // (BYOND icons index from 1,1 to the upper bound, inclusive)

Returns a SpritesheetResult as JSON, containing fields: list( "sizes" = list("32x32", "64x64", ...), "sprites" = list("sprite_name" = list("size_id" = "32x32", "position" = 0), ...), "dmi_hashes" = list("icons/path_to/an_icon.dmi" = "d6325c5b4304fb03", ...), "sprites_hash" = "a2015e5ff403fb5c", // This is the xxh64 hash of the INPUT field "sprites". "error" = "[A string, empty if there were no errors.]" ) In the case of an unrecoverable panic from within Rust, this function ONLY returns a string containing the error.

rustg_iconforge_generate_async

Returns a job_id for use with rustg_iconforge_check()

rustg_redis_connect_rq

Connects to a given redis server.

Arguments:

rustg_redis_lpop

https://redis.io/commands/lpop/

Arguments

Note: count was added in Redis version 6.2.0

rustg_redis_lpush

https://redis.io/commands/lpush/

Arguments

rustg_redis_lrange

https://redis.io/commands/lrange/

Arguments

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:

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:

rustg_worley_generate

This proc generates a noise grid using worley noise algorithm

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: