Best Strategy for Detecting and Replacing a Grid of Objects?

supremelorax

  • Posts: 41
Greetings,
I am working on a bead board type program. Think of it as a flat piece of wood with divets in a grid for the placing of small objects to visualize quantities.
I have been piecing together bits from this forum and elsewhere and have tried a few things such as using actors, regions... but there are 100 of these 'divets.' Giving each one code will kill a lot of time and seems unnecessary with the tools Stencyl has. What I am trying to do is have each be marked by a region (on a list) that is constantly monitored for detection of a click at which point it will check for an 'active' attribute and either place a bead or remove one (or do nothing if there is nothing there). A user will first activate a 'box' where these objects come from and then click on a 'divet' to make this creation occur. I have also experimented with actors, which is easy enough to set up a few blocks for one and therefore 100, but I still need the actor to check for that 'active' attribute which it cannot do as it belongs to the scene. I am still a bit new at this so maybe I am just missing an easier solution and I wanted to see if there was someone out there who can keep me from wasting too much time trying too many things.

If I only had one bead to place, this is what the code would look like (attached). How do I get something to set the initial region call for any region within the series of 100?

I appreciate any help with this.

JeffreyDriver

  • Posts: 2262
You can use loops to cycle through things.

You may also want to look at using the Tile API. It's very useful for grid-based stuff.

supremelorax

  • Posts: 41
A loop might help but first I need a way of setting something up that can check these areas repeatedly. It seems much of the blocks I would need for that must be at the top of a string.

The other thing is that even though I mentioned a grid, it is not one that aligns with the tile grid very easily hence why regions might be my best bet as they will get me proper placement of each object. Although I do wonder if actors can be used and if the same quantity would be too taxing or just annoying to try to configure.

Attempting to better explain...
Here is my updated code. It now allows for me to click on a box (which activates it) and then click on a 'divet' and drop one in if there is nothing there. If there is something there, then it removes it back to the box. This is tied to a designated region. How do I set something up that will apply this to 99 other regions? Or, is there a better route to explore to get this same mechanic to work like this?

Also... does anyone know why '=' blocks don't work for my 'get list' statements but '>=' and '<=' do?

supremelorax

  • Posts: 41
I would love to have a  'when mouse is pressed on <any region from list>' block at the top there. Then I could set up a list of region names to check, verify and set those 'Divet' blocks to.

supremelorax

  • Posts: 41
I think I found a way to do this with a lot of replications but little to no modification to each iteration; with the bulk of the actual 'doing' being handled by a single event that grabs from an array of attributes set by each action.

However... I am still interested in any suggestions that might be even more efficient!

LIBERADO

  • *
  • Posts: 2718
I am unable to understand your explanations.
Can you explain graphically what you want to do? (with images, not with words only)
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

supremelorax

  • Posts: 41
Liberado, thank you for taking an interest.

Here is an image of my region grid. I suppose this could be an actor grid.
I want to be able to tap on any of those, and have a single code check if the mouse has clicked there and then execute a code.

I was able to do this with a simple code that I replicated 81 times for these regions, which collects information and feeds it into another script that executes the following:
If nothing is there and cup (where objects come from) is not active: do nothing
If nothing is there and cup is active: place object
If something is there and cup is not active: put object back
If something is there and cup is active: do nothing

At this point I am just trying to save time as I am about to apply this mechanic across four similar programs. It doesn't take too long but is a monotonous procedure as I have to adjust two different attributes by one consecutive number. Let me know if you can think of an easier way to accomplish this.

supremelorax

  • Posts: 41
http://thebestdistraction.com/montessori/test/index.html

Here Liberado. If you load this and click in the bottom corner to go to 'Unit Division Board' you can try out this function I am describing. It works as intended but I am just looking for a more efficient way of going about it, or if this is the best way.

To get beads ready. Click on 'Fill' and then click on the cup to drop some in. Turn off 'fill' and click on the cup again. Then you can drop a bead in any of those divets. To drop another you have to click on the cup again. This works beautifully on a touch screen. Mouse or track pad can be annoying.

« Last Edit: June 12, 2020, 02:57:55 pm by supremelorax »

LIBERADO

  • *
  • Posts: 2718
...but I still need the actor to check for that 'active' attribute which it cannot do as it belongs to the scene.
Do you know that you can use this red block in any actor?:
 


Found here:
 


More info: http://www.stencyl.com/blocks/viewCategory/behavior-atts/scene-get-attribute
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

supremelorax

  • Posts: 41
Thank you Liberado for this. I will be working on playing with this later tonight if possible. My guess is that it will be as easy as setting the two actors who need to  change into each other with this behavior and capturing their x,y coordinates or drawing a region to make the switch? If I had 400 of these actors who need to change into other actors, would that be more taxing than 400 regions that can spawn or kill actors?


LIBERADO

  • *
  • Posts: 2718
Sometimes I read in the forum that regions can be problematic in terms of performance.
If it's hundreds of actors, I would use Simple actors, or even Minimal actors:

I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.