From ad124da37ca1d2cbae30b9eec338bef534fd09b9 Mon Sep 17 00:00:00 2001 From: Chris Laurel Date: Thu, 1 May 2003 17:43:42 +0000 Subject: [PATCH] Checkin of sample scripts --- scripts/annum.celx | 8 ++++++++ scripts/marktype.celx | 18 ++++++++++++++++++ scripts/randstar.celx | 9 +++++++++ scripts/tour-system.celx | 23 +++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 scripts/annum.celx create mode 100644 scripts/marktype.celx create mode 100644 scripts/randstar.celx create mode 100644 scripts/tour-system.celx diff --git a/scripts/annum.celx b/scripts/annum.celx new file mode 100644 index 000000000..220dedd02 --- /dev/null +++ b/scripts/annum.celx @@ -0,0 +1,8 @@ +jd = celestia:gettime() +last = jd + 365 + +repeat + jd = jd + 1.0 + celestia:settime(jd) + wait(0.05) +until jd >= last \ No newline at end of file diff --git a/scripts/marktype.celx b/scripts/marktype.celx new file mode 100644 index 000000000..eeacd770a --- /dev/null +++ b/scripts/marktype.celx @@ -0,0 +1,18 @@ +function mark_spectraltype(x) + local obs = celestia:getobserver() + local nstars = celestia:getstarcount() + local i = 0 + while i < nstars do + star = celestia:getstar(i) + first, last = string.find(star:spectraltype(), x, 1, true) + if first == 1 then + celestia:mark(star) + end + i = i + 1 + end +end + +spectral = "O" +celestia:flash("Marking all " .. spectral .. " stars.") +mark_spectraltype(spectral) + diff --git a/scripts/randstar.celx b/scripts/randstar.celx new file mode 100644 index 000000000..c5d0970b5 --- /dev/null +++ b/scripts/randstar.celx @@ -0,0 +1,9 @@ +obs = celestia:getobserver() +while 1 do + nstars = celestia:getstarcount() + index = math.floor(nstars * math.random()) + star = celestia:getstar(index) + celestia:select(star) + obs:goto(star, 10) + wait(10) +end diff --git a/scripts/tour-system.celx b/scripts/tour-system.celx new file mode 100644 index 000000000..0f9c47cfa --- /dev/null +++ b/scripts/tour-system.celx @@ -0,0 +1,23 @@ +function goto(o, t) + local obs = celestia:getobserver() + obs:follow(o) + obs:goto(o, t) + while (obs:travelling()) do + wait(0) + end +end + +function visit(o) + local i, v + celestia:select(o) + celestia:flash(o:type() .. " - " .. o:name()) + goto(o, 3) + wait(0.5) + local children = celestia:getchildren(o) + for i, v in ipairs(children) do + visit(v) + end +end + +sol = celestia:find("Sol") +visit(sol)