Yann's Recent Forum Activity

  • Well, depends on what you want to do but in general, the basic functions you want to have with arrays are access using index and as a by product of that, being able to loop through the entries.

    To loop, you just have to use the basic C2 repeat or for loop. The plugin has the JSON.Length(origin,p,a,t,h,...) expression that returns the length of the array at the given path. All you need to loop.

    If you start messing with array indices though (like creating holes in the indexing) you'd have to check for undefined durring your looping.

    Otherwise, other functions like push/pop/shift/unshift/insert/delete (what you would need for drag&drop and rearrange) are indeed not implemented. It's not too hard to implement via events using loop, but it would probably be better to have the javascript functions directly. Though you would only be able to push/unshift simple values (not object or array)) unless I do something like JSON.pushJSON(origin,p,a,t,h,...)... Not sure I would want to go that far.

    Otherwise, the foreach loop implemented in the plugin is for looping through object (but you can use it to loop through arrays as well, though I wouldn't trust the ordering on that one)

    So yeah in the end, the only feasible way to move objects arround is to so a insertJSON, pushJSON and unshiftJSON. Converting the branch of the object you want to move to JSON and that would be parsed and inserted as a new object.

    I might throw a new capx with some example of that tomorrow night. If I have time =)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • + Condition A
    + Condition B
    + Condition C
    + Condition D
    + System: random(1) < 0.25
         -> Attack[/code:3mgvvr7d]
  • When you type an expression in the chrome console and press enter, you always get some sort of value (often undefined, or the result of some operations), that's what will get automagically returned by ExecJS.

    In the case of the example you gave, undefined should be returned (maybe as a string, I don't remember (: )

    in Noncentz705's case it should return the div DOM object

  • Why do you try to compare a string with lowest/highest?

    Are you rather trying to compare the length of the string?

    Anyway, I gave it a look, and it seems to be a real bug.

    If you are really in a hurry you can try replacing C:/..../construct2/exporter/html5/eveng.js with this one :

    eveng.js

    Use this at your own risk (: (in any case it will be replace by a new update)

    The only thing I added in it was on line 1868 :

    replace:

    					this.get = this.get_familyvar;[/code:2wq8ymuv]by:[code:2wq8ymuv]
    					this.get = function() {
                            return this.get_familyvar(this.index);
                        };[/code:2wq8ymuv]
    
    Note that it's not enough, you also have to check that instances are present, doing this (else you'll also get an error):
    [img="http://img208.imageshack.us/img208/9181/325i.png"]
  • vtrix

    Not really sure what I'm looking at, but it sure looks neat

    And it seems that you manage to get the hang of the plugin pretty well :]

  • vtrix

    An idea for you, going back to your post about weapons:

    You could put a JSON object in container with your weapon object type.

    This way you could have automatic picking, but also you weapon JSON could have a structure like this:

    {
      "name": "rifle",
      "surname": "MyLittleRifle",
      "fireRate": 0.5,
      "damage":5,
      "bullets":[
        {type:"superbadass",perforation:5,speed:500,"fx":"flash"},
        {type:"medium",perforation:1,speed:300,"fx":"flash"},
        {type:"fake",perforation:0,speed:0,"fx":"smoke"},
      ]
    }[/code:2vu1jnjt]
    
    This way you can imagine a game were weapons can be picked, dropped, with their amunitions, the amunitions can be removed, sorted, placed in other weapons, and each bullet have specific properties. The "bullets" property would be an array where the order is used to shot them sequencially.
    
    And since it's a container, each weapon you have in your layout could have very different or random properties. And to organize your project better you can even put information about animation or frames to play/display, this way you can leave all your weapon frames in the same sprite and same for bullets.
    Everything synched with just one object instead of a lot of array/dictionnary
    
    Maybe a few things would be redundant with instance variables... but meh
  • shinkan

    Ok my bad, I think I've seen it on the function plugin at some point but I might have dreamt that

    Anyway, I don't think I did something wrong setting up the UI, it might be some iffy secret stuff going on Ashley side I'm not aware of. (maybe having a comboParam before a variadicParams mess things up...)

    And unfortunately I don't have enough control to do "nothing if there's nothing and parenthesis if there's something"

    I can only put

    <i>[{...}]</i>[/code:14bpo4jg]as far as I know, to tell the plugin to display [parm0,param1,param2,...] in italic with and with 0 param it will leave the brackets the same way you still have the parenthesis even with no parameters in the function call action.
    
    @newt  nice one =)
  • shinkan

    What you describe is actually a (minor) bug you also have in the function plugin =)

    Funny one, I never got around to report it.

    But it's something that should be solved by Ashley.

  • shinkan

    Yeah maybe square brackets are misleading:

    Here's a better representation of what we could get

    // square
    root[]
    root["Wizard"]
    root["Wizard","stats"]
    root["Wizard","stats","hp"]
    // curly
    root{}
    root{"Wizard"}
    root{"Wizard","stats"}
    root{"Wizard","stats","hp"}
    // normal
    root()
    root("Wizard")
    root("Wizard","stats")
    root("Wizard","stats","hp")
    // angle
    root<>
    root<"Wizard">
    root<"Wizard","stats">
    root<"Wizard","stats","hp">
    // nothing
    root 
    root "Wizard"
    root "Wizard","stats"
    root "Wizard","stats","hp"[/code:k20702zz]
    What do you prefer?
    note that's it's really only an esthetic/cosmetic consideration. It will change nothing in how it works =)
  • vtrix

    I'm at work now, but know that the root object can be whatever you want it to be: an object (a.k.a. dictionary), an array, a boolean, a number, a string or null.

    By default, root is undefined (or should be, I don't remember what I do )

    The brackets [] you see in the event sheet are just because I don't have a lot of options as far as formating the look of action/condition/expression. Those brackets should contain the path to a value. Nothing to do with type.

    In the example with the Wizard class,

    • root[] is the base (which in this case is an object)
    • root["Wizard"] is the value at the "wizard" key in the root object, and it is also an object
    • root["Wizard","hp"] is the value at the "hp" key contains in the object at the "Wizard" key of the root object.

    and so on and so forth.

    I'll keep calling this type "object", because that's what it is called in the official JSON documentation and in javascript, but do think of it as a dictionary (key value pair)

    As far as confusion with objects in construct...

    Well in construct you don't really have objects per se.

    You have plugins, object-types (created from plugins) and instances (created from object-types).

    You don't really have "objects" (well, the term is usually mis-used interchangeably as a shorthand for object-types or instances... talking about confusion ).

    And in any case, object-types or instances have nothing to do with a JSON object.

    I repeat again, an object in JSON is the same as a dictionary in construct2 (and in python it's also called a dictionary)

  • shinkan

    Well, for now I didn't have any complain (not sure anyone really tested it).

    But I'd say, a safe one or two weeks would be a fair minimum

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann