Hello.
I'll have to help a kid writing "a lesson" (a detailed Solar system tour) using Celestia. He will write all the text, i'll do all the programming/scripting part.
It could be much easier if he could write whatever it wants on a file (call it "lesson.txt"), and (using a bit of formatting?) print that lines of text from the "Showlesson.cel" file... using arrays and indexes?
i tried to look about this but i have'nt found nothing.
Is it possible? If yes, how?
cel script: Is it possible to print text from another file using index?
You'll have to write a .CELX script, not a .CEL script. Then you can use standard Lua I/O calls. They're not specific to Celestia. However, you do have to ask Celestia to let you do it. By default, file I/O is not allowed.
See https://en.wikibooks.org/wiki/Celestia/Celx_Scrip ... x_celestia#requestsystemaccess
See https://en.wikibooks.org/wiki/Celestia/Celx_Scrip ... x_celestia#requestsystemaccess
Selden
Years ago when I did the first pre alpha versions of my solar system tour DVD, I used a system like that.
This was quite a few years ago and my notes are non existent, this is just off the top of my head.
What I did was make a file that created an associative table in a file such as planetinfo.celx for instance.
Planet_Table = {}
Planet_Table["Mercury"] = "This is Mercury, the first and fastest planet. It goes around the sun in 88 of our days, which is its year."
Planet_Table["Venus"] = "This is Venus, the brightest planet in our sky, better known the dawn or evening star."
Then 'require' that associative array in my main script.
local PlanetTable = require("planetinfo.celx.Planet_Table")
Then call celestia:print(PlanetTable['Mercury'])
I don't remember exactly, but it was something like this.
The planetinfo.celx had a return or something in it I think.
It was funky and awkward, but worked.
If I can find it again, I can post it if needed.
Janus.
This was quite a few years ago and my notes are non existent, this is just off the top of my head.
What I did was make a file that created an associative table in a file such as planetinfo.celx for instance.
Planet_Table = {}
Planet_Table["Mercury"] = "This is Mercury, the first and fastest planet. It goes around the sun in 88 of our days, which is its year."
Planet_Table["Venus"] = "This is Venus, the brightest planet in our sky, better known the dawn or evening star."
Then 'require' that associative array in my main script.
local PlanetTable = require("planetinfo.celx.Planet_Table")
Then call celestia:print(PlanetTable['Mercury'])
I don't remember exactly, but it was something like this.
The planetinfo.celx had a return or something in it I think.
It was funky and awkward, but worked.
If I can find it again, I can post it if needed.
Janus.
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 18 years 11 months
Parduz,
This works in Windows.
CC
This works in Windows.
CC
Last edited by Chuft-Captain on 20.11.2017, 01:12, edited 1 time in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 18 years 11 months
You're welcome,
In theory, this should have been some pretty standard lua/Celx scripting, but I struggled for a few hours trying to get the script to recognize the LUA file.
I do like a challenge, but this turned out to be more difficult than I expected, and seemingly intractable. Luckily I discovered that this exact issue had been identified (and solved) by Selden and Hank over 10 years ago.
CC
In theory, this should have been some pretty standard lua/Celx scripting, but I struggled for a few hours trying to get the script to recognize the LUA file.
I do like a challenge, but this turned out to be more difficult than I expected, and seemingly intractable. Luckily I discovered that this exact issue had been identified (and solved) by Selden and Hank over 10 years ago.
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS