Action just won't retrieve values from XY array

0 favourites
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi!

    I've got a problem. I'm trying to get the value I just stored in an Array. I'm trying to set the X and Y position based on where it is stored in the Array.

    But the object 'Container2" just spawns at 0,0 coordinates in the game. While I stored 156,207 in the array.

    My array is 3 wide and 2 high, 0 depth.

    This is driving me crazy, what am I doing wrong?

    Thanks.

  • You want a depth of 1 on your array. If you check in debug mode you can look at the array object to confirm your values are being stored.

  • Thanks!!

    I tried with the depth, in my quest to solve this problem.

    I added the depth of 1, now it works. Not sure why it didn't before, but it's working now.

    Ah yes, I was aware of the debug mode.

    :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're welcome :-)

    If you have a value of zero for any of the array's dimensions then the array doesn't have any cells for you to store data e.g. 5x5x0 = 0

  • That makes sense.

    Now, I'm almost there with the coding, but I can't figure this one last thing out. Perhaps you can help me out?

    Here's the array that I have:

    I'm still in the learning phase of programming, but that is how I stored the coordinates of the X and Y positions of the containers I'm trying to place.

    Basically, what I want to happen is this;

    First, 6 shipping containers (basically sprite blocks) are created. They all have 6 frames total with these colors. Each container has a 'choose' frame action.

    The bottom 6 containers should have all the colors the top 6 have, but I just can't find a way to 'shuffle' the places of these bottom 6 containers so it doesn't mirror the top 6.

    It's basically some sort of 'Match 2' puzzle game.

    I've tried a lot of things with arrays and coding, and I'd like to really limit the number of total sprites used (in total two now).

    Here's a part of the coding, as you can see, it's just the tip of a tedious iceberg.

    And as you can also see, you can see I'm trying, but am not really sure what to do next. I've looked at many samples for Match 2, 3, etc. but it's incredibly hard to make those examples work for your own ideas/variations.

    Thanks. Sorry for the long post.

  • Of course, it doesn't have to be made from the code I posted, perhaps you could point me into the right direction.

  • On it, should have something for you shortly :-)

  • OK, here's what I managed:

    dropbox.com/s/0xs8vj1lp2gq5g8/matchContainers00.capx

    This creates two sets of containers with shuffled instances. I've added comments on the event sheet to explain what's happening, but let me know if they aren't clear.

  • Wow. Thanks! I spend literally HOURS fiddling with code and this guy..!

    I downloaded the .capx, I will look at it in depth, probably tomorrow.

    Taking a quick look at your code.. I will have to take a good look.. because it looks so efficient, and intimidating at the same time!

    Sometimes I think to myself, should I even bother continue programming with Construct? I mean, how much more learning before I'm at this level too? I often have many ideas for games, but I often get bogged down with programming, where I often have to give up on many projects.

    Do you have a programming background?

    And I'm also curious, do you also have games out there? Or videos of them.

    In any case, thanks for your time good sir!

  • Glad to be able to help, give me a shout if you would like me to clarify anything in the demo.

    I've no programming background, apart from dabbling with a few scripting languages here and there; it's one of my main reasons for using Construct.

    Knowing the conventions and workarounds comes with practice, but keep plugging at it and you'll be surprised at how quickly you pick stuff up. I've found that scouring the forums, tutorials and manual really helps.

    A good way to get a leg-up on projects is to start with one of the bundled example projects as a base, and enhance it with a few extra mechanics. Just keep them simple and you'll stand a better chance of finishing them. That said, don't get too disheartened with abandoning projects - each is a learning experience whether you finish it or not. I have plenty of games that are on the bench - maybe I'll get back to them, maybe I won't, but all of them have helped me improve.

    You can check out my noodlings (in various states of completion) here:

    mekonbekon.netlify.com

  • I think it's impressive that you manage to do that, without any programming background.

    Perhaps I should indeed dive more into tutorials. I don't always find the C2 manual particularly informative, because it has few examples. It just states what's what, I do manage to find related topics to solve my problem, but I just have a hard time adapting the solutions into my own projects.

    Ha! I do indeed have many abandoned projects. Primarily because I couldn't get it working - I turn my attention to something new.

    Hey about this Netlify site you're using, what's the reason for choosing that one?

    Anyway, having looked at the .capx you created I do have some questions. I also have some other questions, perhaps you have a means of communication like Discord? Admittely, I don't use it often, but it seems popular here on the forums.

  • I use Netlify because it's free and really straightforward to use - you just drag in your exported project folder to upload it and, hey presto, it's ready to go. You can also easily change the site name.

    Yup, I'm on Discord (mekonbekon) and on Construct Community - I don't use it much either but if you would rather continue there I'll muddle through :-)

  • Hiya,

    OK so I'm trying to add you on Discord but it asks me for the number after your name.

    So in a; mekonbekon#0000 format?

  • mekonbekon#0890

  • mekonbekon Hey! It's kinda hard to get in touch using Discord. I often just forget to start it up, when I do, it doesn't seem to send out any notifications when someone left a message. Perhaps there's a better way of communication, although I'm not sure what you prefer? If you're still interested, of course. :)

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