Cirias's Forum Posts

  • 2 posts
  • I don't understand why do you use loopindex in arr_crew.At(..., loopindex) expressions. Loopindex will correspond to the nested "While" loop, not the parent "Repeat" loop.

    By the way, instead of the safety_counter you can just use loopindex<200 condition.

    .

    This task would be a lot easier if you use JSON instead of the firstnames array.

    > {
    "elves": {
    "male": ["Aelar", "Theren", "Faelar"],
    "female": ["Lia", "Shalana", "Aeris"]
    },
    "dwarves": {
    "male": ["Borin", "Thrain", "Karg"],
    "female": ["Dis", "Hilda", "Brynja"]
    }
    }
    

    To find a random name for any species/gender:

    JSON.Get("elves.female." & int(random(JSON.ArraySize("elves.female"))))

    Hey thanks, I hadn't really thought of using JSON, but I will give it a go as I'm finding arrays crazy complex, lol

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I am trying to build logic into my game where it will assign names at random to NPCs. I have a FirstNames array which has:

    • COL 0: Gender
    • COL 1: Species
    • COL 2: Name

    I have a Crew array which is already pre-populated with Species and Gender values, so I just need this loop to match a row from the Crew to a row from FirstNames and then assign a name to that row on Crew array.

    It's currently assigning names at random, but it's not actually matching the attributes it's just picking random names.

    Can anyone help me fix this?

  • 2 posts