Automatic celx scripts generator

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 3 months
Location: Paris France

Re: Automatic recording of celx scripts

Post #21by jogad » 04.03.2011, 11:06

Hi,
Dave M wrote: I tried just putting speed = 1 dotravel() and it just crashes Celestia everytime.
This is weird and should not happen. Your modification seems very inoffensive.
Please attach the working unmodified and the guilty modified script to your post so I can investigate a bit more and try to see what is wrong.
Tell also what is your current OS. I have tested this script with Windows and I am not aware of possible bugs with linux or Mac. (But with such a simple modification it would be surprising that it generate errors...)

For what is high or low speed it is simple. speed=1 is the normal speed=2 is two time faster etc. You may use decimal values. Low speeds are between 0 and 1. For example speed = 0.33 sets the speed one third of normal speed.
No special signs are needed and the syntax of your example is correct.

The array "flypath" is made of the points of your parth. Each point (with many parameters) is enclosed between {}. The first parameter of each point is a mean duration (in seconds for a global speed=1) of the papth from this point to the following. Notice that this parameter is zero for the last point. Once you have a suitable global speed, you can tweak the time of the partial segments.

Dave M
Posts: 9
Joined: 24.02.2011
With us: 13 years 9 months

Re: Automatic celx scripts generator

Post #22by Dave M » 05.03.2011, 02:08

Thanks for responding. Here is the script I made with the generator, and the script with my speed changes. It wouldn't allow me to attach txt or celx files so I have to just copy it here:

require "scripts/autocelxfunctions" -- ? UTF-8
celestia:print(" ") wait(0.1)
--------------------------------------------------------------------------
-- script initialization --
--------------------------------------------------------------------------
duration = 5 -- default value for goto
speed = 1 -- adjustable speed during script for the functions stepto(), orbitto and dotravel()

goparam={ -- fixed parameters
startInterpolation = 0.25,
endInterpolation = 0.75,
accelTime = 0.5
}
function celestia_cleanup_callback()
restoreoriginalsettings() -- comment out if you prefer.
celestia_cleanup_callback=nil
end

------------------------------------------------------------
-- beginning of recorded script --
------------------------------------------------------------
saveoriginalsettings()
obs=celestia:getobserver()
obs:singleview()

celestia:seturl("cel://Follow/Sol:Earth/2011-06-04T14:13:51.79651?x=yeDmdeR7GA&y=oE+3aCqoYA&z=qNZKc4V9bv///////////w&ow=0.107253&ox=0.117052&oy=-0.948026&oz=-0.275757&select=Sol:Earth&fov=20.4721&ts=0&ltd=0&p=0&rf=1922947&lm=0&tsrc=0&ver=3") wait(0) wait(0.1)

--[[ goto version of the above url
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:follow(earth)
celestia:settime(2455717.0929606)
celestia:settimescale(0)
jumpto("yeDmdeR7GA", "oE+3aCqoYA", "qNZKc4V9bv///////////w", 0.107253, 0.117052, -0.948026, -0.275757)
wait(duration)
fov_change(20.4721/deg)
]]

earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:follow(earth)
flypath = {
{1.29,0.00037132419012983,0.00049532859641527,-0.00041473056239629,-0.00014049953951961,-0.00018741962295205,0.00015692339629421,-0.68083877607237,0.69750701150239,0.22347825375478},
{0.331,0.00037894625599428,0.00051017772857049,-0.00042408610340597,0.00037420107932995,0.00050378926737322,-0.000418775684185,-0.68284034567672,0.69482399002169,0.22571815435723},
{1.328,0.00038760488246614,0.0005294543163138,-0.00043475793737022,0.00038631864543499,0.00052769736283167,-0.00043331522654813,-0.68602797364541,0.69050360209682,0.22928234748292},
{1.302,0.00039925045730275,0.00055489443092394,-0.00044933387900347,0.00039155195432818,0.00054419474016867,-0.00044066964796551,-0.68976291678518,0.68535584871705,0.23348335970114},
{1.36,0.00041089736233113,0.00058911441377932,-0.00046406144744552,0.00040151955319501,0.0005756692008424,-0.0004534702875099,-0.69654878413553,0.67577738395656,0.24113216013657},
{1.244,0.00042570635623799,0.0006349735744358,-0.00048299823612965,0.00041351848220161,0.00061679442858032,-0.00046917010888776,-0.70501575589604,0.66338876645296,0.25073517599722},
{1.454,0.00040753133537276,0.00068811822963178,-0.00048582895075822,0.000395285102371,0.0006674404180345,-0.00047122989048095,-0.72799884145932,0.62697021765375,0.27735542722128},
{1.314,0.00038221465922174,0.0007027778184262,-0.00055605580526042,0.00036729174976197,0.00067533907555835,-0.0005343455693072,-0.73154381217651,0.6208301192935,0.28180421189948},
{1.117,0.00036976262595174,0.00069849563708276,-0.00063239656160726,0.00035561283550214,0.00067176614577941,-0.00060819649864861,-0.70513774939829,0.64329805367826,0.29824213067118},
{1.102,0.00037772176227898,0.00074116974756592,-0.00069482328128276,0.0003644727407031,0.00071517237342036,-0.00067045156229682,-0.57566323813906,0.69588806090759,0.42936190206111},
{1.461,0.00039332312642239,0.00077736254138862,-0.00077620761054644,0.00037808254726885,0.00074724111056711,-0.00074613093126313,-0.57020896395183,0.70671448695112,0.41882737656747},
{1.44,0.00036689767708807,0.00083813233181746,-0.00091205417200485,0.00034543431346974,0.00078910193418492,-0.00085869937704205,-0.45749059459858,0.7387865618593,0.49487045968612},
{1.428,0.00034429673676797,0.00090409936654126,-0.0010859826360374,0.00032211707235709,0.00084585710513556,-0.0010160234181562,-0.40702641839614,0.76128993918397,0.50474461188295},
{1.37,0.00030959641533811,0.00098856591127317,-0.0013025367263927,0.00028773626284999,0.00091876471043759,-0.0012105665030643,-0.35535295889587,0.78331657620525,0.51003864171849},
{1.427,0.00030451848676395,0.0010809355258166,-0.0015727725769129,0.0002820145754204,0.0010010544075975,-0.0014565447084162,-0.34954904275086,0.80236154322548,0.4837679409229},
{1.329,0.00037682296377064,0.0011252258465771,-0.0019426783301033,0.00034541321519117,0.0010314336302471,-0.0017807480769448,-0.33744445876276,0.84148336851318,0.42194428277442},
{2.1,0.00038163116182746,0.0012810400599135,-0.0023622387106699,0.00035016473884476,0.0011754151728105,-0.0021674663495763,-0.28549396614672,0.86104700039956,0.4208221220382},
{0, 0.00038163116182746,0.0012810400599135,-0.0023622387106699,0.00038163114696546,0.0012810400100255,-0.0023622386186764,-0.28549396614672,0.86104700039956,0.4208221220382},
}
dotravel()

-- end of script
wait(5)
celestia:print("the script is over",5)
wait(0)



and here is with my speed changes:


require "scripts/autocelxfunctions" -- ? UTF-8
celestia:print(" ") wait(0.1)
--------------------------------------------------------------------------
-- script initialization --
--------------------------------------------------------------------------
duration = 5 -- default value for goto
speed = 1 -- adjustable speed during script for the functions stepto(), orbitto and dotravel()

goparam={ -- fixed parameters
startInterpolation = 0.25,
endInterpolation = 0.75,
accelTime = 0.5
}
function celestia_cleanup_callback()
restoreoriginalsettings() -- comment out if you prefer.
celestia_cleanup_callback=nil
end

------------------------------------------------------------
-- beginning of recorded script --
------------------------------------------------------------
saveoriginalsettings()
obs=celestia:getobserver()
obs:singleview()

celestia:seturl("cel://Follow/Sol:Earth/2011-06-04T14:13:51.79651?x=yeDmdeR7GA&y=oE+3aCqoYA&z=qNZKc4V9bv///////////w&ow=0.107253&ox=0.117052&oy=-0.948026&oz=-0.275757&select=Sol:Earth&fov=20.4721&ts=0&ltd=0&p=0&rf=1922947&lm=0&tsrc=0&ver=3") wait(0) wait(0.1)

--[[ goto version of the above url
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:follow(earth)
celestia:settime(2455717.0929606)
celestia:settimescale(0)
jumpto("yeDmdeR7GA", "oE+3aCqoYA", "qNZKc4V9bv///////////w", 0.107253, 0.117052, -0.948026, -0.275757)
wait(duration)
fov_change(20.4721/deg)
]]

earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:follow(earth)
flypath = {
{1.29,0.00037132419012983,0.00049532859641527,-0.00041473056239629,-0.00014049953951961,-0.00018741962295205,0.00015692339629421,-0.68083877607237,0.69750701150239,0.22347825375478},
{0.331,0.00037894625599428,0.00051017772857049,-0.00042408610340597,0.00037420107932995,0.00050378926737322,-0.000418775684185,-0.68284034567672,0.69482399002169,0.22571815435723},
{1.328,0.00038760488246614,0.0005294543163138,-0.00043475793737022,0.00038631864543499,0.00052769736283167,-0.00043331522654813,-0.68602797364541,0.69050360209682,0.22928234748292},
{1.302,0.00039925045730275,0.00055489443092394,-0.00044933387900347,0.00039155195432818,0.00054419474016867,-0.00044066964796551,-0.68976291678518,0.68535584871705,0.23348335970114},
{1.36,0.00041089736233113,0.00058911441377932,-0.00046406144744552,0.00040151955319501,0.0005756692008424,-0.0004534702875099,-0.69654878413553,0.67577738395656,0.24113216013657},
{1.244,0.00042570635623799,0.0006349735744358,-0.00048299823612965,0.00041351848220161,0.00061679442858032,-0.00046917010888776,-0.70501575589604,0.66338876645296,0.25073517599722},
{1.454,0.00040753133537276,0.00068811822963178,-0.00048582895075822,0.000395285102371,0.0006674404180345,-0.00047122989048095,-0.72799884145932,0.62697021765375,0.27735542722128},
{1.314,0.00038221465922174,0.0007027778184262,-0.00055605580526042,0.00036729174976197,0.00067533907555835,-0.0005343455693072,-0.73154381217651,0.6208301192935,0.28180421189948},
{1.117,0.00036976262595174,0.00069849563708276,-0.00063239656160726,0.00035561283550214,0.00067176614577941,-0.00060819649864861,-0.70513774939829,0.64329805367826,0.29824213067118},
{1.102,0.00037772176227898,0.00074116974756592,-0.00069482328128276,0.0003644727407031,0.00071517237342036,-0.00067045156229682,-0.57566323813906,0.69588806090759,0.42936190206111},
{1.461,0.00039332312642239,0.00077736254138862,-0.00077620761054644,0.00037808254726885,0.00074724111056711,-0.00074613093126313,-0.57020896395183,0.70671448695112,0.41882737656747},
{1.44,0.00036689767708807,0.00083813233181746,-0.00091205417200485,0.00034543431346974,0.00078910193418492,-0.00085869937704205,-0.45749059459858,0.7387865618593,0.49487045968612},
{1.428,0.00034429673676797,0.00090409936654126,-0.0010859826360374,0.00032211707235709,0.00084585710513556,-0.0010160234181562,-0.40702641839614,0.76128993918397,0.50474461188295},
{1.37,0.00030959641533811,0.00098856591127317,-0.0013025367263927,0.00028773626284999,0.00091876471043759,-0.0012105665030643,-0.35535295889587,0.78331657620525,0.51003864171849},
{1.427,0.00030451848676395,0.0010809355258166,-0.0015727725769129,0.0002820145754204,0.0010010544075975,-0.0014565447084162,-0.34954904275086,0.80236154322548,0.4837679409229},
{1.329,0.00037682296377064,0.0011252258465771,-0.0019426783301033,0.00034541321519117,0.0010314336302471,-0.0017807480769448,-0.33744445876276,0.84148336851318,0.42194428277442},
{2.1,0.00038163116182746,0.0012810400599135,-0.0023622387106699,0.00035016473884476,0.0011754151728105,-0.0021674663495763,-0.28549396614672,0.86104700039956,0.4208221220382},
{0, 0.00038163116182746,0.0012810400599135,-0.0023622387106699,0.00038163114696546,0.0012810400100255,-0.0023622386186764,-0.28549396614672,0.86104700039956,0.4208221220382},
}
speed = 0.33 dotravel()

-- end of script
wait(5)
celestia:print("the script is over",5)
wait(0)



I am using Windows XP. I have tried it on 3 different PCs though and it does the same thing every time. I've attached a screenshot of the error message I get.

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Automatic celx scripts generator

Post #23by Fenerit » 05.03.2011, 03:22

Your script works perfectly on my system. Both the 2 parts, the first more fast and the second more slow, are correctly executed. If the script is loaded newly several times, it works fine too.
Never at rest.
Massimo

