- Edited
I'm currently working on a game that contains a handful of "data libraries" with various information to look up, which was completely fine to do entirely via GDScript dictionaries (containing ID numbers as keys, and custom objects as values) while I was setting up, but I'd like to swap over to a better structure now that I know it works.
I've been looking around at possible solutions (CSV, JSON, Resources, etc), but I'm mainly running into two issues with them:
- I need to be able to put (preferably anonymous) functions as some of the object fields. As far as I can tell, this isn't possible with either CSV or JSON, and it might be possible with Resources
- I want to have a single file per library, as opposed to one file per entry. This is fine with CSV, and can be fine with JSON, but from what I've seen it's not an option for Resources (I would need both a resource file and a script file for each entry, right?)
To give an idea what I'm working with, this is an entry in one of the library dictionaries I'm using at the moment:
"015": Card.new("Shield Bash", CardType.ATTACK_MELEE, {CardCost.STAMINA:1, CardCost.MOVE:1}, CardRarity.COMMON,
[TargetType.ENEMY, TargetPattern.SHOT_3], 50, true, 1, [],
"Runs up to target and deals 2 blunt damage. +1 damage for every tile moved. +2 damage if a shield is equipped.",
func(s,t,card):
var dmg = 2
if s.get_shield(): dmg += 2
var path = s.find_path(t.current_position)
if path: dmg += path[1].size() - 2
s.move_to(path[1][path[1].size() - 2], true, true)
var di = DamageInstance.new(dmg)
s.deal_damage(t, di, card))
Does anyone have any recommendations on how I could go about this? Worst comes to worst I can settle for having multiple files if there's no alternatives, but being able to store custom functions in each entry is a hard requirement.