Page 1 of 1

More CELX newbie incomprehension

Posted: 27.07.2007, 18:40
by rthorvald
Can someone please show me why this simple snippet does not work? I am probably handicapped by my meagre knowledge of other scripting languages, because i am totally unable to see where this breaks down; it _should_ look like this.

Code: Select all

mydate = celestia:gettime()
if (mydate)  > "2454296.5"
celestia:flash(mydate)
else
celestia:flash("2454296.5")
end

... As you can see, this should print the current date to screen if the date is later than july 15th, and print the july 15th date if it is not. But it won??t print anything at all...

Thanks for any input,
- rthorvald

Posted: 27.07.2007, 19:07
by selden
Which version of Celestia are you running on your Mac?

Under XP with Celestia v1.5.0 from cvs, I get a popup message which complains that a "then" is missing.
[edit]
And after that's fixed it complains that you're trying to compare a number with a string: delete all of the quotes.
[/edit]

Posted: 27.07.2007, 19:14
by selden
This works for me:

Code: Select all

mydate = celestia:gettime()

if (mydate  > 2454296.5 )
then
s = string.format(" mydate = %f",mydate)
celestia:print(s,5)
else
celestia:print(" mydate <= 2454296.5",5)
end

Posted: 27.07.2007, 19:55
by rthorvald
Thank you, Selden!
Great help in learning the syntax.

- rthorvald