0 votes

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 !

in Engine by (15 points)

1 Answer

0 votes
Best answer

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).

by (1,644 points)
selected by

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...

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.