License from €75 Log in
DE EN FR ES IT CZ

Question about loops

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 12 years ago
    Hi,

    i wanto ask you, how much are the loop scripts gruelling the system?
    I wanted dragged items to disappear in invetory, which is done by tile covering the item, but for recalling that i had to set up a loop checking if there is some dragged item.

    And there is a loop for aligning the text, loop for positioning the character shadow etc etc..

    how many loops is still ok for the system?
    Thanks!
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 12 years ago
    This is a good question because I also have several loops in definition scripts.
  4. · 12 years ago
    indeed, a good question razz
    I think it depends on how the loops are generated: are they normal for, while, etc loops in a lua script or actionsparts who jump to the beginning (which are maybe more resource consuming)?
  5. · 12 years ago
    I mean mostly registerEventHandler loops
  6. · 12 years ago
    it depends what your event handler is doing. Each event handler is called at max. only one time per player main loop. Usually lua functions are executed very fast so you shouldn't run into any performance issues. Unless your function performs disk I/O or some insane stuff like traversing ten thousands of objects etc.
    I think very long script executions are registered in the log file. If the event handler or function execution takes multiple milliseconds it usually means that you're doing something wrong.
  7. · 12 years ago
    Thanks alex, i already have issues with occasionally lagging so i try to be careful.

    For example the loop checking the inventory. On every mouse movement if there is no dragged item it sets 10 conditions to false. Works fine, but it runs even if it's not needed, its still setting the conditions even if i'm not working with items. I didn't find another way to make it work so i hope loops like this are ok.
  8. · 12 years ago
    that should be fine. One easy optimization would probably be to store the previous state of last execution (item dragged / not dragged) in a variable and only perform the rest when the state changed.
  9. · 12 years ago
    Okey thank you Alex.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?