+1 vote

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;

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

TWeapon =record
    Critical, Type, Num :integer;
    Damage :TSphaeren;
in Engine by (29 points)
edited by

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()
by (2,300 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.