oosyrag's Forum Posts

  • Sorry about that, it should be repeat tokencount(AJAX.LastData,newline).

  • Use a global variable to keep track of total stars collected. For example lets call it TotalStars.

    On star collected - (System Actions) Add 1 to TotalStars.

    Then to display, you can use a text or spritefont object to set text to TotalStars.

  • On Asteroid Destroyed

    Repeat ceil(random(5)) times - Spawn Minerals

  • Mind if I refer to your server in a tutorial? This seems like a fairly common question, and useful as well.

  • Is there a way to use the min/max() expressions in a situation where the number of values to evaluate is not predetermined?

    My current workaround is to push the set of values into an array, sort, then get the front or back value. I was wondering if there were any different methods.

  • Responding to PM from CBelle requesting clarification here for the benefit of others.

    AJAX is not just for images. By using the "Request project file" action, you can load the contents of your previously imported project file to memory. This is accessible through the AJAX.LastData expression.

    With the conditions "AJAX on completed" and "repeat tokencount(AJAX.LastData,newline) times", you can loop through your text file and get each word with the expression "tokenat(AJAX.LastData,loopindex,newline)". Normally you would store each word in an array or dictionary, but if you want to put it directly in a list object you can do that as well by using the list's "Add item" action.

    Edit: fixed tokencount expression

  • Have each word on its own line in a text file.

    Add your text file as a "Project File". https://www.scirra.com/manual/141/files

    Request the file using AJAX. https://www.scirra.com/manual/107/ajax

    Parse out the words with the tokenat expression in a loop. Your source is "AJAX.LastData", your index is "loopindex", and your token is "newline" https://www.scirra.com/manual/126/system-expressions

    Store in your data structure of choice, recommended array, or dictionary could work too. https://www.scirra.com/manual/108/array

    Edit: Alternatively, for more advanced control over categories or nested data, you can use the XML Plugin. https://www.scirra.com/manual/139/xml

  • An Ajax request can take a URL, as long as it is on the same domain.

    https://www.scirra.com/manual/107/ajax

  • There are other ways to do loops over time... I just would just use an incrementing counter and/or every x seconds instead of the loop condition. I can make an example for you when I get back to a computer.

    Also I tend to avoid the wait action as much as I can, as it is a special case and breaks the normal flow. It has it's uses in the proper situations though.

  • Assuming your range indicator is a circle with diameter the same width of the sprite... your range, or distance from the tower to the edge of the circle, would be the radius of the circle - half the diameter. So set the width and height of the range indicator to 2*range and center it on your tower.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your problem currently is using the "Wait" action, which basically breaks the normal flow of the event sheet.

    A loop will run to completion in one frame.

    A wait action will basically take what remains of the actions after it out of the current flow of events, and complete them at a later time.

    In your loop, there are no actions after your wait, so nothing happens. All four instances of your sound get played in the same frame.

    If you use waits, it is best to have all your actions in one event rather than a loop.

  • Try the manual entry.

    https://www.scirra.com/manual/149/function

    [quote:26dg0304]Returning values from functions

    Functions can also return a result. For example, a factorial function could calculate the mathematical result and return it. In an On function event, the return value can be set using the Set return value action.

    If the event was called using the Call function action, the returned value is afterwards available using the ReturnValue expression. Functions can also be called directly from an expression using the Call expression; in this case the return value is automatically returned as the result of the Call expression.

    And in case you are not familiar with what an expression is: https://www.scirra.com/manual/78/expressions

  • Also you may want to use "On A pressed" instead "A is down", otherwise it will switch between the two every tick as long as you have A held down.

  • Add the condition "layer is visible" to the relevant events.

  • Loops should run to completion before the next frame is rendered, as far as I know. Not completely sure if functions have a special timing for when they are run, I assume the function just gets inserted wherever it was called.