Dasat's Recent Forum Activity

  • spacedoubt, thanks, i guess it should be .itemcount not .count. Thanks once again

    Make a For Loop:

    For "" from 0 to list.count + 1 (i'm not sure why, but I had to add +1 to get the last index)

    then, I'm not sure what you're doing with it, but I was just putting them into some text like this:

    append List.SelectedTextAt(loopindex)

  • I'm using list box and multiselect is on, how do i get all the indices of the selected items as this is more than 1, .selected count only returns the number of items selected and not the index

  • then create then in separate variables i believe

  • i don't get you, do you want to save the individual scores for each level separately and make it available in the next level or what? Also, do your levels run in different layouts.

    Your choices are to store in array, webstorage or a simple global variable.

    Better still explain your question very well.

  • tomsstudio, thanks a lot

    > I'm trying to set a list and another text box from a dictionary by using the st from json action with the expression dictionary.asjson but none of them seems to respond

    >

    The way your using .asjson wont work.

    When you try and load a text box with .asjson, the text box is looking for the text box format json. As you are trying to load a 'dictionary json format", the text box will not recognize it.

    If you want to insert raw dictionary data, then go textbox.settext > "" & dictionary.asjson.

    If you want to get sequential values from the dictionary, then i highly suggest using an array.

    But it can be done with dictionary.

    One way is to use numbered keys, i.e. key: "0"="bob" key: "1" = "sam" etc etc.

    Now we create a for loop.

    For i = 0 to 9

    Textbox.appendtext "" & dictionary.get(system.loopindex("i") & "") & newline // Here we convert the numbered loopindex into a string so we can address the dictionary key to get the data.

    I hope this helps.

  • Yann, thanks a lot, I'm already making progress with the project, i really appreciate you.

    Dasat

    Ah yeah sorry I forgot to launch dropbox, now it's updated

    And for your foreach, first, remember to not do it every tick, that's the reason why it wasn't stopping. You can nest it under the start of layout event for it to just run once.

    Now as far as foreach goes, you're using it correctly. The only thing that you should be aware of, it that using a foreach on an array could lead to weird results, 'cause the foreach won't insure that you'll loop through the indices in the proper order. When you use foreach on an array, the array is considered as an object and the number as fields. As if you had:

    > {
       "0": "first",
       "1": "second",
       "2": "third",
       "3": "fourth"
    }
    [/code:3czwctra]
    
    usually with arrays I just loop through the indices
    So your capx would look like this:
    [code:3czwctra]+ System: repeat JSON.Size(0)
        -> JSON: set Current Path to 

    rootchm@loopindex + JSON: foreach property at current@ -> Text: Append JSON.CurrentKey&newline // newline makes it easier to read[/code:3czwctra] Now your other problem is that you're printing the keys using JSON.CurrentKey, if you want the content, you need to use JSON.CurrentValue In your case, the value for "friends" is an array, so you need to detect that, you can either use the Is Array condition or check if CurrentKey = "friends". I would personally check for Array 'cause this way you can change the name of the field if you need it. Anyway, it should look something like that [url]https://dl.dropboxusercontent.com/u/23551572/C2/JSONDasat-foreach.capx[/url]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yann, the jsonDasat capx is still not updated

  • Yann, the capx on foreachproperty

  • I'm trying to set a list and another text box from a dictionary by using the st from json action with the expression dictionary.asjson but none of them seems to respond

  • Yann,

    Wow, you are a good teacher!!!, at the beginning i was feeling dumb realizing what i was actually doing, but i think i have a better understanding now.

    But, for the capx you sent, in the third method, if you check the debugger you would see its only adding the first property object and not the second, also, if you don't mind i would appreciate you shedding light also on retriving values by using the json.value expression:

    i expect setting text to json.value(0,"path","to","an","object") to spilll out all the contents of the object, or adding a key after the object to return the value of the key, but i keep getting undefined, when i attempt this

    Dasat

    If you run the capx in the debugger (Ctrl+F5) you should see that:

    {
      "name": "dasat",
      "properties": {
        "property_name": "thermal"
      }
    }[/code:1zc6eo4u]
    which is not nothing, but yeah, not what you want for now
    
    Let's comment what you did line by line so I explain a few things:
    
    [code:1zc6eo4u]
    + System: on start of layout
       // in javascript it could be represented as: var root = {};
       -> JSON: new Object at root@    
       + [empty]
          // here you are redoing: root = {}; which basically discard the first object
          -> JSON: new Object at root@ 
          // here current and root are the same, so you are doing:  root["name"] = "Dasat";
          -> JSON: set "Dasat" at current@"name" 
          // you set the current path to the current path, so nothing changes
          -> JSON: Set Current Path to current@  
          // here you do root["properties"] = [];
          -> JSON: new Array at 

    currentnmq@properties // here that make sens, now current is root["properties"] -> JSON: Set Current Path to current@"properties" // you do root["properties"] = {}; so your array gets discarded -> JSON: new Object at current@ // root["properties"]["property_name"] = "electrical" -> JSON: set "electrical" at current@"property_name" // root["properties"]["property_unit"] = "wareva" -> JSON: new "wareva" at current@"property_unit" // here you basically discard the object at root["properties"] and replace it by an empty one -> JSON: new Object at current@ // root["properties"]["property_name"] = "thermal" -> JSON: new "thermal" at current@"property_name" [/code:1zc6eo4u] To summurize I'll write in javascript only what you did [code:1zc6eo4u] var root = {}; root = {}; //which basically discard the first object root["name"] = "Dasat"; root["properties"] = []; root["properties"] = {}; // discard the array root["properties"]["property_name"] = "electrical"; root["properties"]["property_unit"] = "wareva"; root["properties"] = {}; // discard the previous object root["properties"]["property_name"] = "thermal"; [/code:1zc6eo4u] So here the result showing in the debugger makes sens Let's travel from javascript back to the JSON plugin What you want to generate is: I'm trying to have something like let's build a basic addition and multiplication table, like what we learnt whe we were young (but yeah, 0-based for simplicity): [code:1zc6eo4u] [ > {"name": "dasat, > "properties": [ > {"property_name": "conductivity", "property_unit": "wareva" }, > {"property_name": "restitivity", "property_unit": "ohmmeter"} > ] }, {"name": "dasat2, "properties":[ > {"property_name": "conductivity2", "property_unit": "wareva2" } > {"property_name": "restitivity2", "property_unit": "ohmmeter2"} > ] } ] [/code:1zc6eo4u] in javascript you can do it like that: [code:1zc6eo4u] var root = []; root[0] = {}; root[0]["name"] = "Dasat"; root[0]["properties"] = []; root[0]["properties"][0] = {}; root[0]["properties"][0]["property_name"] = "conductivity"; root[0]["properties"][0]["property_unit"] = "wareva"; root[0]["properties"][1] = {}; root[0]["properties"][1]["property_name"] = "restitivity"; root[0]["properties"][1]["property_unit"] = "ohmmeter"; root[0] = {}; root[1]["name"] = "Dasat2"; root[1]["properties"] = []; root[1]["properties"][0] = {}; root[1]["properties"][0]["property_name"] = "conductivity2"; root[1]["properties"][0]["property_unit"] = "wareva2"; root[1]["properties"][1] = {}; root[1]["properties"][1]["property_name"] = "restitivity2"; root[1]["properties"][1]["property_unit"] = "ohmmeter2"; [/code:1zc6eo4u] Some equivalents with the JSON plugin would be: [url]https://dl.dropboxusercontent.com/u/23551572/C2/JSONDasat.capx[/url]

  • Yann, I'm here again, i tried creating the sample json you used for the inspection capx with the plugin and i'm having some issues.

    In a bit to achieve the nested array and objects, when i get to the debug mode somethings my json is just empty. what i'm I doing wrong? My sample capx is here

  • septeven, some of us are still looking out for the plugin

    Fimbul

    After this message, I dediced to make quickly a new plugin - It should be compiled in the week.

    Here is what you can expect to do (fully customizable - colors, dimensions, fonts, styles...)

Dasat's avatar

Dasat

Member since 14 Apr, 2013

None one is following Dasat yet!

Connect with Dasat

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies