Using Advanced Random with my Json table

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi everyone,

    I'm just discovered the Advanced Random plugin and think I can use it for my game when I need to drop pick up some loot randomly.

    For now I create an array as a .Json file to manage my loot:

    The column 0 is for the name, the 1 is for the rarity of my object and the 3 is for the object cost. For now I don't need to use the "Cost" column for what I want to do.

    My main idea is to use the rarity column for the weight entry in te AdvancedRandom. So for exemple I would like the object "Banana" to spawn 75 more time than the others objects.

    I tried to create my AdvancedRandom table using this code:

    I can see that is doesn't really the correct way to use the plugin, the debug show me kind of a mess and repeat 3 times my datas (because of my 3 column)

    I can I correctly set this?

  • Don't use "For each XY" loop.

    I see that you store items on Y axis in the array, the item name is at X=0 and the rarity is at X=1. So you can use this event:

    System For "y" from 0 to array.height-1
     AdvancedRandom add entry array.at(0, loopindex) with weight array.at(1, loopindex)
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah! Thank you dop2000!! I knew I was messing up with something on the axis, I still need to practice!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)