Jump to content
CodeHunterEx

Text Reader

Recommended Posts

I am looking for a way to be able to load a text file and have a text box the size of the game window where you can display and scroll the text on the screen.

 

Is this possible?  Is there a script or other way to accomplish this?

 

The idea is to have the player click on a event that loads a text file and lets them read the text and then close the window.

 

Thank you

Share this post


Link to post
Share on other sites

I did something like this with my Ebook reader I made months ago :P But I changed OS and I don't have the project source anymore. but the principles are simple.

use a file exists function to check if the file exists to load. then use file read function and store each line in an array or similar. draw_text_ext to bound the text in the window spacing. or write the text file with the limits in mind and /n to start a new line. scrolling is input.trigger? and then pick whatever keys you want to be up and down and so on. update the text drawn when the input is triggered. dispose on scene.exit.

Share this post


Link to post
Share on other sites

This script is promising: 

 

 

I have a problem, though when I try to use it to read the files.  When the player selects the item to read the game seems to freeze up.  Wait long enough and it may load.

Is there a size limit to this script, or is there something I need to do to get it to load?  I even tried this using a clean project and get the same problem.

Share this post


Link to post
Share on other sites

Does anyone work with Ace scrips these days, and can the problem loading files over say 250KB files be corrected?   Or know of a script that does the same feature without the loading issue?

Share this post


Link to post
Share on other sites

What do you meant with loading file problem over specific size? If it's about the delay, I believe it's caused by the amount of the lines instead of the file size. It's true that more lines you have means more size; However, two files with same line but different size should have the same loading time, as most file reader reads the file line by line.

 

Because this is an engine limitation oh how fast they can run a large number of loop, there's no way to improve this unless we're changing (to be exact, "improving") the algorithm on how we read the files. As far as I know, I haven't seen/heard anyone attempt to do this yet.

 

For your information, I have a file such that each lines fit about more than half of the width of the game window. The size is 259KB and there's over 8K lines inside the file. It took the game about 3 to 7 seconds to load all those lines. I doubt there's a lot of game that'll need an information of 8K lines presented in a single window (Imagine how long it'll take to scroll them all up).

 

Edit: I'm using my own text reader thought. It can load more than 1K lines under 1 second. EST Notebook scripts might have longer delay due to it have more customization (so it needs to run more script lines for a single text line) compared to what mine's have (almost no customization/options). I believe you could disable all those option on EST Notebook to make the loading faster.

Edited by Black Mage
Fix some wording.

Share this post


Link to post
Share on other sites

why not try the divide-and-conquer algorithm instead? that should reduce any action by a lot. ya it's for sorting, but you can apply it to reading a file even. maybe even through in recursion for best optimization.

 

I mean just look at the theta-notation for merge-sort compared to linear time efficient algorithms such as bubble sort

Edited by Asharonapaul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×