So lets say I have this script
#name of the script is example.gd
extends Node
var x = 0
var y = 0
func _ready():
pass
static func test1(x_val):
x = x_val
static func test2(y_val):
y = y_val
and lets say I have another script here
extend <insert node type here>
var z = preload("example.gd")
func _ready():
z.test(10)
z.test2(20)
I would get an error that originates in example.gd test and test2 function because x and y are both not defined (even though they are). How can I use variables I initialized earlier in inside the script in static functions?
Update: When I try to preload one script into another, and call a function from the script I preloaded, I get an error saying I can't call non-static functions. That is why even though static functions aren't suitable in this case, I tried to use them. If there is a way to use one script from another script, that is more what I am looking for.