table_to_json(data) | → string | Convert a table to a JSON string |
Convert a table to a JSON string | ||
json_to_table(json) | → AnyBasic? | Convert a JSON string to a table. |
Convert a JSON string to a table. | ||
write_file(filename, data, append?, for_player?) | Write a file to the | |
Write a file to the | ||
remove_path(path) | Remove a file or directory in the | |
Remove a file or directory in the | ||
direction_to_string(direction) | → string | Converts the given direction into the string version of the direction. |
Converts the given direction into the string version of the direction. | ||
evaluate_expression(expression, variables?) | → double | Evaluate an expression, substituting variables as provided. |
Evaluate an expression, substituting variables as provided. | ||
encode_string(string) | → string? | Deflates and base64 encodes the given string. |
Deflates and base64 encodes the given string. | ||
decode_string(string) | → string? | Base64 decodes and inflates the given string. |
Base64 decodes and inflates the given string. | ||
parse_map_exchange_string(map_exchange_string) | → MapExchangeStringData | Convert a map exchange string to map gen settings and map settings. |
Convert a map exchange string to map gen settings and map settings. | ||
check_prototype_translations() | Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. [...] | |
Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. [...] | ||
is_valid_sound_path(sound_path) | → boolean | Checks if the given SoundPath is valid. |
Checks if the given SoundPath is valid. | ||
is_valid_sprite_path(sprite_path) | → boolean | Checks if the given SpritePath is valid and contains a loaded sprite. [...] |
Checks if the given SpritePath is valid and contains a loaded sprite. [...] | ||
create_profiler(stopped?) | → LuaProfiler | Creates a LuaProfiler, which is used for measuring script performance. [...] |
Creates a LuaProfiler, which is used for measuring script performance. [...] | ||
object_name | :: R string | The class name of this object. [...] |
The class name of this object. [...] |
filename | :: string | The name of the file. Providing a directory path (ex. |
The name of the file. Providing a directory path (ex. | ||
data | :: LocalisedString | The content to write to the file. |
The content to write to the file. | ||
append | :: boolean? | If |
If | ||
for_player | :: uint? | If given, the file will only be written for this |
If given, the file will only be written for this |
path | :: string | The path to the file or directory to remove, relative to |
The path to the file or directory to remove, relative to |
expression | :: MathExpression | The expression to evaluate. |
The expression to evaluate. | ||
variables | :: dictionary[string → double]? | Variables to be substituted. |
Variables to be substituted. |
-- Calculate the number of research units required to unlock mining productivity level 10
local formula = game.forces["player"].technologies["mining-productivity-4"].research_unit_count_formula
local units = helpers.evaluate_expression(formula, { L = 10, l = 10 })