Fireche's Recent Forum Activity

  • Fireche

    You are running into a subtlety.

    > CurrentKey

    > In a For each loop, a string of the current key name. If an array is being looped, the current key is a string of the current index, e.g. "0", "1"...

    Since your data is in an array, CurrentKey will have indexes to the array. What you need to do then is load what is at that path in the json into another JSON plugin instance and then loop through that. Because the new loop in on a json object, CurrentKey will have the key names as strings.

    https://www.dropbox.com/s/3zzdt1yjk9riwwr/ReadingJSON.c3p?dl=0

    The example does just that. The only thing which is rather cryptic is the path you need to give to GetAsCompactString to extract a single item from the json array.

    For this example JSON, doing JSON.GetAsCompactString("array.0") gets you the first item as a string, which you can load into another JSON object using the Parse action.

    > 	{
    		"array": [
    > 			{"foo": "1"},
    > 			{"bar": "2"}
    > 		]
    	}
    

    An extra detail I noticed while puting the example together, it seems the path you need to give to GetAsCompactString has to be absolute.

    thank you, this works fine :) maybe the JSON plugin could be updated to support this without the use of having to instantiate a temp object? :P

  • Was the format [{"foo": "bar"}] readable?

    I try using ({"foo": "bar"}) seems okay.

    ({"foo": "bar"}) is not valid JSON syntax.

  • Current key is the name, current value is the value of that key.

    Provided you have the correct path.

    If its not doing that then make a test project to someone to debug.

    Current Key is index of an array as the documentation says. But maybe I am missing something. here is the example project:

    easyupload.io/tws6mx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am struggling to fetch the key of an object in a json-array:

    [{"foo": "bar"}]

    How can I read the "foo" key? I don't need the value of "foo"; I only need the key "foo" itself.

    I am iterating over all items and JSON.CurrentKey only returns the array index, unfortunately.

    The documentation says > CurrentKey

    In a For each loop, a string of the current key name. If an array is being looped, the current key is a string of the current index, e.g. "0", "1"...

    but it does not say how to get the actual key name when looping over an array. Any ideas?

  • If you mean that it doesn't always create the matching object like over A it creates B instead of A then this is intentional, if you use Family it creates a random object inside Family.

    Interesting. I think the behavior should be different when I specifically iterate over all family instances right before. I kind of expect the family object in the create method to be the same .

  • You can't leave the expression empty in for each (ordered) dialogue. At least a property of the object required. By default construct create random family instances plainly. From what "ordered" suggest a filter criteria needed for example 'family.Y' will filter family instances based on their Y position in ascending/descending order.

    So for your case the expression require ObjectTypeName:

    https://www.dropbox.com/s/sd1f6ikhqfupmj5/family_order_byType.c3p?dl=0

    okay I see..this does not seem so intuitive to me but alright. How do I access the last created object when it's created by name?

  • I would like to iterate over all instances of an object family, and for each instance, I would like to create a new instance.

    The issue is that it sometimes creates multiple instances of the same object, and I don't understand why.

    In my playground, I have two instances, A and B, and expect another A and B to be created.

    But instead, sometimes it creates AA, BB, AB. I would understand that when iterating over the instances, it includes the newly created once, but then I would expect an infinite loop which also doesn't happen. Instead, it only always creates two new instances.

    To avoid an infinite loop, I added another condition to ensure it only iterates over the instances off-screen. But it is still the same issue.

    Does anyone have an idea what's going wrong here?

  • To append to my previous statement, I have plenty of experience working within construct 2, less so c3. I used Tiled to create levels in c2 and Unity.

    Hey, sorry for the late answer. There was no notification that I received an answer. Sounds good, I don't find an option to send you a PM so how do we further discuss the details?

  • I am still looking.

  • Hey Fireche

    I have plenty of experience with building and decorating levels using tilemaps (using tile-background, 9-patch, sprites and vector where needed).

    For my game Bad Pad I built 160 levels/layouts, the levels/layouts size increases exponentially as you progress.

    http://store.steampowered.com/app/517210/

    For Bad Run Turbo Edition I built 3 big open-world castle levels (total size 83000 x 56000 px)and a procedural run-time level generating system using over 100 predesigned tilemap sections.

    http://store.steampowered.com/app/1285070/

    For my latest game I already made around 140 layouts.

    http://store.steampowered.com/app/1367050/

    http://headbangames.com/becloudead/devblog/

    You can read more about my work and contact me here:

    http://headbangames.com/devblog/contact/

    Cheers

    Perfect, I sent you an email :)

  • Just looking for someone to use the existing tiles and place them to create a beautiful level.

  • Hello everyone,

    I am looking for someone who is motivated to design a level for my 2d pixel-art game.

    I already have the tiles but I lack the time to carefully create a beautiful terrain. I would need you to "design" a village, and some parts of a forest.

    Please let me know if you are interested. Include some references from previous work if you can.

    It's a paid position. The exact amount depends on your skill level.

Fireche's avatar

Fireche

Member since 23 Mar, 2015

Twitter
Fireche has 1 followers

Trophy Case

  • 9-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies