Magistross's Forum Posts

  • Your best bet is by tokenizing your data into a single string, then loop for each token to add elements to the list.

  • You can still reference arrays as you would reference objects. So depending on your need, you could "pass" an array to a function by using its UID.

    edit : Here's an example where it creates 10 randomized arrays at start, then permits you to get the sum of one of them using a function and a UID parameter.

  • Or just add another condition that goes like "Animation dead is not playing".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Although not recommanded, you could also use the Browser object ExecJS expression, but I guess it's okay for test games !

    Set color to Browser.ExecJS("parseInt('" & someHexValue & "', 16);")

    You can also wrap this in a function, like aruche did with his method.

    Anyhow, it seems that an official way of parsing hex values is lacking, and could be suggestion for a future feature ! <img src="smileys/smiley2.gif" border="0" align="middle" />

  • It's an iteration on the X axis only. So for each X (or monster in our case), check if its level (y = 1) is equal to the first function parameter (desired level). If it is, I add the current index to the list of candidates.

    I could have done a normal for loop, but since the array was set in such a manner, using the built in for each X axis was easier at that time.

  • I completed ArcadEd example with another function to retrieve the index of a random monster of the wanted level.

    You can then store that index in a local variable to get all the info you want on that monster !

    https://dl.dropboxusercontent.com/u/7004246/pickArray.capx

  • It has something to do with how picking is handled I think. The "Function" object is a unique instance, so the call get executed only once with the first UID from the filtered list of enemy. If the "Sprite" object could somehow link itself with the "Function" object, the internal for each would probably take care of the multiple calls. Maybe something on the to-do list ?

    Anyhow, an explicit for each works and you implemented it perfectly in tandem with the implicit one.

  • There doesn't seem to be an easy way to achieve that, although it's far from impossible.

    Try a for loop, start index 0 to floor(tilemap.width / "tile width") - 1, with a nested for loop that goes like start index 0 to floor(tilemap.height / "tile height") - 1. Since there is no expression to retrieve the tile width/height, you'll have to use the same constants as the tilemap properties.

    In the inner loop, add a new condition that goes like compare tile at x = loopindex("outerloop"), y = loopindex("innerloop") equals to 9, then add your actions to create an enemy.

    edit : Here's a quick example. I replace all cacti by mad faces.

  • Simply put, I want a random index between 0 and the number of remaining possibilities minus 1, since arrays are 0-indexed.

    With that index, I can then retrieve the corresponding frame in the array.

    When the layout begins, the possibilities array get initialized with values from 1 to 4. If the first random index is 0, the first tile is set to animation frame 1. In the next pass, random indexes can only from 0 to 2 (three remaining possibilities). Index 2 get picked, the next tile is set to animation frame 4. And so on so forth...

  • I went ahead and modified your file with an alternate way to do what you want. Here is the file.

    The method consists in populating a "possibilities" array, then building your grid with one random element from the array, removing it from the array everytime, so it doesn't get picked again.

  • Another way :

    for i = 0 to Array.Width * Array.Height - 1

    --Set Array.At(i % Array.Width, int(i/Array.Width)) = i

  • Debugging particular events is not yet implemented if I'm not mistaken, but is indeed in the (evergrowing) todo list !

  • fassFlash There is already a LayoutName expression under the system object, I don't know what you need more !

    On start of layout     -> Do common things

    --subevents

    -LayoutName = "xxxx" -> Do this

    -LayoutName = "yyyy" -> Do that

  • I once written an expression to do exactly that. Overkill nested choose FTW !

    choose(NPC.lastdirectionpicked = 0 ? choose(90, 180, 270) : 0, NPC.lastdirectionpicked = 90 ? choose(0, 180, 270) : 90, NPC.lastdirectionpicked = 180 ? choose(0, 90, 270) : 180, NPC.lastdirectionpicked = 270 ? choose(0, 90, 180) : 270)

    Basically, if choose() select the last direction of NPC, it choose again among the remaining three. If no direction was selected (i.e. NPC.lastdirectionpicked = -1 or something), it still picks one of the four possible choices.

  • You can't create patterns with choose() or random() though.