Why A.at(x,y) is zero after SET A.at(x,y)=1?

0 favourites
  • 11 posts
From the Asset Store
“Zero Numbers” is a logic game. Game with Source-Code (Construct 3 / .c3p) + HTML5 Exported
  • I'm trying to program a labrynth creator routine. Doing it by means of events is quite complicated for me.

    After changing the code to debug it, I tested with this lines at "System - On Start of Layout":

    MyArray Set size to (4,2,1)

    MyArray Set value at(0,0) to 0

    [... more MyArray() initialization ...]

    MyArray Set value at(2,1) to 1

    TextBox Set text to ""&MyArray.At(2,1)

    TextBox displays "0".

    Should I wait a frame or something before MyArray gets the value?

    How can I wait until I'm sure all values have propagated through the matrix?

  • Are you sure the array is big enough to hold all the values? Values written outside the array have no effect and retrieving a value outside the array returns zero.

  • arcalaus, do you have a capx you can post? It might be easier to help if we can see the code.

  • OK, here's the Capx:


    The array is called Direcciones (instead of MyArray), and it is supposed to store X and Y delta values for East, South, West and North.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Good luck with this! I have always been interested in procedural generation - this seems like a difficult but worthy endeavour!

  • I was having a hard time working with your capx so I pulled out the important parts (i hope).

    Here is an example i came up with:

    Direcciones Example

    I hope that helps!

  • There are no instances of that array object on your layout. When there are no instances the expressions default to 0. The only solution at this point is to delete the Direcciones object from the "object types" folder and create a new array on the layout.


    This situation is pretty easy to reproduce.

    1. Create Array.

    2. Delete Array from objects bar.

    At this point Array only exists in the "object types" folder, and there is no way to add an instance of it to the layout.

    Could a solution be to allow dragging Array from the "object types" folder onto the layout if there were no instances of it already there?

  • Good catch, r0j0hound!

  • I swear I tried adding arrays to layout, but they refused to appear on it. I'll give another try.

  • Just in case someone else makes the same mistake...

    Since moving non-world objects to layout seems to be impossible, i've edited the layout.xml file in order to avoid events being deleted during object deletion.

    I've edited the "nonworld-instances" part of layout.xml and added:

      <instance type="Direcciones">

    ...It worked!

    Now, I'll focus in the labyrinth generation routine

    (it seems that making a javascript "behaviour" would be easier, though).

  • Better if the creators give us a clean solutions for this problem, I dont want to hack xmls files to solve a problem, since C2 is a high level creation tool.

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