The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote
func _on_Button_pressed():
if !$AudioStreamPlayer.is_playing():
    var file2check = File.new()
    var doFileExists = file2check.file_exists("res://musics/aca" + $LineEdit.get_text() + ".mp3")
    if !doFileExists:
        $HTTPRequest.set_download_file("res://musics/aca" + $LineEdit.get_text() + ".mp3")
        $HTTPRequest.request("https://www.eduardodequadros.online/playlist_academia/aca" + $LineEdit.get_text() + ".mp3")
    else:
        $AudioStreamPlayer.stream = load("res://musics/aca" + $LineEdit.get_text() + ".mp3")
        $AudioStreamPlayer.stream.loop = false
        $AudioStreamPlayer.play()

func _on_LineEdit_gui_input(event):
if event is InputEventKey && event.is_pressed() && !$AudioStreamPlayer.is_playing():
    if event.get_scancode() == KEY_UP:
        if numero_musica >= 72:
            numero_musica = 72
            if numero_musica < 10:
                $LineEdit.set_text("00" + str(numero_musica))
            elif numero_musica < 100:
                $LineEdit.set_text("0" + str(numero_musica))
            else:
                $LineEdit.set_text(str(numero_musica))
        else:
            numero_musica += 1
            if numero_musica < 10:
                $LineEdit.set_text("00" + str(numero_musica))
            elif numero_musica < 100:
                $LineEdit.set_text("0" + str(numero_musica))
            else:
                $LineEdit.set_text(str(numero_musica))
    elif event.get_scancode() == KEY_DOWN:
        if numero_musica <= 1:
            numero_musica = 1
            if numero_musica < 10:
                $LineEdit.set_text("00" + str(numero_musica))
            elif numero_musica < 100:
                $LineEdit.set_text("0" + str(numero_musica))
            else:
                $LineEdit.set_text(str(numero_musica))
        else:
            numero_musica -= 1
            if numero_musica < 10:
                $LineEdit.set_text("00" + str(numero_musica))
            elif numero_musica < 100:
                $LineEdit.set_text("0" + str(numero_musica))
            else:
                $LineEdit.set_text(str(numero_musica))

This manner, when I press the button on UI for the first time on the debugging program, click on Godot editor, the file is downloaded, but when just using the exported program, the file isn't downloaded. I want to create a Windows program installer with Inno Setup, that doesn't accept setups larger than 2 GB.

Godot version 3.4
in Engine by (68 points)

2 Answers

0 votes

You can't change the files in res:// with a built project. The res:// folder is not meant to be changed at runtime, only read from. For that you'll want to use the user:// directory instead, which will be in a separate folder on the system for game data. This is also where save files are usually stored as well. ;)
https://docs.godotengine.org/en/stable/tutorials/io/data_paths.html

by (654 points)
0 votes

andersmmg, you said me that I need a user:// path. I want to know if can be a relative path. For example, if my script is on res:// path, the relative path to download will be ./musics/aca01.mp3.

by (68 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.