Region Names [Solved]

LtVax27

  • *
  • Posts: 85
I want to go from- When Action 1 is pressed, If Actor inside this or that region switch to this or that scene (xAmount of Regions(lest I use is 7))
To - If Actor collides with region, Set -- to Last collided region name
If Action 1 is pressed, switch to scene with name 'Region name'
This will cut my code down to something so basic I can use it almost any where.
Now, the problem is I don't know how to detect the region without having a lot of 'If Actor collides with region' or how to get the name, I tried 'set Text to Region as Text' but get NULL back.
Trying to make it universal for every Town scene. Thanks in advance to who ever puts there time/thought into this.

Solved

Just have to name 'Regions' to corresponding 'Scene names'

« Last Edit: February 28, 2017, 07:45:23 pm by LtVax27 »

mdotedot

  • Posts: 1564
Hello LtVax27,

So far I know Stencyl doesn't provide a for each region block. (I am not on the latest version) Long time ago I created a Ladder Behavior (ClimbLadder)

In this behaviour I used this kind of code to get all the regions:
Code: [Select]
for(r in this.engine.regions){
   trace("Name of region: "+r.name);
}

Maybe this can help you as well
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

LtVax27

  • *
  • Posts: 85
That looks like it will do what I want, problem is I've not gotten into custom codes that much so I don't know how or where to use this code,  I did try just swapping out the 'region' block for 'code' block as Text but that just gave me an error I don't yet under stand. Any chance on a basic example of using this to add that name to a attribute?
P.S. Off to work now so no rush.

mdotedot

  • Posts: 1564
Here is an example stencyl file that includes a scene-behavior with the code. You can study this and adapt it to your needs:

List of Regions
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

LtVax27

  • *
  • Posts: 85
After scratching my head and doing a lot of reading and compiling ideas of how to mutilate some code together for a few hours I have finally worked out how I can use that example.

Thank you Sir, your help was most impressive.

« Last Edit: February 28, 2017, 06:53:01 am by LtVax27 »

LtVax27

  • *
  • Posts: 85
Just thought I'd add a pic of the final version, this is how it looks in my game, way more tidy than what I had and saves adding repetitive code for every house/town you move between.

Had a few bugs but worked them out. The Item> stores 2 lots of data.

« Last Edit: March 02, 2017, 08:38:59 am by LtVax27 »