How do I open a local text file using the Operating System's File Dialogue?

0 favourites
  • 3 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • I'm making a game that has a secret Text editor in it. I was trying to use the built-in GetFile addon to grab a text document, take the text from it, and set a variable to that text. But I can't figure out how to get the data. So I tried doing it with Javascript. First, I created this script:

    Then, within my event sheet, I check if a button is pressed, and run this script when it is:

    	globalThis.TextField.Input = openFile()
    

    When I run the game, and click the button, it opens a windows file dialogue and allows me to select a plain-text file. I select one, but when I do, the whole window goes white and displays the text, like it replaced the browser tab with the actually opened file, instead of importing the file into the game. Not sure what I am doing wrong here?!

    Also, I would like to save text files to the device using the file dialogue as well.

  • Sorry, I can't help you with JS, but it's very easy to do with events.

    Add FileChooser and AJAX objects, and this event:

    .

    You can also use NWJS action "Show open dialog" and NWjs.ReadFile(path) expression.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks a ton but I had just discovered this thing existed right after posting this! I never knew it was a thing lol...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)