Hello! I'm working on a save system for a large game. Here is an example of what I'm trying to do:
Grab the correct information from a node in a group:
extends Node2D
func get_object_information(target:Node2D) -> Dictionary:
var groups:Array = target.get_groups()
var objData:Dictionary = {
"Filename":target.filename,
"PosX":target.position.x,
"Pos":target.position.y,
"RotationD":target.rotation_degrees,
}
match groups:
["Building"]:
objData["BuildingName"] = target.buildingName as String
["Person"]:
objData["PersonState"] = target.state as int
return objData
It worked with if else statements, but the code got messy real fast. But with match statements, it does not work.