I have a simple network chat program created in Godot that I am using to teach basic encryption to high school students with. I would like to add a custom built encryption class to allow students to create their own cyphers. Here is a simple implementation I created to test the class:
class Security:
extends Resource
func _init():
print("Started.")
func encrypt():
print("Encrypting.")
In my main script, I have this code to initialise the class (I have this at the top, in the variable space, before any function definition):
const Security = preload("res://scripts/security.gd")
var sec = Security.new()
And then this in one of my functions within the script:
func send_message():
sec.encrypt()
At no point does either print message appear in the console. When I trigger the send_message function, I get the following error:
Invalid call. Nonexistent function 'encrypt' in base 'Rederence (security.gd)'.
Is there something I am doing wrong with the creation of the class, or how I add it to my script? Or is what I am trying not really doable (e.g. should I just be adding a node, adding a script to that and using that node in my scene)?
Thanks.