Nilom's Recent Forum Activity

  • Thank you! This will help me later.

    Now I am a little despairing about how I can create nested objects with the eventing system.

    I am trying to do something like this:

    Characters: [
    
    	{
    	id: loopindex
    	class: randomClass()
    	hp: getHP(self.class)
    	},
    	
    	{
    	id: loopindex
    	class: randomClass()
    	hp: getHP(self.class)
    	},
    
    	{
    	id: loopindex
    	class: randomClass()
    	hp: getHP(self.class)
    	}
    
    ]
    

    So inside the object Characters each of the characters should have his own object with own key: value pairs for storing its id, class, hp and many more.

    I guess I have to push an array and inside that array an empty object or so. But I can't get it to work.

    The current state of my events:

    I changed it many times but it is hard without an example. :(

  • dop2000 thank you for your answer. :)

    Ok that is a bit unfortunate.

    Then I will set the data up as a javascript object via script event and then load it to a global variable. For saving and to use that object with the eventing system.

    What I wonder is however, how can I make this object readable by the runtime engine? Do I have to parse it or something like that?

    It is inpractical, that there is no eventing system for dealing with js objects, like with the arrays.

    I need the data structure to be a js object. Arrays would be a pain.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is there a way to write to one of the projects JSON files? I wanted to use it as kind of a database.

    If there is no way to do this, how much would be the performance impact and memory usage of an javascript object containing thousands of key/value pairs? (Up to 30.000 - 50.000)

    And would it be possible to save this object to one of the projects global variables and save&load from local storage?

    Thanks in advance!

  • You are my hero! I will try this later. Got sick yesterday but today I feel better.

    Thank you again for your help. :)

  • Hmmm. This is strange. raids is a global variable that I parsed AJAX data to. It should be an object.

    I described in this post construct.net/en/forum/construct-3/scripting-51/parse-json-objects-return-149689 how I sat it up.

    Did I do it wrong?

  • Wow this is super awesome! I will test it out as soon as I am at home. Thank you for the efforts! :)

  • Hello!

    I would like to use the javascript filter() method. Is it possible with scripting in Construct 3?

    I tried it both in the editors script file and in the add script command in the events.

    raids.filter(raids => raids.id === localVars.raidID1)[0].raidMembers.filter(x => x.isConfirmed)

    Both times it gave an error message in the console "filter is not a function".

    How can I use Javascripts filter() method?

  • Thank you very much for this idea.

    I asked the programmer if he could restructure it that way and he told me it wouldn't work, because the IDs are dynamic.

    But he told me about variable.filter(). That is pretty handy and I think I can use it.

    Thanks again. :)

  • Thanks for the reply. I know about arrays. But how would I know the array index from, lets say the player name and his level inside one of the raids/dungeons? I would need arrays with named indices. Instead of array.0 I would need something like array.raidID.playerID.name. Or array["raidID","playerID","name"].

  • Hello!

    I use the AJAX events to get this and similar Objects from a server:

    [
     {
     "id": "3510d1-43e-4c45-be00-156ffk6d5da",
     "name": "BWL",
     "description": "",
     "dateFrom": "2020-01-30T18:00:00.0000000Z",
     "dateTo": "2020-01-30T22:00:00.0000000Z",
     "raidMembers": [
     {
     "characterId": "3z3z4a-5364-473c-97b1-gf63kl06",
     "isConfirmed": false,
     "name": "Jorgen",
     "class": "Hunter",
     "role": "RangedDamage",
     "talents": "MM",
     "race": "Troll",
     "guild": "Bla Bla",
     "level": 24,
     "isMain": false,
     "confirmedAt": "2020-01-26T23:31:33.32299Z",
     "confirmedBy": "Jeff",
     "registeredAt": "2020-01-26T23:30:59.5301Z",
     "unregisteredAt": "2020-01-27T15:58:20.61561Z"
     },
     {
     "characterId": "ashh2a9-33ac-654-923f3-456kgh8bb",
     "isConfirmed": true,
     "name": "Jeff",
     "class": "Warrior",
     "role": "Tank",
     "talents": "Deep prot",
     "race": "Undead",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": "2020-01-29T11:33:24.56272Z",
     "confirmedBy": "",
     "registeredAt": "2020-01-26T23:30:55.754507Z",
     "unregisteredAt": null
     },
     {
     "characterId": "d637hd-e256e-26d2-237-a8htz6hb15",
     "isConfirmed": true,
     "name": "Gubbo",
     "class": "Shaman",
     "role": "Healer",
     "talents": "Resto / Support",
     "race": "Orc",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": "2020-01-29T11:33:24.526091Z",
     "confirmedBy": "",
     "registeredAt": "2020-01-27T11:22:03.78456Z",
     "unregisteredAt": null
     },
     {
     "characterId": "daafe672-833e-6270-3gb-f970h29e39",
     "isConfirmed": false,
     "name": "Gimp",
     "class": "Warrior",
     "role": "Tank",
     "talents": "Furry-Prot",
     "race": "Orc",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": null,
     "confirmedBy": null,
     "registeredAt": "2020-01-27T17:03:19.3627Z",
     "unregisteredAt": "2020-01-27T17:03:20.389363Z"
     },
     {
     "characterId": "602j4e-43j89-d651-dag4a-jkh20ua38f",
     "isConfirmed": false,
     "name": "Looky",
     "class": "Rogue",
     "role": "MeleeDamage",
     "talents": "(°O°)",
     "race": "Orc",
     "guild": "Hamlo",
     "level": 60,
     "isMain": false,
     "confirmedAt": null,
     "confirmedBy": null,
     "registeredAt": "2020-01-28T03:53:18.35210Z",
     "unregisteredAt": "2020-01-28T03:53:19.747Z"
     },
     {
     "characterId": "056e716-ajk7-33fb-32fg-dgfd70s6",
     "isConfirmed": false,
     "name": "Sery",
     "class": "Priest",
     "role": "RangedDamage",
     "talents": "Shadow",
     "race": "Tauren",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": null,
     "confirmedBy": null,
     "registeredAt": "2020-01-29T11:35:21.1520Z",
     "unregisteredAt": "2020-01-29T11:35:21.2555589Z"
     },
     {
     "characterId": "d956614d0-b775-75h4-bc5f-0956971dd",
     "isConfirmed": false,
     "name": "Myth",
     "class": "Priest",
     "role": "Healer",
     "talents": "CH 21/30",
     "race": "Troll",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": "2020-01-29T14:14:54.23564Z",
     "confirmedBy": "",
     "registeredAt": "2020-01-29T13:59:56.0963920Z",
     "unregisteredAt": "2020-01-29T21:08:47.3569952Z"
     }
     ],
     "raidGroupId": "43gga-9453-4hgc-83d0-j3i927f"
     },
     {
     "id": "g3j6n2-2n5-442b-4c-23a0a6262hkl38",
     "name": "Molten Core",
     "description": "",
     "dateFrom": "2020-01-30T17:30:00.0000000Z",
     "dateTo": "2020-01-30T21:00:00.0000000Z",
     "raidMembers": [
     {
     "characterId": "jdfa9-3ffjc-f4-9cfd83-4j5kbb",
     "isConfirmed": false,
     "name": "Jeff",
     "class": "Warrior",
     "role": "Tank",
     "talents": "Deep prot",
     "race": "Undead",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": "2020-01-26T23:32:57.36435Z",
     "confirmedBy": "Jeff",
     "registeredAt": "2020-01-27T18:04:08.7722Z",
     "unregisteredAt": "2020-01-30T17:44:13.72376Z"
     },
     {
     "characterId": "798a7g-8f3gh-fd55h-dfg-d8g2h98j6",
     "isConfirmed": false,
     "name": "Jorgen",
     "class": "Hunter",
     "role": "RangedDamage",
     "talents": "MM",
     "race": "Troll",
     "guild": "Bla Bla",
     "level": 24,
     "isMain": false,
     "confirmedAt": "2020-01-26T23:32:48.45668Z",
     "confirmedBy": "Jeff",
     "registeredAt": "2020-01-26T23:32:52.64566Z",
     "unregisteredAt": "2020-01-30T17:44:10.456453Z"
     },
     {
     "characterId": "5g34e-7gg-3451-b534a-df98gjf",
     "isConfirmed": false,
     "name": "Looky",
     "class": "Rogue",
     "role": "MeleeDamage",
     "talents": "(°O°)",
     "race": "Orc",
     "guild": "Hamlon",
     "level": 100,
     "isMain": false,
     "confirmedAt": null,
     "confirmedBy": null,
     "registeredAt": "2020-01-28T03:54:01.54533Z",
     "unregisteredAt": null
     },
     {
     "characterId": "98d7fg6-adf77-4gdb-bhr2-d1kjoij5a6",
     "isConfirmed": false,
     "name": "Seri",
     "class": "Priest",
     "role": "RangedDamage",
     "talents": "Shadow",
     "race": "Tauren",
     "guild": "Bla Bla",
     "level": 60,
     "isMain": false,
     "confirmedAt": null,
     "confirmedBy": null,
     "registeredAt": "2020-01-29T11:35:41.6438Z",
     "unregisteredAt": null
     }
     ],
     "raidGroupId": "72828ha-4233-4f4c-8230-asd987fb"
     }
    ]
    

    I then use JSON to parse it.

    But this is unpractical because I want to be able to re-referance the Data at a later time and I need to know how I can just pick specific keys/values.

    I stored the parsed JSON value in a global variable. But I guess this is wrong for easily accessing specific object data later.

    1) Can someone please give me an example how I can write .name of .raidmembers with a text object?

    2) And how can I reference .name if there are multiple members / nested objects?

    raids.raidmembers.name[0]

    raids.raidmembers.name[1]

    raids.raidmembers.name[2]

    Something like that?

    3) Is there a way to use Javascript Objects within the event system?

    Thank you in advance! :)

  • Ahhhh. I see now. Very clever. Thank you that will surely come in handy.

  • Oh thank you for the fast response!

    I did not fully understand how I can "Pick" the Icon and the IconFamily.

    But with your hints I found the Pick last created condition and it works perfect. Because it will always have the same instance order.

    But just in case, can you tell me how I can use your solution? :)

Nilom's avatar

Nilom

Member since 26 Dec, 2019

Twitter
Nilom has 1 followers

Trophy Case

  • 4-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

9/44
How to earn trophies