Advanced Random: "Set current probability table" clearing itself?

0 favourites
  • 8 posts
From the Asset Store
Heads N Tails is an educational Ludo game of probability with visualization and in fun manner.
  • Currently Advanced Random has one defined probability table, "Testing Zone". This corresponds to an instance variable of some other objects in the game. When those objects are selected by a function that seems not to be relevant here, I want the value of that instance variable to make Advanced Random choose the corresponding probability table.

    In other words, when a tile whose variable is "Testing Zone" is selected, the current probability table should be "Testing Zone".

    When the game starts, this works. However, after several seconds, the current probability table becomes blank, and does not regain "Testing Zone" even when the tiles are continually selected.

    Some clarifying points:

    -All of the tiles currently have the value of "Testing Zone", so I know for certain that there isn't any other value getting in the way here.

    -I have a dummy variable, called "thing", also receiving the value from the tiles. By checking this, I have verified that "Testing Zone" is indeed being passed correctly.

    -I found no success at all telling Advanced Random to make WildEncounterTiles.Location the current probability table. Changing that to str(WildEncounterTiles.Location) fixed that, insofar as it works correctly at the beginning and then never again once the probability table gets reset for some reason. EDIT: After further testing, it seems either one leads to the same result, actually.

    The attached screenshot shows what I believe to be the relevant portion of the event sheet. Any help would be very much appreciated!

  • I guess I might as well put this here too.

    After trying to get to the bottom of this for several hours, I discovered that the expression AdvancedRandom.WeightedByName(WildEncounterTiles.Location) returns a value of 0. This is incomprehensible, and I can find no documentation as to why it should be doing this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did a quick test a WeightedByName returns correct values when two or more probability tables are added.

    Make sure you are picking the right WildEncounterTiles instance, and Location variables contains the right value. You can use Debug View and Browser Log to troubleshoot issues like these.

  • I think I may have stumbled upon a solution, but I'm curious to see your reaction to it.

    As far as I can tell, Calling SetCurrentProbabilityTable was failing because the string I was submitting for the probability table name contained quotation marks... like strings are supposed to. So I passed the string to a variable thing, removed the quotation marks with replace(thing, """", ""), and then passed thing to SetCurrentProbabilityTable. That appears to have fixed the initial issue of setting the current probability table (it no longer goes blank after a few seconds), though I haven't tried doing WeightedByName without setting the current table.

    Does that sound like it should have worked, or did I accidentally find my way to a bad solution?

  • I don't know, it's possible that quotation marks are not supported in probability table names.

    Why do you have them in your string in the first place?

  • I have them in the strings because as far as I can tell, Construct requires them for string-typed instance variables. I had never encountered a problem with other mechanics not playing nice with them, so this is striking me as strange.

  • Quotation marks are only needed when you set values via events. If you manually enter text values into instance or global/local variables, quotation marks are not required.

  • Oh snap, I didn't know that. Thank you! That should simplify things.

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