### Prop Preview Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Gets the preview Prop that follows the user's cursor before placement. Call confirm to force it to place. ```APIDOC ## Prop Preview ### Description Gets the preview Prop. This is the object that follows the user's cursor before it is actually placed. Call confirm to force it to place. ### Access ```gdscript Prop Preview ``` ### Type Prop ``` -------------------------------- ### GET Controls["Color"] Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets the ColorPickerButton control for adjusting the wall color. ```APIDOC ## [GET] Controls["Color"] ### Description Gets the ColorPickerButton control that allows the user to adjust the multiplied color of the next wall. ### Method GET ### Endpoint Controls["Color"] ### Parameters None ### Response #### Success Response (200) - **ColorPickerButton** (Object) - The color picker control. #### Response Example ```json { "ColorPickerButton": {} } ``` ``` -------------------------------- ### GET Controls["Texture"] Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets the GridMenu control for selecting the wall texture style. ```APIDOC ## [GET] Controls["Texture"] ### Description Gets the GridMenu control that allows the user to select the style of wall being drawn. ### Method GET ### Endpoint Controls["Texture"] ### Parameters None ### Response #### Success Response (200) - **GridMenu** (Object) - The texture selection menu control. #### Response Example ```json { "GridMenu": {} } ``` ``` -------------------------------- ### PathTool.Confirm() Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Finishes any path started and closes loops if possible. ```APIDOC ## Confirm() ### Description Finishes any path started and closes loops if possible. ### Method Confirm ### Parameters None ### Returns void ``` -------------------------------- ### bool BlockLight Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Gets and sets whether the tool will place objects that block light. ```APIDOC ## bool BlockLight ### Description Gets and sets whether the tool will place objects that block light. ### Access ```gdscript bool BlockLight ``` ### Type bool ``` -------------------------------- ### GET Global.Editor.Tools["WallTool"] Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Accesses the WallTool instance from the editor's tools collection. ```APIDOC ## [GET] Global.Editor.Tools["WallTool"] ### Description Accesses the WallTool instance from the editor's tools collection. ### Method GET ### Endpoint Global.Editor.Tools["WallTool"] ### Parameters None ### Response #### Success Response (200) - **WallTool** (Object) - The WallTool instance. #### Response Example ```json { "WallTool": {} } ``` ``` -------------------------------- ### bool Shadow Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Gets and sets whether the tool will place objects with shadows. ```APIDOC ## bool Shadow ### Description Gets and sets whether the tool will place objects with shadows. ### Access ```gdscript bool Shadow ``` ### Type bool ``` -------------------------------- ### GET Controls["Bevel"] Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets the CheckButton control for toggling wall bevel. ```APIDOC ## [GET] Controls["Bevel"] ### Description Gets the CheckButton control that allows the user to toggle the bevel of the next wall. ### Method GET ### Endpoint Controls["Bevel"] ### Parameters None ### Response #### Success Response (200) - **CheckButton** (Object) - The bevel toggle control. #### Response Example ```json { "CheckButton": {} } ``` ``` -------------------------------- ### Dungeondraft .ddmod manifest example Source: https://github.com/megasploot/dungeondraft/wiki/Dungeondraft-Modding Required .ddmod manifest file for a Dungeondraft mod. Written in JSON, it informs Dungeondraft's filesystem about the mod's name, unique id, version, author, description, minimum Dungeondraft version, and optional dependencies. The dependencies field is only necessary if you use scripts from other mods. ```json { "name": "Test Mod", "unique_id": "Megasploot.TestMod", "version": "1.0.0", "author": "Megasploot", "description": "Description here", "dd_version": "1.1.0.0", "dependencies": [ "Megasploot.ParentMod" ] } ``` -------------------------------- ### GET/SET Texture Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets or sets the texture used for the next wall drawn. ```APIDOC ## [GET/SET] Texture ### Description Gets and sets the texture used for the next wall drawn. ### Method GET/SET ### Endpoint Texture ### Parameters #### Request Body (for SET) - **value** (Texture) - Required - The texture to set. ### Response #### Success Response (200) - **Texture** (Texture) - The current texture. #### Response Example ```json { "Texture": {} } ``` ``` -------------------------------- ### GET/SET Shadow Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets or sets whether the wall has a shadow below it. ```APIDOC ## [GET/SET] Shadow ### Description Gets and sets whether the wall has a shadow below it. ### Method GET/SET ### Endpoint Shadow ### Parameters #### Request Body (for SET) - **value** (bool) - Required - Whether the wall has a shadow. ### Response #### Success Response (200) - **Shadow** (bool) - Whether the wall has a shadow. #### Response Example ```json { "Shadow": true } ``` ``` -------------------------------- ### Get asset list with Script.GetAssetList Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Returns an Array of Strings populated by the path to all the assets of that category. Valid categories include Terrain, Patterns, Objects, Walls, and more. ```gdscript Array Script.GetAssetList(String category) ``` -------------------------------- ### GetCustomColor() Source: https://github.com/megasploot/dungeondraft/wiki/Prop Gets the custom color of the Prop. ```APIDOC ## GetCustomColor() ### Description Gets the custom color. See [Color](https://docs.godotengine.org/en/stable/classes/class_color.html). ### Returns Color - The custom color. ``` -------------------------------- ### int ActiveLayer Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Gets and sets whether the tool's layer. ```APIDOC ## int ActiveLayer ### Description Gets and sets whether the tool's layer. ### Access ```gdscript int ActiveLayer ``` ### Type int ``` -------------------------------- ### EndSection() Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Ends the current section started with BeginSection(). ```APIDOC ## EndSection() ### Description Ends the section and all UI controls created afterwards will not be included in the previous section. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters None ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.BeginSection(true) # Add controls here tool_panel.EndSection() ``` ``` -------------------------------- ### GET/SET Bevel Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets or sets whether the next wall should have beveled corners. ```APIDOC ## [GET/SET] Bevel ### Description Gets and sets whether the next wall should have beveled corners. ### Method GET/SET ### Endpoint Bevel ### Parameters #### Request Body (for SET) - **value** (bool) - Required - Whether the wall should have beveled corners. ### Response #### Success Response (200) - **Bevel** (bool) - Whether the wall should have beveled corners. #### Response Example ```json { "Bevel": true } ``` ``` -------------------------------- ### GET/SET Color Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Gets or sets the next wall's multiplied color. ```APIDOC ## [GET/SET] Color ### Description Gets or sets the next wall's multiplied color. ### Method GET/SET ### Endpoint Color ### Parameters #### Request Body (for SET) - **value** (Color) - Required - The color to set. ### Response #### Success Response (200) - **Color** (Color) - The current color. #### Response Example ```json { "Color": {} } ``` ``` -------------------------------- ### Combine Global.Root with a relative path for icons Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Global.Root is the base directory of the mod a script is packaged in. It is helpful for locating other files inside a mod, like a PNG file for icons. For example, you can assign a variable to a PNG filename by combining the Root name with a known relative path. ```gdscript var icon = Global.Root + "icons/example_tool.png" ``` -------------------------------- ### Tool Script minimum viable script Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Introduction The smallest Tool Script. The script_class variable must be "tool" for Dungeondraft to recognize it as a tool script. The start() method is called after the script instance is created and after drawing assets are loaded, but not on the welcome screen. ```gdscript var script_class = "tool" func start(): pass ``` -------------------------------- ### Access all tools via Global.Editor.Tools Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Provides access to every tool in Dungeondraft by name. For example, you can access the Object Tool by indexing the variable in this manner: Global.Editor.Tools["ObjectTool"]. ```gdscript Array Global.Editor.Tools ``` -------------------------------- ### Get active mods with Script.GetActiveMods Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Returns an Array of Strings of unique IDs of all active mods. ```gdscript Array Script.GetActiveMods() ``` -------------------------------- ### PathTool.StartPath() Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Creates a new path with zero points and sets it as the ActivePath. ```APIDOC ## StartPath() ### Description Creates a new path with zero points and sets it as the ActivePath. ### Method StartPath ### Parameters None ### Returns void ``` -------------------------------- ### void Confirm() Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Makes real the preview and cycles to a new Preview. Call this method to make the Preview a real object. ```APIDOC ## void Confirm() ### Description Makes real the preview and cycles to a new Preview. Call this method to make the Preview a real object. ### Method Confirm ### Parameters None ### Returns void ``` -------------------------------- ### void PromoteCustomColor() Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool Updates the Preview with any changes in custom color. ```APIDOC ## void PromoteCustomColor() ### Description Updates the Preview with any changes in custom color. ### Method PromoteCustomColor ### Parameters None ### Returns void ``` -------------------------------- ### CreateTextureGridMenu(String id, String category, bool show_preview) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot GridMenu filled with assets from a specified asset category. ```APIDOC ## CreateTextureGridMenu(String id, String category, bool show_preview) ### Description Creates and returns a Godot GridMenu filled with assets from the specified Dungeondraft asset category. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this grid menu. - **category** (String) - Required - The asset category to populate the grid with. - **show_preview** (bool) - Required - If true, shows a preview of the selected asset. ### Returns - **GridMenu** - The created Godot GridMenu instance. ### Example ```gdscript var my_grid = tool_panel.CreateTextureGridMenu("textures", "Floors", true) ``` ``` -------------------------------- ### BeginSection(bool stretch) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Begins a section that encloses subsequently created UI controls. ```APIDOC ## BeginSection(bool stretch) ### Description Encloses all UI controls created afterwards inside a section. Must be closed with EndSection(). The parameter stretch causes the section to extend all the way to the bottom of the panel. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **stretch** (bool) - Required - If true, the section extends to the bottom of the panel. ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.BeginSection(true) # Add controls here tool_panel.EndSection() ``` ``` -------------------------------- ### CreateColorPalette(String id, bool property_only, String default, Array presets, bool multiselect, bool init_tool_color) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Dungeondraft ColorPalette control filled with preset colors. ```APIDOC ## CreateColorPalette(String id, bool property_only, String default, Array presets, bool multiselect, bool init_tool_color) ### Description Creates and returns a Dungeondraft UI control called a ColorPalette and fills it through the presets array. The Strings should be in hex color code format. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this color palette. - **property_only** (bool) - Required - If true, the palette is property-only. - **default** (String) - Required - The default color in hex format (e.g., "#FFFFFF"). - **presets** (Array) - Required - An array of hex color strings to populate the palette. - **multiselect** (bool) - Required - If true, multiple colors can be selected. - **init_tool_color** (bool) - Required - If true, initializes the tool color. ### Returns - **ColorPalette** - The created ColorPalette instance. ### Example ```gdscript var my_palette = tool_panel.CreateColorPalette("colors", false, "#FF0000", ["#FF0000", "#00FF00"], false, true) ``` ``` -------------------------------- ### CreateDropdownMenu(String id, Array options, String default) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot OptionButton (dropdown menu) with the given options. ```APIDOC ## CreateDropdownMenu(String id, Array options, String default) ### Description Creates and returns a Godot OptionButton (which is a dropdown menu) and autofill the menu with options. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this dropdown menu. - **options** (Array) - Required - An array of strings representing the options to display in the dropdown. - **default** (String) - Required - The default selected option. ### Returns - **OptionButton** - The created Godot OptionButton instance. ### Example ```gdscript var my_dropdown = tool_panel.CreateDropdownMenu("choice", ["Option A", "Option B"], "Option A") ``` ``` -------------------------------- ### CreateLabeledDropdownMenu(String id, String label, Array options, String default) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot OptionButton with a label and autofilled options. ```APIDOC ## CreateLabeledDropdownMenu(String id, String label, Array options, String default) ### Description Creates and returns a Godot OptionButton (which is a dropdown menu) with a label and autofill the menu with options. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this dropdown menu. - **label** (String) - Required - The label to display next to the dropdown. - **options** (Array) - Required - An array of strings representing the options to display in the dropdown. - **default** (String) - Required - The default selected option. ### Returns - **OptionButton** - The created Godot OptionButton instance. ### Example ```gdscript var my_labeled_dropdown = tool_panel.CreateLabeledDropdownMenu("choice", "Select:", ["Option A", "Option B"], "Option A") ``` ``` -------------------------------- ### Create a custom tool with Global.Editor.Toolset.CreateModTool Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Creates a new tool inside Dungeondraft and automatically generates a Tool Panel as the return. The category is the set of tools the new tool will show under. The id is the internal tool name, while the name is displayed to the end user. The icon is the path to a PNG to use as the button. ```gdscript ToolPanel Global.Editor.Toolset.CreateModTool(Reference script_instance, String category, String id, String name, String icon) ``` -------------------------------- ### POST Confirm() Source: https://github.com/megasploot/dungeondraft/wiki/WallTool Confirms the wall creation from the polyline. ```APIDOC ## [POST] Confirm() ### Description Takes the polyline from WorldUI and turns it into a Wall and adds it into the Walls children. ### Method POST ### Endpoint Confirm() ### Parameters None ### Response #### Success Response (200) - **void** - No return value. #### Response Example ```json {} ``` ``` -------------------------------- ### CreateToggle(String id, bool default, String on_label, String on_icon_path, String off_label, String off_icon_path) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a toggle style Godot Button. ```APIDOC ## CreateToggle(String id, bool default, String on_label, String on_icon_path, String off_label, String off_icon_path) ### Description Creates and returns a toggle style Godot Button. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this toggle. - **default** (bool) - Required - The default state of the toggle (true for on, false for off). - **on_label** (String) - Required - The label to display when the toggle is on. - **on_icon_path** (String) - Required - The path to the icon to display when the toggle is on. - **off_label** (String) - Required - The label to display when the toggle is off. - **off_icon_path** (String) - Required - The path to the icon to display when the toggle is off. ### Returns - **Button** - The created toggle style Godot Button. ### Example ```gdscript var my_toggle = tool_panel.CreateToggle("my_toggle", true, "On", "res://on.png", "Off", "res://off.png") ``` ``` -------------------------------- ### Store data in binary format with File.store_var() Source: https://github.com/megasploot/dungeondraft/wiki/Saving-and-Loading-Mod-Data Saves a Dictionary to a file in binary format using Godot's File class. Use File.WRITE to open the file for writing, and store_var() to write the data. The user:// path points to Dungeondraft's User Folder. Call close() to prevent dangling file access. ```gdscript var data = { "key": "value" } var file = File.new() file.open("user://mod_data.txt", File.WRITE) file.store_var(data) file.close() ``` -------------------------------- ### CreateLayerMenu() Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns the dropdown menu for the layer system (Objects, Paths, Materials). ```APIDOC ## CreateLayerMenu() ### Description Creates and returns the dropdown menu representing the layer system for Objects, Paths, and Materials for Dungeondraft. There should only ever be a single instance of this UI control per tool if needed. To inspect the current selected layer, check the variable Global.Editor.Tools["mod_tool_id"].ActiveLayer which returns the int of the layer value. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters None ### Returns - **OptionButton** - The created dropdown menu for layers. ### Example ```gdscript var layer_menu = tool_panel.CreateLayerMenu() ``` ``` -------------------------------- ### SelectTool Source: https://github.com/megasploot/dungeondraft/wiki/SelectTool Documentation for the SelectTool class, including properties, methods, and the SelectableTypes enum. ```APIDOC ## SelectTool ### Description Access the SelectTool instance via `Global.Editor.Tools["SelectTool"]`. It inherits from Tool and provides methods to manage selections, filters, and transformations. ### Properties - **Selected** (`Array`) - Gets an array of things selected by the user. - **Selectables** (`Dictionary`) - Gets a dictionary of selected things with their type as an int. - **RawSelectables** (`Array`) - Gets an array of unbeautified Selectable objects. - **Filter** (`Dictionary`) - Gets or modifies a dictionary of filtered types. Valid keys: Walls, Portals, Objects, Paths, Lights, Patterns, Roofs. - **LayerFilter** (`Dictionary`) - Gets or modifies a dictionary of filtered asset layers. Valid keys: 9999, -400, -100, 100, 200, 300, 400, 700, 900. ### Methods #### SelectThing(Node2D thing, bool value) - **Description**: External version of Select to allow safe select and deselecting of things. Automatically creates an internal Selectable if it does not exist. - **Parameters**: - `thing` (Node2D) - The thing to select or deselect. - `value` (bool) - Whether to select (true) or deselect (false). #### SelectThingsInsideBox(Rect2 box) - **Description**: Select things inside the given Rect2 in world space while respecting current filters. - **Parameters**: - `box` (Rect2) - The rectangle in world space to select within. #### Delete() - **Description**: Deletes all selected things. #### IsDeletable(Selectable s) - **Description**: Returns true if the Selectable s is a deletable type. - **Parameters**: - `s` (Selectable) - The Selectable to check. - **Returns**: `bool` - True if deletable. #### DeselectAll() - **Description**: Removes all things from selection. Call ClearTransformSelection() instead to also clear selection box visuals. #### GetSelectableType(Node thing) - **Description**: Gets the SelectableType of the thing. - **Parameters**: - `thing` (Node) - The thing to get the type of. - **Returns**: `int` - The SelectableType as an int. #### GetSelectable(Node2D thing) - **Description**: Gets the Selectable of a thing. Only works for things already inside the selection. Otherwise, use Select(Node2D thing). - **Parameters**: - `thing` (Node2D) - The thing to get the Selectable for. - **Returns**: `Selectable` - The Selectable object. #### EnableTransformBox(bool value) - **Description**: Turns on and off the selection box visuals. - **Parameters**: - `value` (bool) - Whether to enable (true) or disable (false) the selection box visuals. #### ClearTransformSelection() - **Description**: Deselects all things and also removes the selection box visuals. #### GetSelectionRect() - **Description**: Returns a Rect2 that encloses all selected things. - **Returns**: `Rect2` - The bounding rectangle of the selection. #### RotateTransformBox(float rotation) - **Description**: Rotates every thing that can be rotated in degrees by the center of the box. - **Parameters**: - `rotation` (float) - The rotation in degrees. #### MirrorTransformBox() - **Description**: Horizontally flip all transformable things along center of the box. #### Lock() - **Description**: Toggles the lock on selected things. Use carefully. #### IsSelectionLocked() - **Description**: Returns true if the first thing the user selected is locked. - **Returns**: `bool` - True if locked. #### MakePrefab() - **Description**: Prompts the user to make the current selection into a prefab. #### Separate() - **Description**: Separate the current selected prefab into individual pieces and disassociating with the prefab. #### MergeWalls() - **Description**: Merges walls if there are more than one wall selected that can be merged. Incompatible with a selection of mixed types. ### SelectableTypes Enum - `Invalid = 0` - `Wall = 1` - `PortalFree = 2` - `PortalWall = 3` - `Object = 4` - `Pathway = 5` - `Light = 6` - `PatternShape = 7` - `Roof = 8` ``` -------------------------------- ### CreateButton(String label, String icon_path) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot Button with the given label and icon path. ```APIDOC ## CreateButton(String label, String icon_path) ### Description Creates and returns a Godot Button with the given label and icon path. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **label** (String) - Required - The text to display on the button. - **icon_path** (String) - Required - The path to the icon to display on the button. ### Returns - **Button** - The created Godot Button instance. ### Example ```gdscript var my_button = tool_panel.CreateButton("Click Me", "res://icon.png") ``` ``` -------------------------------- ### Global.Editor.Toolset.CreateModTool Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Creates a new tool inside Dungeondraft and automatically generates a Tool Panel as the return. The category determines where the tool appears, and the id and name are used for identification and display. ```APIDOC ## Global.Editor.Toolset.CreateModTool ### Description Creates a new tool inside Dungeondraft and automatically generates a Tool Panel as the return. ### Signature `ToolPanel Global.Editor.Toolset.CreateModTool(Reference script_instance, String category, String id, String name, String icon)` ### Parameters - **script_instance** (Reference) - Required - The script instance for the tool. - **category** (String) - Required - The set of tools the new tool will show under. Valid options are: Design, Terrain, Objects, Effects, Settings. - **id** (String) - Required - The internal tool name. - **name** (String) - Required - The name displayed to the end user. - **icon** (String) - Required - The path to a PNG to use as the button. ### Returns ToolPanel - The automatically generated Tool Panel. ``` -------------------------------- ### CreateLabel(String label) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates a Godot Label with the given text. ```APIDOC ## CreateLabel(String label) ### Description Creates a Godot Label with the text as the parameter. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **label** (String) - Required - The text to display in the label. ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.CreateLabel("Hello World") ``` ``` -------------------------------- ### CreateCheckButton(String label, String id, bool default) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot CheckButton. ```APIDOC ## CreateCheckButton(String label, String id, bool default) ### Description Creates and returns a Godot CheckButton. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **label** (String) - Required - The text to display next to the check button. - **id** (String) - Required - The unique identifier for this check button. - **default** (bool) - Required - The default state of the check button (true for checked, false for unchecked). ### Returns - **CheckButton** - The created Godot CheckButton instance. ### Example ```gdscript var my_check = tool_panel.CreateCheckButton("Enable Feature", "feature_enabled", true) ``` ``` -------------------------------- ### CreateNote(String note) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates a note to display on the panel. ```APIDOC ## CreateNote(String note) ### Description Creates a note to display on the panel. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **note** (String) - Required - The text of the note to display. ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.CreateNote("This is a note.") ``` ``` -------------------------------- ### CreateRightsidePanel(String name) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a right-side panel for additional UI controls. ```APIDOC ## CreateRightsidePanel(String name) ### Description Creates and returns a Dungeondraft right-side panel that behaves like the left-side tool panel and allows you to add more UI controls for your mod. Must be called from a ToolPanel you created for your mod tool, as it is registered to the tool. It will automatically open and close when your tool is selected. Only one is supported per tool. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **name** (String) - Required - The name of the right-side panel. ### Returns - **ToolPanel** - The created right-side ToolPanel instance. ### Example ```gdscript var right_panel = tool_panel.CreateRightsidePanel("My Panel") ``` ``` -------------------------------- ### Properties Source: https://github.com/megasploot/dungeondraft/wiki/WorldUI Properties of the WorldUI class that control cursor appearance and snapping behavior. ```APIDOC ## Properties ### CursorMode - **Type**: int - **Description**: Gets or sets the type of cursor the active tool should use. Values: 0 = Off, 1 = Point, 2 = Tile, 3 = Vertex, 4 = Segment, 5 = Circle, 6 = Texture. ### UseHalfSnap - **Type**: bool - **Description**: Gets or sets if the snapping of the active tool snaps in the middle of a grid unit. ### Texture - **Type**: bool - **Description**: Gets or sets the preview Texture shown on the cursor. Only used by the PortalTool. ``` -------------------------------- ### Functions Source: https://github.com/megasploot/dungeondraft/wiki/WorldUI Functions of the WorldUI class for managing polyline points and snapping positions. ```APIDOC ## Functions ### MarkPolyPoint() - **Return Type**: void - **Description**: Creates a new point on the polyline at the cursor position. Remember to call ClearPolyline() when you finish using it. ### UndoPolyPoint() - **Return Type**: void - **Description**: Uncreates the last polyline point. ### AddPolyPoint(Vector2 position) - **Parameters**: - **position** (Vector2) - The exact global position to add a new point. - **Return Type**: void - **Description**: Force add a new point at an exact global position. ### ClearPolyline() - **Return Type**: void - **Description**: Deletes any existing polyline points and resets it for the next use. ### GetSnappedPosition(Vector2 position) - **Parameters**: - **position** (Vector2) - The position to snap to the grid. - **Return Type**: Vector2 - **Description**: Takes any Vector2 and returns a Vector2 snapped to the grid. ``` -------------------------------- ### CreateSlider(String id, float default, float minimum, float maximum, float step, bool exponential) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Godot HSlider with optional exponential scaling. ```APIDOC ## CreateSlider(String id, float default, float minimum, float maximum, float step, bool exponential) ### Description Creates and returns a Godot HSlider. The exponential parameter makes the slider use an exponential scale. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this slider. - **default** (float) - Required - The default value of the slider. - **minimum** (float) - Required - The minimum value of the slider. - **maximum** (float) - Required - The maximum value of the slider. - **step** (float) - Required - The step size for the slider. - **exponential** (bool) - Required - If true, the slider uses an exponential scale. ### Returns - **HSlider** - The created Godot HSlider instance. ### Example ```gdscript var my_slider = tool_panel.CreateSlider("size", 10.0, 1.0, 100.0, 1.0, false) ``` ``` -------------------------------- ### CreateFileSelector(String id, String file_filter, String directory) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates a special UI control for selecting a file with OS-specific filters. ```APIDOC ## CreateFileSelector(String id, String file_filter, String directory) ### Description Creates a special UI control dedicated to selecting a file. The file_filter parameter is the file extension filter that is unique to each operating system. A modder needs to account for Windows, OSX, and Linux in the filter. The directory is the path to the default starting location for the file dialog that opens. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this file selector. - **file_filter** (String) - Required - The file extension filter (e.g., "*.png;*.jpg"). Must account for Windows, OSX, and Linux. - **directory** (String) - Required - The default directory path for the file dialog. ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.CreateFileSelector("file", "*.png;*.jpg", "user://") ``` ``` -------------------------------- ### Script.GetAssetList Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Returns an array of paths to all assets in a specified category. This is useful for tool scripts to access available assets. ```APIDOC ## Script.GetAssetList ### Description Returns an Array of Strings populated by the path to all the assets of that category. ### Signature `Array Script.GetAssetList(String category)` ### Parameters - **category** (String) - Required - The asset category. Valid categories are: Terrain, Patterns, Patterns Colorable, Caves, Roofs, Objects, Walls, Materials, Portals, Paths, Lights, Simple Tiles, Smart Tiles, Smart Tiles Double. ### Returns Array - An array of paths to all assets in the specified category. ``` -------------------------------- ### Global.Root Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Provides the base directory of the mod a script is packaged in, useful for locating other files inside a mod, such as icon PNGs. ```APIDOC ## Global.Root ### Description This name is the base directory of the mod a script is packaged in. It is helpful for locating other files inside a mod, like a PNG file for icons. ### Usage Example ```gdscript var icon = Global.Root + "icons/example_tool.png" ``` ``` -------------------------------- ### PathTool.SetBlockLight(bool value) Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Updates whether the current unfinished path should block light. ```APIDOC ## SetBlockLight(bool value) ### Description Updates whether the current unfinished path should block light. ### Method SetBlockLight ### Parameters - **value** (bool) - Required - Whether the path should block light. ### Returns void ``` -------------------------------- ### CreateRange(String id, float minimum, float maximum, float step, float default_minimum, float default_maximum) Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates and returns a Dungeondraft RangeSlider control for selecting a range of values. ```APIDOC ## CreateRange(String id, float minimum, float maximum, float step, float default_minimum, float default_maximum) ### Description Creates and returns a Dungeondraft unique UI control RangeSlider. This control allows the user to pick a range of values instead of a single value. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters - **id** (String) - Required - The unique identifier for this range slider. - **minimum** (float) - Required - The minimum value of the range. - **maximum** (float) - Required - The maximum value of the range. - **step** (float) - Required - The step size for the range. - **default_minimum** (float) - Required - The default minimum value of the selected range. - **default_maximum** (float) - Required - The default maximum value of the selected range. ### Returns - **RangeSlider** - The created RangeSlider instance. ### Example ```gdscript var my_range = tool_panel.CreateRange("range", 0.0, 100.0, 1.0, 20.0, 80.0) ``` ``` -------------------------------- ### Prop Properties Source: https://github.com/megasploot/dungeondraft/wiki/Prop Properties of the Prop class: Sprite, Texture, and BlockLight. ```APIDOC ## Prop Properties ### Sprite - **Type**: Sprite - **Description**: Gets the Godot Sprite that displays the image of this Prop. ### Texture - **Type**: Texture - **Description**: Gets the Texture of this Prop. ### BlockLight - **Type**: bool - **Description**: Gets the flag that indicates if this object blocks light. ``` -------------------------------- ### ScatterTool Source: https://github.com/megasploot/dungeondraft/wiki/ScatterTool Documentation for the ScatterTool, including its controls, properties, and functions. ```APIDOC ## [ScatterTool] Overview ### Description The ScatterTool is used to scatter objects in the Dungeondraft editor. It is accessed via `Global.Editor.Tools["ScatterTool"]` and inherits from the Tool class. ### Access `Global.Editor.Tools["ScatterTool"]` ### Controls Controls are UI elements that can be accessed by indexing `Controls[id]`. - **Controls["Rotation"]** (RangeSlider) - Adjusts the range of random rotation. - **Controls["Scale"]** (RangeSlider) - Adjusts the range of random scaling. - **Controls["Spread"]** (HSlider) - Adjusts how far apart to spread the objects. ### Properties - **Preview** (Prop) - Gets the preview Prop that follows the user's cursor before placement. Call `confirm` to force placement. - **ActiveLayer** (int) - Gets and sets the tool's layer. - **Shadow** (bool) - Gets and sets whether the tool will place objects with shadows. - **BlockLight** (bool) - Gets and sets whether the tool will place objects that block light. ### Functions - **PromoteCustomColor()** (void) - Updates the Preview with any changes in custom color. ``` -------------------------------- ### Reference map objects by NodeID with get_meta(), GetNodeByID(), and HasNodeID() Source: https://github.com/megasploot/dungeondraft/wiki/Saving-and-Loading-Mod-Data These three calls manage map asset instances by their NodeID. get_meta("node_id") returns the ID to store; GetNodeByID(id) retrieves the object; HasNodeID(id) returns a bool to check existence before using the ID, preventing crashes across sessions. ```gdscript var id = thing.get_meta("node_id") ``` ```gdscript var thing = Global.World.GetNodeByID(id) ``` ```gdscript Global.World.HasNodeID(id) ``` -------------------------------- ### Store data as JSON text with JSON.print() and store_line() Source: https://github.com/megasploot/dungeondraft/wiki/Saving-and-Loading-Mod-Data Saves a Dictionary as human-readable JSON text using JSON.print() and store_line(). This format is slower but readable and easier to fix if corrupted. Use File.WRITE to open the file for writing. ```gdscript var data = { "key": "value" } var file = File.new() file.open("user://mod_data.txt", File.WRITE) file.store_line(JSON.print(data, "\t")) file.close() ``` -------------------------------- ### Load JSON text data with File.get_as_text() and JSON.parse() Source: https://github.com/megasploot/dungeondraft/wiki/Saving-and-Loading-Mod-Data Loads JSON text data saved with JSON.print(). Use File.READ to open the file, get_as_text() to read the entire file (not get_line(), because JSON includes newlines), and JSON.parse() to convert the text back into a Dictionary. ```gdscript var file = File.new() file.open("user://mod_data.txt", File.READ) var line = file.get_as_text() var data = JSON.parse(line).result file.close() ``` -------------------------------- ### SetBlockLight(bool value) Source: https://github.com/megasploot/dungeondraft/wiki/Prop Sets whether or not this object will block light. ```APIDOC ## SetBlockLight(bool value) ### Description Sets whether or not this object will block light. ### Parameters - **value** (bool) - Required - The value indicating whether the object blocks light. ### Returns void ``` -------------------------------- ### Global.Editor.Tools Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Reference Provides access to every tool in Dungeondraft by name. You can access a specific tool by indexing the array with the tool's name. ```APIDOC ## Global.Editor.Tools ### Description Provides access to every tool in Dungeondraft by name. For example, you can access the Object Tool by indexing the variable in this manner `Global.Editor.Tools["ObjectTool"]`. ### Type Array ### Access Global.Editor.Tools ### Valid Tool Names - SelectTool - TextTool - PrefabTool - FloorShapeTool - PatternShapeTool - WallTool - PortalTool - RoofTool - PathTool - ObjectTool - ScatterTool - CaveBrush - WaterBrush - TerrainBrush - MaterialBrush - Environment - LightTool - Generator - MapSettings - LevelSettings - LayerSettings - TraceImage ``` -------------------------------- ### Tool Enable/Disable Source: https://github.com/megasploot/dungeondraft/wiki/Tool Methods to enable and disable a Dungeondraft tool. ```APIDOC ## Enable() ### Description Enables the tool to perform tasks. This is also called internally when a tool is selected in the toolbar. The tool will not work without being first enabled. ### Method Enable ### Parameters None ### Returns void ``` ```APIDOC ## Disable() ### Description Disables the tool. Must be called when you are done with a tool to clean up. ### Method Disable ### Parameters None ### Returns void ``` -------------------------------- ### Controls["Scale"] Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool An HSlider control that allows the user to adjust the object scaling. ```APIDOC ## HSlider Controls["Scale"] ### Description Allows the user to adjust the object scaling. ### Access ```gdscript HSlider Controls["Scale"] ``` ### Type HSlider ``` -------------------------------- ### PathTool.SetFadeIn(bool value) Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Marks future paths to fade in. ```APIDOC ## SetFadeIn(bool value) ### Description Marks future paths to fade in. ### Method SetFadeIn ### Parameters - **value** (bool) - Required - Whether to fade in. ### Returns void ``` -------------------------------- ### Export Format Script minimum viable script Source: https://github.com/megasploot/dungeondraft/wiki/Scripting-Introduction The smallest Export Format Script. The script_class must be "export_format". The export_format_name is shown in the export window, export_file_extension is the file extension, export_image_format must be "png", "jpg", or "webp", and show_quality_slider displays the quality slider. The process() method is called after the imaging step of the export process. ```gdscript var script_class = "export_format" var export_format_name = "Export Format Name" var export_file_extension = "myexportextension" var export_image_format = "webp" var show_quality_slider = true func start(): pass func process(path : String, image : File, ppi : int): pass ``` -------------------------------- ### CreateSeparator() Source: https://github.com/megasploot/dungeondraft/wiki/ToolPanel Creates a separator line in the panel. ```APIDOC ## CreateSeparator() ### Description Creates a separator. ### Method N/A (This is a method of the ToolPanel class, not an HTTP endpoint) ### Parameters None ### Returns - **void** - This method does not return a value. ### Example ```gdscript tool_panel.CreateSeparator() ``` ``` -------------------------------- ### PathTool.SetFadeOut(bool value) Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Marks future paths to fade out. ```APIDOC ## SetFadeOut(bool value) ### Description Marks future paths to fade out. ### Method SetFadeOut ### Parameters - **value** (bool) - Required - Whether to fade out. ### Returns void ``` -------------------------------- ### PathTool.UpdatePath() Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Updates the visuals of the current unfinished path. ```APIDOC ## UpdatePath() ### Description Updates the visuals of the current unfinished path. ### Method UpdatePath ### Parameters None ### Returns void ``` -------------------------------- ### PathTool.SetTransitionIn(int value) Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Sets the type of transition for the fade. 0 is disable, 1 is fade in, 2 is grow/shrink. ```APIDOC ## SetTransitionIn(int value) ### Description Sets the type of transition for the fade. 0 is disable, 1 is fade in, 2 is grow/shrink. ### Method SetTransitionIn ### Parameters - **value** (int) - Required - Transition type: 0 disable, 1 fade in, 2 grow/shrink. ### Returns void ``` -------------------------------- ### PathTool.SetTransitionOut(int value) Source: https://github.com/megasploot/dungeondraft/wiki/PathTool Sets the type of transition for the fade. 0 is disable, 1 is fade in, 2 is grow/shrink. ```APIDOC ## SetTransitionOut(int value) ### Description Sets the type of transition for the fade. 0 is disable, 1 is fade in, 2 is grow/shrink. ### Method SetTransitionOut ### Parameters - **value** (int) - Required - Transition type: 0 disable, 1 fade in, 2 grow/shrink. ### Returns void ``` -------------------------------- ### Controls["Rotation"] Source: https://github.com/megasploot/dungeondraft/wiki/ObjectTool An HSlider control that allows the user to adjust the object rotation. ```APIDOC ## HSlider Controls["Rotation"] ### Description Allows the user to adjust the object rotation. ### Access ```gdscript HSlider Controls["Rotation"] ``` ### Type HSlider ``` -------------------------------- ### GetNodeByID Source: https://github.com/megasploot/dungeondraft/wiki/World Retrieves an Asset Instance node by its ID. ```APIDOC ## World.GetNodeByID ### Description Returns an Asset Instance by its id. ### Method GetNodeByID ### Parameters - **id** (int) - Required - The id of the Asset Instance to retrieve. ### Returns - **Node** - The Asset Instance with the given id. ```