citron2010's Forum Posts

  • Just been reading this:

    construct.net/en/tutorials/savegames-11

    What you can do instead is save the game state to JSON, then save that manually to e.g. local storage - then you _could_ delete it.

  • I think this has been asked before and the answer is that you can't! Instead, just ignore the slot you want to clear or overwrite it.

  • Looks like you could control it with JavaScript using something like:

    kalumajs.org

    You could probably do most of the work in event sheets though.

  • I've just built a "level factory" to build levels that are stored as an array of objects in JSON. I had to use JSON because two of the level parameters are themselves arrays. I can then assign a difficulty that I want to sort the levels by. But I need to download the JSON so I can re-import it as a project file, so currently plan to sort it using an online tool. But I will bookmark this in case I need to sort it at runtime.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I use AI quite a lot, but in general I use it to teach me how to do something rather than asking it to do that thing for me. If I try using it to say write some code for me, it might work, but I'll end up with something that I don't understand and is hard to extend or bug fix.

    I've found that ChatGPT's capabilities with Construct has improved significantly over the past few months - it seems to have a much better understanding of C3's event system.

  • For what it's worth, here's what I've just done.

    • I was using a sprite font because I noticed some differences in positioning across platforms when using regular text.
    • But I wanted to translate to Chinese!
    • I implemented the Internationalization plugin
    • Then used ChatGPT to translate - but did it phrase by phrase explaining to the AI the context of what the text was and its meaning - I think it's done a reasonable job - I've translated most of the text back to English and the correct meaning seems to have been preserved - but I will get it reviewed by a native speaker before I release.
    • I then took the zh_hans.json localization file and imported it into this tool:
    • https://r12a.github.io/app-listcharacters/
    • Which listed all the unique Chinese characters used in my text
    • I took that list and used it to create a sprite font using this:
    • https://stmn.itch.io/font2bitmap
    • And the font NotoSansSC-Regular.ttf
    • This meant I could create the sprite font I wanted without having to include ALL Chinese characters - just the ones I need.
    • Then I used an image editor to merge that sprite font with my original one
  • ...using 'Set response binary' has no effect once the AJAX request has completed. You must use that before sending the request for it to load in to the Binary Data object automatically when the request completes.

    Argh! Sorry - didn't read the manual thoroughly - it's working now that I've set that before the request. Thanks everyone - I now have a fully working native event sheet solution!

  • Sorry - should have screenshot more - I only run those events on the click of a button which is only enabled once the AJAX request had completed. I'll try to adapt my project to use the free version of Eleven Labs so anyone can try.

  • I'm using a paid Eleven Labs account.

    The JavaScript above works fine - sending the request, playing the response in JS, passing the URL of the response to a global variable, then in the event sheet, setting the Audio plugin's "Add remote URL" to that var and playing it (so I can insert effects).

    This is everything I need, but I was trying to do it all in event sheets, but something's not working in the events in the screenshot above. If I download AJAX.LastData, I see stuff like this in the header:

    ID3 #TSSE  Lavf60.16.100

    But VLC won't play it and presumably also why I get "EncodingError: Unable to decode audio data" when trying to play it in the event sheet using the actions in the screenshot.

  • I was just trying that to see what happened because:

    Also results in "EncodingError: Unable to decode audio data"

  • That’s what I’ve tried – both:

    • AJAX Set Response to BinaryData
    • BinaryData Set buffer to UTF-8 text AJAX.LastData

    (Which I believe are equivalent)

    If I then download it, I can see some relevant headers when opened in a text editor, but can’t play it in e.g. VLC. And Audio –> Add remote URL = BinaryData.GetURL -> Play returns “EncodingError: Unable to decode audio data”

    I’ve been working with ChatGPT on this and it gave me some JavaScript which sends the request, successfully plays the response and sets a var to the URL of the response. When that URL is then used in Audio – Add remote URL, it DOES work.

    My ultimate aim is to use the Audio Analyser effect to animate a sprite (to sync lip animation), so this approach works, but agree that it _should_ work using native C3 events.

    This is ChatGPT's JavaScript:

    fetch("https://api.elevenlabs.io/v1/text-to-speech/fexRy0lZ3HSLmYNrlI0v?output_format=mp3_44100_128", {
     method: "POST",
     headers: {
     "xi-api-key": "<my_secret_key",
     "Content-Type": "application/json"
     },
     body: JSON.stringify({
     text: "Construct 3 Rocks.",
     model_id: "eleven_multilingual_v2"
     })
    })
    .then(response => response.blob())
    .then(blob => {
     const audioURL = URL.createObjectURL(blob);
    
     // OPTION A: Play using JS
     const audio = new Audio(audioURL);
     audio.play().then(() => console.log("Audio is playing")).catch(console.error);
    
     // OPTION B: Pass to Construct's Audio plugin
     runtime.globalVars.AudioDataURL = audioURL; // You must create this global text variable
    })
    .catch(err => {
     console.error("Failed to fetch ElevenLabs audio:", err);
    });
  • Unfortunately they don't provide a URL - just audio to download in one of a myriad of formats! It's this API:

    elevenlabs.io/docs/api-reference/text-to-speech/convert

    I'll keep experimenting, because it IS returning something!

  • Hi,

    I’m trying to use Eleven Labs text-to-speech API to generate and then play MP3s.

    I request in their default format – “output_format=mp3_44100_128” using an AJAX request.

    But I’m not sure how to play it.

    I’m assuming I need to pass it to a Binary Data object first and have tried:

    • BinaryData – set from base64 (this produces no data)
    • AJAX – Set response binary -> Destination = BinaryData (also produces no data)
    • BinaryData – set from text (this does produce data)

    (If I download this via Browser – Invoke Download for string = BinaryData.GetAllText, MIME type = “audio/mpeg), it downloads something, but it won’t play)

    I’ve then tried:

    • Audio – Add remote URL = BinaryData (type = audio/mpeg) and added a tag
    • Audio – play tag

    But this returns:

    Failed to load audio 'blob:https://preview.construct.net/<some UID>': EncodingError: Unable to decode audio data

    Any ideas? I don’t really want to use JavaScript but importantly, I need to be able to use C3’s effects – specifically the audio analyser so I can animate a sprite based on the audio’s level.

  • I'm doing something very similar and agree with dop2000 that having slightly higher gravity would look better.

    But the other thing I did was move the image point that I'm applying the force too so that it's off centre, so when the force is applied, the parts rotate more.