0 votes

Is there a way to create your own type in GDScript like TSphaeren in the Pascal example?

TSphaeren = record
    physical, Fire, Cold, Lightning, Chaos :integer;
end;

TArmour = record
    AntiCritical, Type, Num :integer;   
    Resistances :TSphaeren;
end;

TWeapon =record
    Critical, Type, Num :integer;
    Damage :TSphaeren;
end;
asked Aug 24, 2018 in Engine by MakLinux (28 points)
edited Aug 31, 2018 by MakLinux

1 Answer

0 votes

Using inner class:

class TSphaeren extends Reference:
    var physical : int
    var Fire : int
    var Cold : int
    var Lightning : int
    var Chaos : int

You can use it in other scripts by doing something like:

const ScriptWithTSphaeren = preload("res://ScriptWithTSphaeren.gd")

var foo = ScriptWithTSphaeren.TSphaeren.new()
answered Aug 24, 2018 by hilfazer (1,952 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.