Magistross's Forum Posts

  • atan2() exists in the Javascript Math object, but it can't be directly used in C2. But it seems Ashley proposed a working alternative using the already implemented angle function.

  • Hi all !

    I used my spare time at work to mess around with the plugin SDK. I decided to give a go at data structures and this little plugin was born !

    I basically implemented the basic JavaScript's array functions (pop, shift, splice, etc.) for vectors, with all vectors stored in an associative list. Actions add data, and expressions remove it, although you can still remove data with an action (but without retrieving it).

    Descriptions, names and such are a mess, but I think it's still pretty usable. If someone feels like cleaning the descriptions and giving more significative names to conditions, actions and expressions, or even adding more functionalities to the plugin, please do ! I did this just for kicks, but if it can be helpful for someone, then by all means use it !

  • I, too, checked the code. But it seems you didn't see things as I did. When the plugin receive a message, indeed the trigger happens, but the "lastData" variable also gets overridden with the new message. So in the unprobable (but possible) event of two messages received between two C2 tick, only the last message is returned via the "LastData" expression. As I said, storing them in an array via C2 WON'T help, and there is no workaround except by implementing stacks (or queues, or any other data structure) inside the plugin.

  • There is no way to tell if the plugin received more than one message during one tick. Storing them in an array is pointless, since you can process them punctually as they arrive. This is a kind of things that needs to be done internally.

  • Add an array to your project

    Add a global variable "step"

    Socket=>"on reception" (something like that, I can't have the plugin under my eyes)

    ..array. Set at X (where X is global step), value Socket.LastDataReceived

    ..array. Set size to X=step+1 ,Y=0,Z=0

    ..step. Add 1 to step

    This wouldn't solve anything since the problem comes from the plugin itself. I don't know anything about websocket, their implementation or anything, but I think the plugin should use a stack to store received messages instead of a simple string variable. That way, you could add an event like "While the messages stack is not empty, pop a message, parse it and do whatever needs to be done".

  • If you use the For each to loop for every instance of an object, then do as Kyatric said. You have to make use of the implicit looping when you can ! <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Sub-events are executed once every iteration, isn't it what you want ?

  • Nested loops ! You need to scan every target for every tower.

  • Have the loop condition as a "master" event, and then add as much sub-events as you need, with each its own set of conditions and actions.

  • Are you totaly sure about this ?

    eah, in the end it all comes down to the number of elements in the array. A 10x10x2 3d array is pretty much the same as a 100x2 2d array in term of memory allocation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want the array to be a virtual representation of the grid, going the vector way is definitely not the way to go. Going 3d is more intuitive and human readable, and take as much as memory space.

    However, I don't think he needs any kind of array representation of anything. Normally, you would build a grid or map using the info you've got stored in the array, not the other way around.

  • One way would be doing arithmetics with the pixel coordinates to transform them into array "coordinates".

    ("PixelX of tile" - "Grid Xoffset from (0,0)") / "tile width" = x index

    ("PixelY of tile" - "Grid Yoffset from (0,0)") / "tile height" = y index

    Or you could go the simple way and add instance variables to the tile, one for each index, and fetch data from the array using these.

  • The best for storing two (or more) variables of a grid of instances would be a 3-dimensional array with the x,y (width and height) indexes the coordinates of an instance and the remaining dimension (depth) would be use to store each variable.

    However, if you plan on storing the positions in the array, I think it's pointless, since you can retrieve the values directly with the instances anyway.

  • What exactly are you storing inside the array ?

  • Are you looking for something like this ?

    I create 100 tiles with a simple repeat and then order them in a 10x10 grid layout using 3 different (but similar) ways.