piranha305's Recent Forum Activity

  • agree with newt the performance benefit you get from scripting vs events is negligible, the real benefit from scripting comes from complex data structures imo. you have alot more freedom to freely manipulate data and store data. that said with that extra freedom you can fine tune some algorithms that you have on the event sheet and you might get a bit more performance. but it really depends on what you are doing, for general game play logic you wont see that big of a boost. just take a look at the ghost shooter example it implemented using full scripting and full events and the performance is very similar, mind you its a very simple implementation. one thing i noticed from comparing both scripting had a few frame drops to like 57 fps every once in a while and the event based one stay at a constant 60 fps. mind you i was just looking at the debugger and did not dig too deep into the metrics. you should explore it on your own for the use case of you game. i'd say the way to go is a mix, pure scripting does not seem like a full replacement for the evening system, they should be used in conjunction to get the most out of construct, but like i said just my opinion.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's all good man, the more info the better.

  • construct arrays are actually 3 dimensional, so the array represented as json looks like this

    { "c2array": true, "size": [ 1, 1, 1 ], "data": [ [ [ "stuff" ] ] ] }

    you would need to do something like this

    + System: On start of layout

    -> Array: Set value at 0 to "{""enemies"":[2,2], ""position"":[1,2], ""wait"":[0,0]}"

    notice you have to escape the double quotes

  • the action that loads an array from json expects a very specific format. if you just wanted to store a json string in the array, you have to set one of the index of the array to json "string".

  • yeah makes sense, sometimes its just hard to resist the shiny new toys though...

  • Ashley since chrome 80, i think null coalescing has been added to javascript. it seems the scripting feature does not support the newest features being added to javascript? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator

    it's not a big deal, since this is just syntactic sugar to help code cleanliness. but this brings up the question? as new features are added to the javascript (seems to be happening at a rapid pace nowadays) will construct keep up with these features in the scripting api? I would assumes this is just adding linter support for the new feature? but it might be more complex than that.

    will construct target a specific iteration of java script? there is a snippet in the documentation

    I am not sure the overhead of having construct keep up with these changes to the language, what are your thoughts on this?

    Tagged:

  • Congrats, this game is super awesome!

  • Not for the time being sorry, I had to remove them. I might start them back up in the future, but currently it's not possible

  • is there some other method in the scripting api, to reference a specific instance that is not already picked by a c3 condition? like for code not in an event block? like we can get the first instance? and the set of all instances? and an instance by specific index, but is there a way to reference a specific instance by some condition?

    the only way i know of atm is to iterate over all instances and check for the given condition (uid == x, instvar = x ... etc) and get that instance. using array filter still has to iterate over all the instances.

    iterating over all of them is not a big deal, but i think that is where the pain point is for ppl trying to transition. they want to run some logic for a specific instance,but don't know how to to get the reference to the instance

  • when you use getDataMap(), the object that returns can be used to add change delete key value pairs.

    https://i.imgur.com/H1ZmcqO.png

    https://www.geeksforgeeks.org/map-get-javascript/

    ** and yeah you need to add a dictionary object to be able to reference it and call getDataMap()

  • in script you always have to iterate over all the instance, construct conditions are set based operations, any new condition pretty much filters out instances from the whole set. so you have multiple instances that match the condition, they will all be pick and then action should run on both. i am not sure how picking by uid is implemented internally in c3, do they iterate over all the instance and return the matching uid? or do they already have some data structure that is keeping track of the instances and they can just select the one with the uid?

    looking at c2runtime, it seems this is the approach they take,

    they have

    this.objectsByUid = {}; // maps every in-use UID (as a string) to its instance
    

    and when new instances are created

    this.objectsByUid[instance.uid.toString()] = instance;
    

    then when they look it up

    Runtime.prototype.getObjectByUID = function (uid_)
    {
    ;
    var uidstr = uid_.toString();
    if (this.objectsByUid.hasOwnProperty(uidstr))
    return this.objectsByUid[uidstr];
    else
    return null;
    };
    

    i am not sure this is how it works in c3, since the runtime is different, they might have a way better way of doing it.

  • yeah, i would say if you need to access all your instances frequently, at the start of layout i would iterate over all of them, and store them in a map (dictionary) with uid as the key, then you should be able to reference them very easily objectMap[uid], you just have to remember to add new objects if they are created at runtime.

piranha305's avatar

piranha305

Early Adopter

Member since 26 Apr, 2016

Twitter
piranha305 has 34 followers

Connect with piranha305

Trophy Case

  • 8-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • x5
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • x4
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x2
    Lightning Draw First person to up-vote a new Construct 3 release
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies