Skip to main content

Tool

This is the self in tool scripts.

It provides a Lua API for getting input, setting properties, and interacting with the scene.

You can make custom tools by creating a package and making tools folder and making tool folders in there. Check the core package for example, the tools have a tool.toml.

Drag tool is great sample to look at since it has tool settings. Functions below can help you read tool settings from the tool script. Good luck bestie, you can always ask for help in the server land.

Functions

note

Make sure to use :function() and not .function(), or you'll get an error


:pointer_pos()

Get the current cursor position in world coordinates


:grid_pointer_pos()

Get the cursor position snapped to the grid


:grid_enabled()

Returns whether grid snapping is enabled


:grid_multiplier()

Returns the current grid multiplier


:grid_size()

Returns the current grid size


:key_just_pressed()

Returns whether a key was just pressed this frame


:key_just_released()

Returns whether a key was just released this frame


:key_pressed()

Returns whether a key is currently being held down


:pointer_just_pressed()

Returns whether the pointer was just pressed this frame


:pointer_just_released()

Returns whether the pointer was just released this frame


:pointer_pressed()

Returns whether the pointer is currently being held down


:pointer_locked()

Returns whether the pointer is currently locked


:preferred_pointer_pos()

Returns the preferred pointer position (snapped if grid is enabled)


:snap_if_preferred()

Snaps a position to grid if preferred (based on grid enabled state)


:snap_pointer_pos()

Snaps a position to the grid regardless of grid enabled state


:set_cursor()

Sets the cursor icon


:get_property()

Gets a property value by ID


:get_properties()

Gets all properties as a table


:set_property()

Sets a property value.


:get_selected_objects()

Gets a list of currently selected objects


:get_selected_attachments()

Gets a list of currently selected attachments


:set_selected_objects()

Sets the currently selected objects


:set_selected_attachments()

Sets the currently selected attachments


:clear_selection()

Clears all current selections