Magistross's Forum Posts

  • You need a separate list of indices. You can either generate it every time you want to fetch a new index or just keep it synced with the data in your array. It shouldn't be that costly to generate a new list every time, unless your array has thousands of values !

    edit : I edited Seasky's example to illustrate both methods.

  • Oh, I did not fully understand the problem to begin with. To do that with the UID you'd have to loop through the UID ordered collection of your sprites and pick the first higher one... definitely not the way to go.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A higher UID always mean a more recent instance, so ordering by UID to do the picking could work. But it's so much easier to go with sprite(sprite.count - 1) that there's no reason not to !

  • You might be able to achieve what you want with something like this.

  • I don't think loopindex works with the For each axis of the array object, use array.curX or array.curY instead. I don't think stop loop works either... so maybe you should just use a plain "for loop".

  • It is called by the addItem function. It first check if an item exists (index != -1), if so, add to its quantity, if not, add a new entry to the inventory array, and set its quantity to 1.

  • You probably want something like this. Pay attention to the itemIndex function. It returns -1 if the item isn't contained in the inventory, otherwise, it returns the index of the item.

  • Look at system expressions. Especially under the System group. You got that nifty projectversion variable !

  • I recently started creating the foundation for a retro RPG game. I stumbled on this thread so I thought I could share my work. Here's what I have so far. Download capx

    I've made grid based movement using the tilemap plugin and rexrainbow's excellent MoveTo behavior.

    Default keys for movement are WASD.

  • I don't understand your gripes with how Construct handles this. If you delete an index on an axis, the remaining elements are automatically shifted on that particular axis...

  • I went ahead and changed the method to use RegEx instead of tokenization. It now works with nested data too. You'll notice I changed how the function is called, I now supply the input and one or more keys for the data to fetch. You can fetch "name" with a call like parse(input, "name") and it'll give you the data at the first occurence of the key "name", whatever its level of nesting... Or, you can call parse(input, "playerData", "name") and it'll give you the "name" of the first occurence of "playerData" in your input string.

    Here is the file.

  • From a pure parsing point of view you could use something like this. If C2 could use matching groups with regex, it would fall to only one line of code, but anyhow, this should do !

  • RamPackWobble The for each blue sprite on line 2 runs exactly ten times, once for each iteration of the outer loop. The picked instances list after a "Create object" get limited to that particular instance, so the blue sprite already on the layout never get picked for line 2.

    t4u What I meant is if you create multiple objects in a single event and you want to iterate through them afterwards, you're better off duplicating the creation event and doing the iteration on this one. It's hard to explain, so here's a picture. The "creation event" is a simple "start of layout" in this case.

  • You have 3 arrays, the one already on the layout, and the two newly created. As to why your variable equals 1, it's simple : Iteration only occurs on objects that are available on the top level condition. So using RamPackWobble suggestion should do the trick !

  • Plain is good enough, no need to encapsulate anything in an object. As you said, tokenizing make it so easy !