Equivalent of vba user defined variables

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Animabis

Hello everyone,

I am used in vba to use defined variables a lot, it looks like this:

Type Data_Player    ' Create user-defined type. 
    Ref As Integer    ' Define elements of data type. 
    Name As String
    Color As String 
End Type 

Sub CreatePlayer() 
    Dim Player_0 As Data_Player    ' Declare variable. 
    Player_0.ID = 0    ' Assign a value to an element. 
End Sub

This is particularly useful for defining parameters to be sent to the different instances of an object, I suppose that this involves the creation of a node but that it is the best practice ?

Thank a lot for your help and happy new year !

:bust_in_silhouette: Reply From: AlexTheRegent

You can use node if you know all your keys beforehand or Dictionary if you want to have dynamic keys. In case of dictionary, you will still have to create node with this dictionary as variable.
Also note that it is possible to create script that does not extends Node at all, but you will not be able to add this script to scene directly (but you can create node and make variable that will use this script).

Hi Alex,

Thank you very much for your answer ! it’s unfortunate that this is not possible, but the result is similar by creating instances of a node containing multiple variables. I prefer to avoid Dictionary, it tends to increase the number of containers and make things a little bit laborious…

Animabis | 2021-01-07 11:56