Storing IIDs to matching array index

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • .CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6734583

    UPDATE: Thanks to ArcadEd for helping me discover that the problem was in my debug...not my actual Events/Actions.

    In the .capx file, you'll notice in the "LO LVL 1" layout that there are two red dots (object NodePatrol) and seven black dots (object NodeDirection). There is an array dubbed NodeCompass which has a X-length of 4.

    I'm working on setting up an enemy patrol system that can be adapted to any level, regardless of how many of each type of Node objects there are. The NodePatrol objects denote intersections, while the NodeDirection objects identify available directions to choose from. This way, regardless of the level, I only need to place the nodes wherever I please and all that's left is to set up the instructions on how to choose which route to take next when the enemy reaches a NodePatrol object instance.

    Here's my problem...

    I'll try to break it down clearly.

    Look up line three of the "ES CharEnemy" Event sheet.

    Using the For loop for a duration of 0 to NodeDirection.Count-1 (the -1 because the loop starts at zero and because the loopindex expression will be of use next), pick each instance of NodeDirection according to the loopindex value. Per each instance, check if it's overlapping any instance of the NodePatrol object (presumably, this will simultaneously pick that instance of NodePatrol, as well).

    Because the NodeCompass array is part of the container with the NodePatrol object, this should also pick the array instance associated with the NodePatrol instance. The following action should push the IID of the current NodeDirection instance (again, based on the loopindex value) into the array contained with the NodePatrol instance being overlapped.

    Here's where the problem creeps in...

    You'll notice on the layout that I have two NodePatrol instances and seven NodeDirection instances. I have debug text objects to highlight the IIDs of each NodeDirection instance, 0 through 6. The "A | A | A | A" text are the values in each instance of the NodeCompass array ("A" serves as a place holder so not to be confused with instance 0 or just simply having no other value).

    What seems to be happening is that, as each instance of NodeDirection is checked, the switching between interrupts the process. You'll notice that one instance of NodePatrol has instances 0, 1, and 3 of NodeDirection next to it. The other instance has IIDs 2, 4, 5, and 6. However, when you look at each text display showing the IIDs stored into the related array, instances 3 and 6 (the last of each group of NodeDirection instances surrounding each NodePatrol) are not stored in the array. Only 5 of the 7 IIDs are accounted for. This is what leads me to believe that there is a hic-up in the process. I've even tried using Pick nearest NodePatrol but that doesn't help any.

  • *bump* ...this got pushed to page four REAL fast...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 3 and 6 are being added but you're updating the text before you add the value to the array instead of after so you don't see the last value added.

  • ramones - Yeah, ArcadEd helped me figure that out earlier today. *facepalm to the max* I THOUGHT I checked for that very thing but totally overlooked it anyway. Thank you for confirming it. :)

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