What's faster? JSON or Events?

0 favourites
  • 8 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • I'm using an Array since I can't index variables and wanted to know if anyone knows if loading JSON from a file or just setting each value using actions, on startup is faster?

    I'd imagine JSON would be faster since there's only 1 event...

  • traditionally file I/O is slower than things done in memory.

    I haven't used anything with JSON yet but I have used the CSV plugin by rexrainbow and I know that is definitely "slower" than events.

    So it would make sense that Events are fast since this is done in RAM opposed to going to a file and opening it etc..

  • jobel Makes sense, thank you

  • TwinTails jobel : that's true, it's always better to populate an array or variables with all of the data you need. With the JSON plugin, it's very easy as you can loop through items and populate an array quickly. It's not as efficient with object variables though, as you have to use the dropdown menu to pick a variable to set up... do one of you know of a work-around for that?

    Cheers,

    Nathan

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Valerien I haven't used the JSON plugin so I'm not sure, sorry.

  • just setting each value using actions, on startup is faster?

    oh I assumed you meant "faster" as in, which happens quicker..i.e computer speeds. Information I've loaded from tables are slower than loading information from variables or direct assigning. I've had to add Waits before executing certain code blocks because loading data from a table is slower than a tick. Whereas assigning table data through direct assigning happens in 1 tick.

  • > just setting each value using actions, on startup is faster?

    >

    oh I assumed you meant "faster" as in, which happens quicker..i.e computer speeds. Information I've loaded from tables are slower than loading information from variables or direct assigning. I've had to add Waits before executing certain code blocks because loading data from a table is slower than a tick. Whereas assigning table data through direct assigning happens in 1 tick.

    Adding wait is not best way to do it. Most efficient way to build certain chain reactions is state machine. Unless you have some massive array to deal with, like a big level, arrays are fast enough.

  • Adding wait is not best way to do it. Most efficient way to build certain chain reactions is state machine. Unless you have some massive array to deal with, like a big level, arrays are fast enough.

    right..just illustrating a point...

    I've loaded data using the CSV plugin, when loading that information into memory that process takes longer than a tick, so you have to "wait" for it to be loaded since the game loop happens every tick... you have to build in something that will not execute code that assumes the data has been refreshed (especially if that code only happens once, like in an OnClicked Event for example)...you have to wait for the data to be finished loading. You can do this with flags or in some cases a simple System Wait might work, but it obviously needs to be tested. The Wait command is less reliable since all machines have different speeds and it greatly depends on the size of your data; a 0.1 Wait on one computer might not be long enough on another. However, there are simple cases where a Wait would suffice depending on what you are doing.

    I think the OP was probably just asking what is faster to build...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)