How can I run a script with "Run Script"?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By keito940
:warning: Old Version Published before Godot 3 was released.

I made a file called test.gd in order to check if the assumed result was obtained,
“Script is not Tool, will not be able run:” will appear and will not be executed.
How do I run the script with “Run Script”?

Have you tried adding the keyword tool to the top of the script?

avencherus | 2017-10-28 05:17

thx.
…but, I understood that putting the keyword tool.
Specifically, how can I do?

Code:

func _ready():
	set_process(true)
		
func _process(delta):
	for i in range(5):
		print("i:%d" % [i])
		print("data.append(_array_init)")
		for j in range(5):
			print("j:%d" % [j])
			print("data[%d].append(_arrry_init)" % [i])

keito940 | 2017-10-29 03:21

You may be looking for this: GDScript reference — Godot Engine (latest) documentation in English

avencherus | 2017-10-29 10:08

Though I would like to say thank you,
This time "Could not instance Script.
Did you Forget tool Keyword? "Has come out.
What should I do?
I think that tool was attached.
code:

tool
extends Node

var data = []

func _ready():
	for i in range(5):
		print("i:%d" % [i])
		print("data.append(_array_init)")
		for j in range(5):
			print("j:%d" % [j])
			print("data[%d].append(_arrry_init)" % [i])

keito940 | 2017-11-01 06:24

Sorry, it is not clear to me what you’re trying to do. Is this supposed be a command line run script, an instanced script from another script, a tool mode script for add-on?

avencherus | 2017-11-01 08:21

Sorry.
Do Not Use To Add-on.

keito940 | 2017-11-12 06:54

:bust_in_silhouette: Reply From: avencherus

A few years late, but I believe you were looking for how to use an EditorScript.

There is documentation now for it: EditorScript — Godot Engine (stable) documentation in English