Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you dynamically create variables?

Asked by
Gunt_r 31
4 years ago
Edited 4 years ago

I know the title is confusing, but i'll try my best to explain what i mean in the description.

Lets say i have an xIndex and a zIndex which allow me to ieterate through a 2d array. On this 2d array, i have cubes spawning above each of the points in the grid.

I want to create a new array variable that stores my custom properties of these blocks, say isDestructible = true/false or isDestroyed = true/false.

The problem is i need to create an custom property file for each and every one of these blocks as i need them all to function independantly of each other.

What immediately comes to mind is doing something like this (pseudocode):

xIndex = *changing int variable as it iterates through the arrays*
zIndex = *the same*

for every item in grid
    local woodBlock .. ' ' .. xIndex .. ' ' .. zIndex = {isDestructible = true, isDestroyed = false} 

end

It doesnt allow me to do the method above. Is there a way to achieve this somehow?

Thanks.

0
If it isnt possible also let me know. Gunt_r 31 — 4y

Answer this question