Nilom's Forum Posts

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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? :)

  • Hello past me. I have come across a working solution:

    On start of layout call the function that we define in the scripts.

    If there is no Token in the url the global variable access_token will only contain "Bearer ". In that case it will forward to the login-page.

    Here is how the Token is read from the url.

    window.location.href will return the full url. We slice out the part where the Token starts ("ey") until the part where it ends ("&token_type").

    Now we got the Access Token and can use it within the value part of the AJAX: Set request header.

  • Is there any possible way how I can reference a previous sprite if there are a multiple number of them?

    Like picking the sprite by it's IID: icon(icon.count-1)?

    I make a calendar. At every day in the calendar events can happen. If there is an event at a given day I will spawn an icon/sprite inside that calendar cell.

    Now I want to modify the size and position of the previous icon, if there is already an event at the same day. Instead of centering a single big icon I want to make both icons smaller and have one left and one right.

    Here is a screenshot from the event:

    And here is the result:

    As you can see the first icon is bigger and centered. That's how it should look like if there is only one event on that day. But because there are two events on that day both should be small and on the sides like the smaller, right one.

    But I do not know how I can edit the properties of the previous sprite from within the second subevent.

    I know some Javascript, but with runtime.Objects.RaidIcons(runtime.Objects.RaidIcons.count-1).destroy() I wasnt able to destroy the Icon with the previous Index.

    Any ideas? Thanks in advance! :D

  • Oh nevermind. You are right. I had this piece of script at a wrong place.

    Thank you for your quick help. Very appreciated. :)

    Do you know how I could use this to read the access token of an url? I'm currently trying to do it with substring, slice and so on but I'm a novice in javascript. Maybe there is an easier way. :D

  • Hello!

    Is there a way to read the current url the project/game is running on?

    Because when I can read the url I can try to extract the access/login token from the url.

    I tried this property to read the url:

    window.location.href;

    But no success so far. window.location.href should return the current url, right? When I insert this to the browser debug console it displays the correct url. But when I set a global variable to this via script the variable remains blank.

    Thank you in advance! :)

  • You do not have permission to view this post

  • Wow super awesome! I was exactly looking for something like this. Thank you very much. :)

  • It is planned for the use as an UI element. And I do not know the radius yet. So I would really love if someone could have an example on how to use drawingcanvas eventing or javascript.

    I found things like

    function roundRect(x, y, w, h, radius) { var canvas = document.getElementById("canvas6"); var context = canvas.getContext("2d"); var r = x + w; var b = y + h; context.beginPath(); context.strokeStyle="green"; context.lineWidth="4"; context.moveTo(x+radius, y); context.lineTo(r-radius, y); context.quadraticCurveTo(r, y, r, y+radius); context.lineTo(r, y+h-radius); context.quadraticCurveTo(r, b, r-radius, b); context.lineTo(x+radius, b); context.quadraticCurveTo(x, b, x, b-radius); context.lineTo(x, y+radius); context.quadraticCurveTo(x, y, x+radius, y); context.stroke(); }

    in the Javascript documentation. But many times when I try to use plain Javascript I get errors when testing the game.

    When I use this with roundRect(700, 600, 200, 200, 10) I get "Cannot read property 'getContext' of null".

  • Thank you for the reply. I already saw the post. Does it mean I need to draw the 9 patches as a sprite and set it up in a complicated way?

    I would have liked to avoid this, as I hate spriting and I would prefer code. :D

  • Hello!

    How do I draw a rounded rectangle?

    Either with events or scripts will work for me.

    I tried it with scripts but many times things will not work if I try using the normal javascript syntax.

    Thank you in advance. :)

  • I noticed that everythime that I start the preview of the project the pop-up window will be a little bit smaller than before. After several time I will need to resize the preview window manually because it got too small. I use google chrome.

    Is that a browser thing or a bug?

  • Oh thank you very much. That makes sense. I fixed it now by using sprites.

  • Hello together.

    Currently I'm doing a calendar with construct 3. Therefore I have a number of buttons (the date cells) and want the date number to be in the top left corner of the button.

    I do not use normal button text, because each button (date cell) will have several numbers and text all over this cell (date number, text, etc).

    But whatever I do with Z ordering the text object it always keeps behind the buttons. Is there a behaviour like the buttons are always on top of all other objects no matter what, or am I doing something wrong?

    On start of layout I create the buttons with a nested loop. I tried several Z order things with the text.

    But the text keeps being behind the buttons. I deleted a cell, so you can see where the text is.

    What can I do to have the text above anything else?