:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/stag-toolkit/sphinx/gen/gdscript/StagUtils.xml. .. _class_StagUtils: StagUtils ========= **Experimental:** Changes may be made for organizational purposes. **Inherits:** ``RefCounted`` Utility constants and functions that are not bundled with Godot, but I wish were. .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary`\[``String``, ``String``\] | :ref:`get_args`\ (\ ) |static| | +---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``float`` | :ref:`factorial`\ (\ n\: ``int``\ ) |static| | +---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``Variant`` | :ref:`default`\ (\ dictionary\: ``Dictionary``, key\: ``Variant``, valuetype\: Variant.Type, override\: ``Variant`` = null, salvage\: ``bool`` = true\ ) |static| | +---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ``PackedStringArray`` | :ref:`walk_directory`\ (\ directory\: ``String``, allowed_extensions\: ``PackedStringArray``, list\: ``PackedStringArray`` = []\ ) |static| | +---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Constants --------- .. _class_StagUtils_constant_INT64_MIN: .. rst-class:: classref-constant **INT64_MIN** = ``-9223372036854775808`` :ref:`🔗` Minimum value for a 64-bit integer. Godot uses 64-bit integers by default for ``int`` types, but may use 32-bit in some cases for less memory usage, such as ``Vector2i``. .. _class_StagUtils_constant_INT64_MAX: .. rst-class:: classref-constant **INT64_MAX** = ``9223372036854775807`` :ref:`🔗` Maximum value for a 64-bit integer. Godot uses 64-bit integers by default for ``int`` types, but may use 32-bit in some cases for less memory usage, such as ``Vector2i``. .. _class_StagUtils_constant_INT32_MIN: .. rst-class:: classref-constant **INT32_MIN** = ``-2147483648`` :ref:`🔗` Minimum value for a 32-bit integer. .. _class_StagUtils_constant_INT32_MAX: .. rst-class:: classref-constant **INT32_MAX** = ``2147483647`` :ref:`🔗` Maximum value for a 32-bit integer. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_StagUtils_method_get_args: .. rst-class:: classref-method :ref:`Dictionary`\[``String``, ``String``\] **get_args**\ (\ ) |static| :ref:`🔗` Returns a dictionary of command-line arguments used to launch the program. Note that all values will be strings. For example launching a StagTest scenario: \ ``$ godot --headless --stagtest --test=res://test/scenarios/test_island_builder.tscn --timeout=60``\ :: print(StagUtils.get_args()) # outputs { "stagtest": "", "test": "res://test/scenarios/test_island_builder.tscn", "timeout": "60" } .. rst-class:: classref-item-separator ---- .. _class_StagUtils_method_factorial: .. rst-class:: classref-method ``float`` **factorial**\ (\ n\: ``int``\ ) |static| :ref:`🔗` Performs a simple factorial of the given integer. Returned as a floating-point for large numbers. Returns ``NAN`` if ``n`` is negative, as it is undefined behavior. .. rst-class:: classref-item-separator ---- .. _class_StagUtils_method_default: .. rst-class:: classref-method ``Variant`` **default**\ (\ dictionary\: ``Dictionary``, key\: ``Variant``, valuetype\: Variant.Type, override\: ``Variant`` = null, salvage\: ``bool`` = true\ ) |static| :ref:`🔗` Fetches the given key out of the dictionary, or null if not found. If the fetched value does not match the specified Variant type (``valuetype``), the value is forcibly converted to that type (applying default when necessary), unless an ``override`` of the same type is specified, at which point the override is used. If ``salvage`` is true, similiar types (such as integers and floats) are converted instead of using the provided override. The override is still applied in cases where types are not similiar (such as string and float). .. rst-class:: classref-item-separator ---- .. _class_StagUtils_method_walk_directory: .. rst-class:: classref-method ``PackedStringArray`` **walk_directory**\ (\ directory\: ``String``, allowed_extensions\: ``PackedStringArray``, list\: ``PackedStringArray`` = []\ ) |static| :ref:`🔗` Recursively walks the given directory and its subdirectories, looking for all files with the given extension list. Note that extensions are compared against the **entire filename**, rather than just the file extension. This helps with cases where Godot might append a ``.remap`` extension onto files when exporting. For example, ``res://data/level_info/data.tres`` might be exported as ``res://data/level_info/data.tres.remap``, which causes ``String``.get_extension() to just return ``remap`` instead of the original ``tres``. Returns a packed array of all filepaths. File paths that are closer to top-level directories will be ordered first in the list. :: print(StagUtils.walk_directory("res://test/scenarios/", [".tscn"])) # outputs [ "res://test/scenarios/example/test_hello_world.tscn", "res://test/scenarios/example/test_signals.tscn", "res://test/scenarios/example/test_tick_timers.tscn", "res://test/scenarios/example/test_workflow.tscn", "res://test/scenarios/island_builder/test_island_builder.tscn", "res://test/scenarios/island_builder/test_settings.tscn", "res://test/scenarios/physics_server/test_raycast.tscn", "res://test/scenarios/queues/test_queuefloat.tscn", "res://test/scenarios/rope/test_interface.tscn", "res://test/scenarios/rope/test_tension.tscn", "res://test/scenarios/utils/test_utils.tscn" ] .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`