Item overwrites previous item in list

What's problem you are encountering?
I am trying to develop a match 3 game, like Candy Crush. So far, I created 4 different costumes, within 1 sprite. My script then builds a 3 row by 6 column tiles, but I am having a problem. Sometimes, when I click of the green flag, the very first tile gets overwritten with the second tile. Since I have not setup a random tile picker as of yet, the first row should display.....
"purple_tile", "green_tile", "red_tile", "yellow_tile", "purple_tile", "green_tile".
However, sometimes, I get this instead....
"green_tile", "green_tile", "red_tile", "yellow_tile", "purple_tile", "green_tile". As you can see, after the script runs, it replaces the first tile, which should be "purple_tile", and changes it to "green_tile". What gives? I am not telling the script to do this, and this incident does not happen all of the time.

What have you tried that didn't work?
I tried closing the project, and then reopening it, which once in a while fixes the problem, but it's not a permenent fix. Eventually, I will end up with having the same problem again.

Post a project example, link, or screenshot:
I would post my project, but posting the copied URL here, just loads a blank project

To share a project (and get the url) click file > open > click on the project > share

Once you share the project, you can then open it up, and it should change the url in the url bar to link to he project. You can then copy/paste that here. If it doesn't give you the link, you can click on the cloud icon, and then click open in community site, then share that url.


here is my project

Its worked fine for me (tried it 10 times)

But I notice this

so its possible your getting a race condition in that xpos is being changed faster than the clones are being created and then them moving

Better idea might be to create a reference to a new clone and then tell that reference to move to the xpos value

I can see how your suggestion explains what is happening to the first tile being shifted to the right, but how do I fix the list issue? In my list of tiles variable, the name of the first item in the list has the same name as the second item.
Since you are not having an issue, then I can see this is a performance issue. I have read about the offline version of Snap is not recomended to be used on a tablet. However, I am using the online version of Snap. Are tablets not reccomended to be use with the online version of Snap as well?

Well, tablets are not recommended to be making big projects in snap, although there's nothing stopping you from doing it.

To make a reference to a new clone, you can do
script vars ((clone)::grey) @addInput ::grey
set [clone v] to (a new clone of [myself v]::control)
tell (clone) to ({...} @addInput ::grey ring)::control

This way, no matter what, it'll wait for the clone to be created before moving on.

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