there are multiple classes in this file. i want to be able to make functions that all of the classes can access
i know that this is a bad function to make. i know that it should be generalized to non four numbers. maybe i’m wrong about how modulo works in python and i don’t need it at all. do not tell me not to do this
If scope4 is a generic function then it can go into an autoload class or you have to add a class name to the outer class it exists in.
In both cases you preface the function name with its accessor/class name.
If you called your autoload Globals then s = Globals.scope4(s).
If the outer class is called class_name MyTileMap then s = MyTileMap.scope4(s)
func _ready():
var new_tile=tile.new(scope4)
func scope4(x):
return 4
class tile:
var edges=[]
var e_pol=[]
var func_scope4:Callable
func _init(scope_callable):
edges=[]
e_pol=[]
func_scope4=scope_callable
func set_edges(e,s,pool):
s=func_scope4.bind(s).call()
you will need to “send” the function to the innerclass tile when you .new() or created the class, then call the function with .call() use .bind() to fill the parameters
you treat it like another class or another script here but it’s actually a class in a class, the right way to call the function outside from inner class tile should be let it call it by sending the callable first, else use signals to communicate