Could I use a script twice but with slight tweaks to stuff like paths to getting nodes etc.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tofu

I have an AI script that uses some spatial nodes to set up a patrol route. Right now it gets the spatial nodes on ready however I have realized that I will want multiple AI with their own patrol routes. How would I then use this AI script but change small parts of it?

:bust_in_silhouette: Reply From: aXu_AP

Use export variables so that you can set them from editor for each instance. Something like this:

export var target_path : NodePath
var target

func _ready() -> void:
	if target_path:
		target = get_node(target_path)
:bust_in_silhouette: Reply From: KaWa

Use the export function.

export(int) var Test = 0

There you can set a number value in the Editor and use it in Code for example.