quackgyver's Forum Posts

  • What C3 object ?

    Please provide clearer informations regarding what you are trying to achieve and how your project is configured for that currently.

    Sure, I can break down the use case described in the original post:

    • We're storing the URI of an image resource somewhere in Construct 3 (variable, object data or otherwise).
    • We need convert the image that is accessible via the URI to base64.
    • We don't want to use plugins to achieve this (or at the very least not non-vanilla plugins).

    You recommended using JavaScript to achieve the conversion from image to base64, but my question is how we would be able to access a URI that is stored somewhere in Construct in JavaScript code, given that the URI is stored somewhere in the project.

    EDIT:

    If it helps, we can imagine for the sake of discussion that the URI is stored in a parsed JSON object that we would want to be able to access via JavaScript, assuming that JavaScript is the only way to achieve the desired result.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the binary plugin to hold the base64 data, and get it from there.

    I meant the other way around. How do I access the URI that I have in a Construct 3 object from within a snippet of JavaScript code?

  • You could use the Scripting feature in order to use the javascript function that does so.

    https://www.construct.net/en/make-games/manuals/construct-3/scripting/overview

    https://stackoverflow.com/questions/30631927/converting-to-base64-in-javascript-without-deprecated-escape-call

    Thanks!

    How can I fetch the image URI via a JavaScript call in this context though?

  • It's not! If it's red it's not associated. Just try adding a new Else and move on.

    I don't understand what you mean.

    I'm asking why the "Else"-case is red, given that it should be valid in that image.

  • Is it possible to convert an image accessible via URI to base64 without using plugins?

  • It's not associated at this point. It must have belonged elsewhere, and that IF was deleted. If you try to add Else to the len() IF, it will add one, in black.

    I'm not understanding your explanation.

    What do you mean by "It must have belonged elsewhere"?

    Based on the image that I provided the "Else"-condition should not be red, since it's a valid event structure.

  • the fact that it is red means it has been orphaned from the condition it was attached to. whatever that was has been deleted, so the else turns red to let you know it is not an else for anything at the moment. There is a condition above it but the else is not connected to it in any way except that the else is the next thing on the event sheet. delete the else, right click on the event above and add a new else if that one needs an else.

    I'm not following. Putting "Else" in its own condition following another condition has always been a valid way of using "Else".

    I don't understand how the "Else" in this case could be orphaned when it's related to the condition above?

  • I don't think it is connected to the event above

    How do you mean? It's placed right after the first event.

  • Why is "else" red in the attached image?

  • You would essentially create a third party editor when you set the state of the tilemap, use the Browser plug to download the json either Tilemap.TilesJSON, or Tilemap.AsJSON I'm not sure, then import that file into project files for use with Ajax during runtime when you set the texture.

    The json should have all the data you need to completely change an existing tilemap, aside from the image data.

    Yeah but I'm not asking how to change the Tilemap image data. I'm asking various questions related to the image size not changing when changing the Tilemap image.

  • I would say you probably need to take a look at using the json save state, and using it if you need to import stuff besides the texture.

    Not sure I'm following. How do you mean?

  • I've had a lot of problems with not being able to load Tilemap image URI's during runtime, and I've boiled it down to the Tilemap object's image size not adapting to newly-loaded images.

    To be more specific, while other objects types (Sprites, Backgrounds) adapt their image sizes to fit whatever image that is loaded in during runtime, the Tilemap object apparently demands that nothing exceeds the original image size.

    My questions are:

    • What happens if i load in an image that is smaller than the original image size? Will I just get a lot of blank tiles until the tile row wraps, or will the image size shrink to fit the new, smaller image?
    • What happens if I decide that I need more tile space, and increase the original image size to allow for larger images to be loaded in. Will the tilemap data become messed up, due to the tile row wrapping changing?
    • Is there any way to get around Tilemaps not being able to load in larger images during runtime?

    Thanks in advance.

  • "Executed", not "excluded". Because that's how Construct works. All events are executed on every tick, unless they are triggers or functions.

    Sorry, I misread.

    I expect them to be executed on every loop, yeah, so that's fine by me.

    It still may require 1-2 ticks to be fetched, or maybe even longer on a slower machine. So you should not start checking JSON keys until it finished loading!

    Try this code:

    > JSON has key "maps.test" -> Browser Log "HAS key, "&tickcount
    Else -> Browser Log "NO key, "&tickcount
    

    Open browser console and check the messages. You will probably see a couple of "NO key" before "HAS key" appear.

    I actually can't get that to work at all:

    I've tried with single quotes, double quotes as well as loading the data from a separate JSON-file, but this always returns "no test".

    JSON.CurrentKey works only inside "JSON For Each" loop. If you need to get current path outside the loop, use JSON.path expression.

    Yes, I'm doing this as part of iterating through a foreach-loop.

  • If the events are at root level, they are executed on every tick.

    Why are they excluded?

    And if you are getting JSON data from a file or Internet, then it may not be ready during the first couple of ticks. And that's why the Else part is triggered.

    It's all local, so nothing is fetched remotely. All I'm doing is loading in a local JSON file that is embedded with the project.

    The reason why I posted this topic is because I'd like to understand how Construct loops through JSON. As far as I can tell, this information doesn't seem to be available anywhere.

    I keep running into strange scenarios like the one outlined in this thread, as well as a new one that I encountered just now where:

    Will not fire at all, but:

    Will set the global variable "debugger" to "background".

    The fact that you can't really troubleshoot JSON with breakpoints makes the whole thing challenging:

    Is there no information anywhere on how Construct loops through JSON objects?

  • This is possibly a bug with the JSON object.

    If you run in to a bug or issue in Construct 3, please post it to the GitHub issue tracker here:

    https://github.com/Scirra/Construct-3-bugs

    You must follow the bug report guidelines or your issue will be closed without investigation.

    Construct is a great product, but as far as the bug reporting goes the customer experience is not so great.

    Customers shouldn't be expected to deal with issue creation, refinement, maintenance and demanding responses from engineers who think that issues needs further refinement or be split up into additional issues.

    And like, threatening with "having my issue closed without investigation" unless I jump through all these hoops is not exactly going to entice me to want to submit bugs.

    > You need to remove "Append JSON.Get("books.title") (i.e. line #3) for the "Else"-case (i.e. line #4) to fire.

    Nope, without this action it still works correctly for me. The Else event is not fired if the key exists in JSON.

    https://www.dropbox.com/s/2x9jtliyiud772n/JSON_HasKey.c3p?dl=0

    Sorry, I just noticed that you had an AJAX-related trigger. It needs to be a continuous loop that checks for "Has key" on every loop.

    If you put your two sub-conditions on root level so that they run on every loop then it should work. :-)

    Thank you very much for the help so far!