Why do I get an error when I define a two-dimensional array?

Why do I get an error when I define a two-dimensional array?

@editable
CS1:creature_spawner_device = creature_spawner_device{}
@editable
CS2:creature_spawner_device = creature_spawner_device{}
@editable
CS3:creature_spawner_device = creature_spawner_device{}
@editable
CS4:creature_spawner_device = creature_spawner_device{}
@editable
CS5:creature_spawner_device = creature_spawner_device{}
@editable
CS6:creature_spawner_device = creature_spawner_device{}

CS:creature_spawner_device = array{
array{CS1, CS2},
array{CS3, CS4},
array{CS5, CS6}
}

For example, writing code like the above would result in an error statement such that the array could not be accessed. Why is this?

Pasting your code into one of my devices the error said it’s not implemented yet. Verse is still a fairly young language, and the @editable’s are coming from the 3D environment - so perhaps it’s just not supported in Verse at this time.

It looks like you can accomplish the same thing with the following - by moving the array setting into the OnBegin of the device.

my_device := class(creative_device):
    @editable
    CS1:creature_spawner_device = creature_spawner_device{}
    @editable
    CS2:creature_spawner_device = creature_spawner_device{}
    @editable
    CS3:creature_spawner_device = creature_spawner_device{}
    @editable
    CS4:creature_spawner_device = creature_spawner_device{}
    @editable
    CS5:creature_spawner_device = creature_spawner_device{}
    @editable
    CS6:creature_spawner_device = creature_spawner_device{}

    var CS:[][]creature_spawner_device = array{}

    OnBegin<override>()<suspends> : void =
        set CS = array{
            array{CS1, CS2},
            array{CS3, CS4},
            array{CS5, CS6}
            }

It compiles without errors anyway.

1 Like

Thank you!

Thanks to you I can now use two-dimensional arrays!

I am always helped by the wisdom of the people on this forum! I appreciate it very much!:smile:

You’re welcome, if you have a moment, it’s good to set the response that provides the solution as the “Solution” (there should be a button for that at the bottom of the response that solved it).

This let’s others know it’s solved, and it puts a link to the solution up top so it’s easy for others to find it who may be searching for a solution to the same problem.

1 Like

Thank you.
I apologize for my very late reply.

I wanted to mark your response as the best answer, but I couldn’t find the “Best Answer” or “Solution” button on this page. I also couldn’t find the solution you mentioned.

Next time, I will make sure to check for those buttons so I can properly mark the best answer and help others in this forum.

This time, since I couldn’t find the button, I pressed the heart button instead.

Thank you again for your help!