CEL date today?
CEL date today?
Looking through the available guides, and browsing through a lot of scripts, i cannot seem to find a CEL command to return to the current date / time if i have already visited other dates in the script. I don??t want a spesific time, i want to return to NOW, whenever NOW is.
Anybody know?
Thanks,
- rthorvald
Anybody know?
Thanks,
- rthorvald
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 19 years 1 month
Dunno about CEL, but you can do it in celX..
Save the current time:
.
.
.
then at a later point in the script, reset to the saved time:
Save the current time:
Code: Select all
orig_time = celestia:gettime()
.
.
.
then at a later point in the script, reset to the saved time:
Code: Select all
celestia:settime(orig_time )
"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
Re: CEL date today?
rthorvald wrote:Looking through the available guides, and browsing through a lot of scripts, i cannot seem to find a CEL command to return to the current date / time if i have already visited other dates in the script. I don??t want a spesific time, i want to return to NOW, whenever NOW is.
Anybody know?
Thanks,
- rthorvald
Indeed... Otherwise, often Celestia need to restart.
Never at rest.
Massimo
Massimo
Chuft-Captain wrote:then at a later point in the script, reset to the saved time:Code: Select all
celestia:settime(orig_time)
Don't forget to add the time that has passed since orig_time was saved (what should be done at the very beginning of the script): tnow = t0 + dt
Code: Select all
script_time = celestia:getscripttime()
celestia:settime(orig_time + (script_time/86400))
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
- LordFerret
- Posts: 737
- Joined: 24.08.2006
- Age: 68
- With us: 18 years 5 months
- Location: NJ USA
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 23 years
- Location: Seattle, Washington, USA
The lack of a celx function to get the current system time seems like a significant omission to me, as does the lack of a cel script command to set the simulation time to the current system time. In celx, I think we should add a method called getsystemtime() that returns a Julian date for the current system time.
--Chris
--Chris
The os library is accessible from a Lua Hook context, but not in celx scripting. As an example, I use the following function in the Lua Tools to set the time to the current system time:LordFerret wrote:There's no access to "os.date ([format [, time]])" or "os.time ([table])" ?
Code: Select all
local setCurrentTime = function()
local UTCtime = os.date("!*t");
celestia:settime(celestia:utctotdb(UTCtime.year, UTCtime.month, UTCtime.day, UTCtime.hour, UTCtime.min, UTCtime.sec));
end
chris wrote:The lack of a celx function to get the current system time seems like a significant omission to me, as does the lack of a cel script command to set the simulation time to the current system time. In celx, I think we should add a method called getsystemtime() that returns a Julian date for the current system time.
I'll mind this as soon as possible...
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
LordFerret wrote:There's no access to "os.date ([format [, time]])" or "os.time ([table])" ?
I suspect you'll get access to that library if you add these two lines to the beginning of your Celx script:
celestia:requestsystemaccess()
wait(0)
Also, you may want to change the line in celestia.cfg which says
ScriptSystemAccessPolicy "ask"
to be
ScriptSystemAccessPolicy "allow"
Selden
selden wrote:I suspect you'll get access to that library if you add these two lines to the beginning of your Celx script:
celestia:requestsystemaccess()
wait(0)
Also, you may want to change the line in celestia.cfg which says
ScriptSystemAccessPolicy "ask"
to be
ScriptSystemAccessPolicy "allow"
Selden,
I tried this before posting my answer, but it didn't work...
Looks like the os library is not part of the standard Lua libraries.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
selden wrote:Vincent,
If the os. table can be accessed from the LuaHook environment, and if requestsystemaccess returns true,
then it is a *bug* that the os. table is nil when called from a celx script.
Selden,
You're right ! The following script works with no problem when ScriptSystemAccessPolicy is set to "allow" in celestia.cfg:
Code: Select all
-- Title: Set time to the current system time
celestia:requestsystemaccess()
wait(0)
local setCurrentTime = function()
UTCtime = os.date("!*t");
celestia:settime(celestia:utctotdb(UTCtime.year, UTCtime.month, UTCtime.day, UTCtime.hour, UTCtime.min, UTCtime.sec));
end
setCurrentTime()
I made my first test with ScriptSystemAccessPolicy set to "ask", replying 'yes' to the access request displayed on screen. I thought that this was equivalent to setting ScriptSystemAccessPolicy to "allow", but that didn't work.
Is there a reason for this, or is this a bug ?
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
selden wrote:Vincent,
It's obviously a bug. I'm submitting it to tracker on SF.
Selden,
Actually, this bug doesn't occure with a version of Celestia built against Lua 5.0. It only happens with Celestia built against Lua 5.1. I'll continue this discussion on the Sourceforge tracker...
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
selden wrote:Vincent,
It's obviously a bug. I'm submitting it to tracker on SF.
I've posted a fix on the SourceForge bug tracker.
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
chris wrote:In celx, I think we should add a method called getsystemtime() that returns a Julian date for the current system time.
I've added the new celestia:getsystemtime() celx method to SVN.
This method returns the current system time as a TDB Julian Date.
As an example, one can set Celestia simulation time to the current system time using:
Code: Select all
sysTime = celestia:getsystemtime()
celestia:settime(sysTime)
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
chris wrote:The lack of a celx function to get the current system time seems like a significant omission to me, as does the lack of a cel script command to set the simulation time to the current system time.
I'm not sure about how the cel command to set the simulation time to the current system time should look like...
The 'time' cel command currently accepts either a Julian Date or a UTC calendar Date:
Code: Select all
time { jd 2454531.00075 }
Code: Select all
time { utc "2008-03-05T12:00:0.0000" }
So what about simply using
Code: Select all
time { system }
Code: Select all
time { system "now"}
Other suggestions ?
@+
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
Vincent
Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3