Dave M
Posts: 9
Joined: 24.02.2011
With us: 13 years 9 months

Re: Automatic celx scripts generator

Post #24by Dave M » 05.03.2011, 03:59

Wow, what could be wrong for me? Could it be my Windows version?

I have Celestia installed in C:\Celestia, But I might still have an old version of celestia installed in C:\Program Files\Celestia. I wonder if that could cause any problems.

Dave M
Posts: 9
Joined: 24.02.2011
With us: 13 years 9 months

Re: Automatic celx scripts generator

Post #25by Dave M » 05.03.2011, 04:08

Nevermind, I got it to work!

I'm not exactly sure what it was, but instead of just editing the "script.celx" and re-running it in Celestia, I copied and pasted the script into a new txt file, renamed it and put celx as the extension, then opened it up in Celestia and it ran perfectly! Kind of a weird that I have to do that but as long as it works I'm happy. Thanks for your help guys.

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Automatic celx scripts generator

Post #26by Fenerit » 05.03.2011, 04:12

Then, was the UTF-8 encoding.
Never at rest.
Massimo

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 3 months
Location: Paris France

Re: Automatic celx scripts generator

Post #27by jogad » 05.03.2011, 07:34

Dave M wrote:Nevermind, I got it to work!
I'm not exactly sure what it was,...
Good! :idea: I think I know what you did...

Most likely you have edited she script with a word processor instead of a text editor.
A world processor can add extra formating to a text that is not recognised then as a valid script.
It can also modify the original text, correcting supposed mistakes. (spelling, typography etc..)

The error message that you get shows that the first quote (") of the first line has been replaced with "»"
This is a typical expression of the "good will" of the word processors. :wink:

A text editor deals with pure text and don't try to "enhance" it.

There are several ways to encode the caracters of a text.
In Celestia the local and diacritic characters are handed with the UTF-8 encoding. So choose a text that support that.
If you have the wrong encoding (e.g ANSI instead of UTF-8) some charact?re will be replace when displayed. But the problem is limited to a wrong display and don't cause a script error.

Never use a word processor for Celestia

Dave M
Posts: 9
Joined: 24.02.2011
With us: 13 years 9 months

Re: Automatic celx scripts generator

Post #28by Dave M » 07.03.2011, 04:18

I'm not sure if that's the problem though....because I was using Notepad and not Microsoft Word or something like that

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 3 months
Location: Paris France

Re: Automatic celx scripts generator

Post #29by jogad » 07.03.2011, 06:19

Still a mystery! That's why I asked you a copy of the file itself and not just its text.
But it's not so important. You must now be able to modify the file as you want without problem.
And anyways that works!

Regards

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Automatic celx scripts generator

Post #30by Fenerit » 07.03.2011, 15:32

Dave M wrote:I'm not sure if that's the problem though....because I was using Notepad and not Microsoft Word or something like that

Maybe is as follows. When you were using Notepad for your speed's modification, I suppose you have edited the file got by the script recorder that had the UTF-8 encoding. Do you have saved yet the new with the UTF-8 encoding or just as ANSI? Since the UTF-8 is a formatting specification, the "?" character is encoded onto such a format; while, when you simply accomplish the "copy/paste" onto a new file ANSI formatted, the "?" is just that of its character's chart.
Never at rest.
Massimo

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 8 months
Location: Thyrrenian sea

Re: Automatic celx scripts generator

Post #31by Fenerit » 07.03.2011, 16:04

The Notepad neither can "feel" whether a file is UTF-8 encoded, nor saving in such a format. You need Wordpad (choose UTF-8 from the combobox in save dialog). Notepad just does copy the text "as it is". Unfortunately, when you make modification on a UTF-8 encoded file, its savings onto itself (in not UTF-8) causes conflicts. You are fortunate, because whether in the file there would have been a character not recognized from the ANSI (ASCII) chart, neither the copy/paste operation would have good end. Best should be that you were using either Notepad2 or Notepad++, which automatically reckons the format in which are the files and does save it as conseguence.
Never at rest.
Massimo

Egroj
Posts: 1
Joined: 28.11.2018
With us: 6 years

Post #32by Egroj » 28.11.2018, 22:52

Hi!
I think that this script must be great. However, I cannot find it neither in this topic, or the motherloade, or anywhere in the internet. Does anyone have it?

By the way, I had not used Celestia since sometime ago, I think that it is a great software and I am happy to see that there are still people writing in these forums.


Return to “Scripting”