dngbae2
(dngbae2)
December 21, 2021, 10:38pm
1
Is there a Structure data type in Roblox that allows us to hold data like in C++?
For example, this is something you would do in C++:
struct account
{
string name;
double money;
};
int main() {
account player1 = new account();
player1.name = "Bob";
player1.money = 200;
}
1 Like
No not in Lua by default unfortunately.
1 Like
Tyler148
(Teccs)
December 21, 2021, 10:42pm
3
I regularly use tables in place of c++ structs.
For example,
local account = {}
account.Name = "Bob"
account.Money = 200
print(account.Name) --> Outputs Bob
2 Likes
dngbae2
(dngbae2)
December 21, 2021, 10:42pm
4
Ah. So I would have to keep track of it in two separate arrays?
1 Like
Yeah but I’ve heard of some people doing a work around to mimic this though I’m not familiar with it so you can try searching around the Forum for it (sorry I don’t have a link right now).
dngbae2
(dngbae2)
December 21, 2021, 10:45pm
6
I guess this will have to do for now.
1 Like