Reading a file in a Lua script
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
Reading a file in a Lua script
I want to read a large events file in my.celx script. I will use this to print event text to the screen during a "spacecraft" trajectory flight. I noticed that the io.open will not work because the io.dll is not included in Celestia. Is there a "work around" to getting my large text file into a Lua script? Should I attempt to install the io.dll myself. I installed socket.dll many years ago and it worked.
-
- Site Admin
- Posts: 706
- Joined: 22.09.2018
- With us: 6 years 2 months
without all required information the answer is "i don't know". what celestia version do you use? what operation system (i assume windows as you are talking about dll). our builds of 1.6.2 beta and 1.7 don't require any additional dlls.
Last edited by onetwothree on 20.03.2020, 18:33, edited 1 time in total.
Lua io. routines are working for me with both 1.6.1 and 1.7 without the presence of an explicit io.dll.
I'm assuming you've included this statement in your CelX script:
I might have asked this before, but what version of Celestia are you running? 1.6.1, 1.6.2, 1.7? If it's 1.7, then you might not have the most recent binaries.
Another thing to check is the version of lua51.dll that you have. For example, how large is your lua51.dll? Mine for 1.7 is 358KB.
And here's its md5 checksum:
FWIW, I'm using the 3rd party Win10 utility "Winaero Tweaker" to get convenient RMB menu options like checksum calculators.
I'm assuming you've included this statement in your CelX script:
Code: Select all
celestia:requestsystemaccess()
I might have asked this before, but what version of Celestia are you running? 1.6.1, 1.6.2, 1.7? If it's 1.7, then you might not have the most recent binaries.
Another thing to check is the version of lua51.dll that you have. For example, how large is your lua51.dll? Mine for 1.7 is 358KB.
And here's its md5 checksum:
Code: Select all
Algorithm : MD5
Hash : ACF6330A105FDC128009FD089F2C499F
Path : C:\MyPrograms\Celestia_1.7.0\lua51.dll
FWIW, I'm using the 3rd party Win10 utility "Winaero Tweaker" to get convenient RMB menu options like checksum calculators.
Selden
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
my lua5.1.dll is 236kbytes. I am using Celetstia 1.6.1.
I tried celestia:requestsystemaccess() but I received the same io error.
I wasn't aware that any version is more recent than 1.6.1. Is there an installer of do I have to build it? Maybe my quaternions will work with the new verison 1.7. I went to the download page and I only see 1.6.1 available.
I tried celestia:requestsystemaccess() but I received the same io error.
I wasn't aware that any version is more recent than 1.6.1. Is there an installer of do I have to build it? Maybe my quaternions will work with the new verison 1.7. I went to the download page and I only see 1.6.1 available.
Unfortunately, 1.7 is still in "pre-alpha" mode and has quite a few changes and, well, bugs. I suggest it would not be appropriate to use 1.7 while trying to develop "production code" since it'd be rather difficult to separate bugs in your code from bugs or changes in Celestia.
My copy of lua51.dll that accompanies Celestia v1.6.1 is 236 KB also, and its MD5 checksum is
Where is your copy of Celestia installed?
(FWIW, I just now verified that I can use io. when running Celestia from a non-priv'd account, so privileges shouldn't be an issue.)
Now I'm wondering if the problem is caused by Celestia having been installed in the Windows directory "Program Files (x86)".
Windows is getting more and more protective about actions which affect its system directories. That's one of the reasons why I created my own separate directory named 'C:\MyPrograms\" (note no space) into which I install 3rd party software like Celestia.
My copy of lua51.dll that accompanies Celestia v1.6.1 is 236 KB also, and its MD5 checksum is
Code: Select all
Algorithm : MD5
Hash : 09819D1BEEF0F0BEEC849B6FD3581247
Path : C:\MyPrograms\Celestia\lua5.1.dll
Where is your copy of Celestia installed?
(FWIW, I just now verified that I can use io. when running Celestia from a non-priv'd account, so privileges shouldn't be an issue.)
Now I'm wondering if the problem is caused by Celestia having been installed in the Windows directory "Program Files (x86)".
Windows is getting more and more protective about actions which affect its system directories. That's one of the reasons why I created my own separate directory named 'C:\MyPrograms\" (note no space) into which I install 3rd party software like Celestia.
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
I moved "C:\Program Files (x86)\Celestia" to MyDocuments and I still get the io error.
I added celestia:requestsystemaccess() at the top but I get the error.
I right clicked on the Celestia Desktop short cut and ran it "As Administrator" but I get the error.
Did you have to add the line: require "io" when you successfully got 1.6.1 working? I get a dialog box "attempt to index global 'io' (a nil value)
Can you show me your line of test code.
I added celestia:requestsystemaccess() at the top but I get the error.
I right clicked on the Celestia Desktop short cut and ran it "As Administrator" but I get the error.
Did you have to add the line: require "io" when you successfully got 1.6.1 working? I get a dialog box "attempt to index global 'io' (a nil value)
Can you show me your line of test code.
-
- Site Admin
- Posts: 706
- Joined: 22.09.2018
- With us: 6 years 2 months
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
Reading a file in a Lua script
Sorry, onetwothree. My celestia:requestsystemaccess statement was ambiguous. I placed the celestia:requestsystemaccess statement at the top of my script. I still am getting the same missing io error.
There was no error on the line where I added celestia:requestsystemaccess.
Thanks Seldon, for the zip file. It appears that my code is similar to yours.
I attempted to run the script twice. Celestia warned me first, then allowed me to continue. See my screen shots.
Well, I don't know how to insert images so I'll type it:
This script requests permission to read/write files
and execute external programs. Allowing this can be dangerous.
Do you trust the script and want to allow this?
yes? No?
There was no error on the line where I added celestia:requestsystemaccess.
Thanks Seldon, for the zip file. It appears that my code is similar to yours.
I attempted to run the script twice. Celestia warned me first, then allowed me to continue. See my screen shots.
Well, I don't know how to insert images so I'll type it:
This script requests permission to read/write files
and execute external programs. Allowing this can be dangerous.
Do you trust the script and want to allow this?
yes? No?
@SimGuy:
Yup, that's the appropriate on-screen prompt.
Sorry, I previously forgot to mention that you actually need two lines in order for i/o to be allowed:
Without the wait, I doubt it'll work. I dunno if that's your problem, though.
For details, see https://en.wikibooks.org/wiki/Celestia/Celx_Scrip ... x_celestia#requestsystemaccess
To insert a picture, while working on a post, you should select the option "Full Editor & Preview" down at the bottom of the "Quick Reply" window. The editor page provides two ways to insert an image. In both cases, you still need to select the option "insert inline" for it to actually show up.
See screengrabs below, which were inserted using this method:
Yup, that's the appropriate on-screen prompt.
Sorry, I previously forgot to mention that you actually need two lines in order for i/o to be allowed:
Code: Select all
celestia:requestsystemaccess()
wait(0)
Without the wait, I doubt it'll work. I dunno if that's your problem, though.
For details, see https://en.wikibooks.org/wiki/Celestia/Celx_Scrip ... x_celestia#requestsystemaccess
To insert a picture, while working on a post, you should select the option "Full Editor & Preview" down at the bottom of the "Quick Reply" window. The editor page provides two ways to insert an image. In both cases, you still need to select the option "insert inline" for it to actually show up.
See screengrabs below, which were inserted using this method:
Selden
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
Reading a file in a Lua script
The 'wait(0)' fixed my problem. I also modified the celestia.cfg so I don't get the nag message.
I am testing the attachment process with my nag message.
Thanks again for you help.
I am testing the attachment process with my nag message.
Thanks again for you help.