How to Print each element of two dimensional array

Hi,

I would like to output an element of two rows by turn in two dimensional array using Print function.

Please look at the following Verse code. In For Statement, I prepare two dimensional array and try to output an element of the First row then output the one of the second row. I expected that print result is;

Reading:Q1
Judge:Card001
Reading:Q3
Judge:Card003

(Print Order of the Column is random because using Random function)

However, when starting Fortnite, the result is as following picture:

I do not make sense why the same element is printed more than one time and the second row’s element (Card001, Card002…) is not printed correctly.

Please tell me how to print a result as I expected.

Thank you,

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /Verse.org/Colors }

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
Source := class(creative_device):

    # array in which Question & Judge elements are set
    var ReadingCards: [][]string = array{array{"Q1", "Card001"},array{"Q2", "Card002"},array{"Q3","Card003"}, array{"Q4","Card004"}, array{"Q5","Card005"}}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Sleep(3.0)
        # Shuffle the array for Game
        var ShuffledReadings : [][]string = array{}
        set ShuffledReadings = Shuffle(ReadingCards)
        # Game Start
        Sleep(3.0)
        if (NumberOfColumns : int = ShuffledReadings[0].Length):
            for(Row := 0..ShuffledReadings.Length-1, Column := 0..NumberOfColumns):
                # Print the first row's elements{Q1, Q2....Q5}one by one
                if (Question := ShuffledReadings[Row][0]):
                    Print("Reading:{Question}")
                # Print the first row's element{Card001, Card002....Card005}one by one
                if (Judge := ShuffledReadings[1][Row]):
                    Print("Judge:{Judge}")

I’m not sure what you want to do but if i understood it well is as simple as change the last if statement to the next i show you:
image

I show you the output it display to check if it is correct:

And if you want to do it the amount of times of your array lenght you should remove the 2nd statement of your loop, like this:
image

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.