![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | VastView |
When I make a Resource var I’m using local to the scene of a saved scene that I instance a lot, it makes the getter in a setget var in my Resource’s code break.
Code that breaks when I switch my custom Resrouce to local to scene:
extends Resource
class_name Stats
export(Dictionary) var stats = {
"dps": 0.0,
"cdr": 0.0,
"armour": 0.0,
"movespeed": 0.0,
"tenacity": 0.0,
"h_regen": 0.0,
"e_regen": 0.0
}
func get_stats():
var res = {}
for key in stats:
res[Enums.stat[key]] = stats[key]
return res
func set_stat(stat_type, new_value):
stats[Enums.stat.keys()[stat_type]] = new_value
Short explanation of the stats
var:
This dictionary gets set up with string values for keys, but when I get my stats
dictionary from another script, I convert it’s keys to their corresponding enum values. (When Resource is local to scene, the getter breaks, because when it refers to stats
it gets a dictionary with enum values as keys, not strings.