Defines a new tool.
Usage
Arguments
| Name | Type | Description |
tool | Tool | Instance of the tool to add. |
Usage
crystal.tool.add(tool, options)
Arguments
| Name | Type | Description |
tool | Tool | Instance of the tool to add. |
options | table | Additional options specifying behavior of the tool. |
The options table supports the following values:
| Name | Type | Default | Description |
keybind | love.KeyConstant | nil | Associates a keybind with this tool. Pressing this key will toggle visibility of the tool. |
hide_command | string | nil | Automatically registers a console command to hide this tool. |
name | string | Class name of the tool (tool:class_name()) | A name used to identify this tool when calling other crystal.tool.* functions. |
show_command | string | nil | Automatically registers a console command to show this tool. |
Examples
local MyTool = Class("MyTool", crystal.Tool);
MyTool.draw = function()
love.graphics.rectangle("fill", 20, 50, 60, 120);
end
crystal.tool.add(MyTool:new());
crystal.tool.show("MyTool");
local MyTool = Class("MyTool", crystal.Tool);
MyTool.draw = function()
love.graphics.rectangle("fill", 20, 50, 60, 120);
end
crystal.tool.add(MyTool:new(), {
name = "my-favorite-tool",
show_command = "ShowMyTool",
hide_command = "HideMyTool",
});
crystal.cmd.run("ShowMyTool");