I'm using r119 on Chrome. r119 because when i updated to a newer release, some things that worked before didn't seemed to work, so i'll stay on r119.
I'm working on a casino game, a roulette. I receive all the information that i need (money, state of the buttons, position and value of coins), from a server running on other computer.
These days i've been struggling with construct trying to create the coins on runtime. I receive the command to make a coin and parse it's slot ID, and it's value without problem, but when i try to create a Coin with the System.Create Action, i get a headache trying to save some reference to that coin.
Note: the old versions of the program are deleted, so i only'll remake them for the pictures
First, i've tried to save the UID on a global variable and retrieve it immediately after creating the coin. pics:
..and later reference it by its UID
That worked really bad! Never put a coin.. after some debugging with the console, i found that construct only is capable of picking by uid the object on the next tick after its creation. So, i added a wait action, and then, it worked somewhat nice, only had troubles if i clicked really fast.
However, the reference says that a wait action in a for loop only will pause the currently running thread. So, the for loop will begin executing again for the next iteration if you put there a wait action. I load the coins in a for loop because i need to load several coins at once in many cases, for instance, if the game losses connection, or the players computer unluckly reboots, when the connection restablishes, the game must continue where it was left. In that context, the multithreaded environment without any system-made semaphores, really scared me. Then, i looked for another approach. Added to the Conis' CoinID variable -1 as initial value, and picked it by that value. Pic:
Worked fine, until i began sending more than one coin at once. Then it failed terribly, only put the first coin. Ignored the rest at the picking by instance variable. I put a foreach to dump all of the coins to the console, and terrified saw that always were only one coin. Furthermore, i've logged this to the chrome console immediately after the pick all Coins condition [CODE]Coins.PickedCount &" coins picked vs "&Coins.Count&"actual coins"[/CODE] and saw things like "2 coins picked vs 4 actual coins". This is where i'm stuck now, kind of desperate because of this weird behavior.
Anyway, thank you in advance for taking the time of reading all if this.