Last active
July 31, 2024 19:05
-
-
Save freehuntx/b77d33058e1dffe121e29988783393d4 to your computer and use it in GitHub Desktop.
Godot globalz - Simple globals class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name Globalz | |
static var _globals := {} | |
static func write(key: String, value: Variant) -> void: | |
_globals[key] = value | |
static func read(key: String) -> Variant: | |
return _globals.get(key) | |
static func has(key: String) -> bool: | |
return key in _globals | |
static func delete(key: String) -> void: | |
_globals.erase(key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func _init(): | |
print(Globalz.read("some.key")) | |
Globalz.write("some.key", "value") | |
print(Globalz.read("some.key")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment