godotengine / godotengine/godot-docs
Tool scripts: Add a paragraph on how Inputs are handled in a tool script and how to get node references
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
**Your Godot version:** Godot 3.3.3 stable
**Issue description:**
Over the past three years I have wasted literally weeks on trying to figure out how to get my tool scripts to respond to Input. Eventually I have given up.
The[ "Running code in the Editor" ](https://docs.godotengine.org/en/stable/tutorials/misc/running_code_in_the_editor.html)docs page imho should mention, how in tool scripts, neither `_input(event)`, `_unhandled_input(event)` , `_gui_input(event)`, nor `Input.is_action_pressed("action")` works.
If should also mention the fact that
`Input.is_mouse_button_pressed(BUTTON_MIDDLE) `
`Input.is_key_pressed(KEY_SPACE)`
`Input.is_joy_button_pressed(0,JOY_BUTTON_0)`
_**do**_ work when used inside `_process()`
Imho it also really needs to mention how getting node references in `_ready()` and `onready var my_node = $MyNode` does not work in tool scripts but getting those refererences in `_init()` **_does_** work:
```swift
tool
extends Node2D
var my_node
func _init():
my_node = $MyNode
func _process(delta):
if Input.is_key_pressed(KEY_SPACE):
print(my_node.name)
```
If these things would have been on this page, it would have saved so much time and frustration and would have made using tool scripts so much more accessible and more useful to me.
**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/stable/tutorials/misc/running_code_in_the_editor.html
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.