跳轉到內容

Celestia/Celx 指令碼/CELX Lua 方法/Celx celestia

來自 Wikibooks,開放世界開放書籍

Celx 指令碼:Celestia 物件

[編輯 | 編輯原始碼]

此物件是預定義的,並提供了對 Lua 指令碼可用的所有與 Celestia 相關的功能的訪問,無論是透過 celestia 的方法直接訪問,還是透過建立提供更多功能的其他物件間接訪問。

本章包含所有可用的 celestia 方法列表,這些方法可用於預定義的 celestia 物件。

celestia:print(string:text [, number:duration, number:horig, number:vorig, number:hoffset, number:voffset])

在螢幕上列印文字。Celestia 支援 UTF-8 編碼的文字字串以顯示非 ASCII 字元。

引數

text
包含要列印的訊息的字串。
該字串可以包含換行符 "\n" 來換行,或者許多用 UTF-8 編碼的特殊字元。
也可以在同一個 print 命令中使用變數和文字字串。
這可以透過如下方式連線文字字串和變數來完成
  • "String1 " .. variable1 .. "String2 " .. variable2
對於更有經驗的 CELX 編寫者,也可以對文字使用 Lua 字串函式,
例如合併和格式化文字和變數(參見 Lua 參考手冊)。
duration [可選]
文字顯示的秒數。預設值為 5。
負的 duration 值被認為是 1.5 秒。
horig [可選]
文字的水平原點,-1 為左,0 為中,1 為右
vorig [可選]
文字的垂直原點,-1 為底部,0 為中,1 為頂部
hoffset [可選]
相對於原點的水平偏移。
voffset [可選]
相對於原點的垂直偏移。

註釋

  1. 預設情況下,文字以白色列印。
    Celestia 也可以在使用此方法之前使用 1.6.1 celestia:settextcolor() 方法設定文字顏色。

示例-1
在螢幕上定位文字

celestia:print("Middle", 3.0, 0, 0, -3, 0) 
wait(3.0)
celestia:print("Bottom left", 3.0, -1, -1, 2, 4) 
wait(3.0)
celestia:print("Top right", 3.0, 1, 1, -10, -4) 
wait(3.0)

示例-2
列印多行文字並使用文字和變數

rearth = celestia:find("Sol/Earth"):radius()
rmars = celestia:find("Sol/Mars"):radius()
celestia:print("Earth radius is: " .. rearth .. " km.\nMars radius is: " .. rmars .. " km.", 5.0, -1, -1, 2, 4)
wait(5.0)

示例-3
列印文字和格式化的變數

rearth = celestia:find("Sol/Earth"):radius()
celestia:print(string.format("The radius of Earth is: %10.0f km.", rearth ), 5.0, -1, -1, 2, 4)
wait(5.0)

注意:celestia: print 方法的持續時間包含在隨後的 wait 方法的持續時間內。兩者不會疊加。wait() 的持續時間必須至少等於 print() 方法的持續時間。


返回 celestia 方法索引。


celestia:flash(string:text [, number:duration])

在螢幕上列印文字,類似於 print。

引數

text
包含要列印的訊息的字串。該字串可以包含換行符 "\n" 來換行,或者許多用 UTF-8 編碼的特殊字元。
duration [可選]
文字顯示的秒數。預設值為 5。
負的 duration 值被認為是 1.5 秒。

示例

celestia:flash("This string is flashed on your screen for 10 seconds.", 10.0)
wait(10.0)


返回 celestia 方法索引。


celestia:show(string:renderflag)

啟用一個或多個渲染功能。此方法為了與舊指令碼的向後相容性而存在。

應該使用 celestia:setrenderflags() 方法來代替。

引數

renderflag
描述要啟用的渲染功能的字串。必須是以下之一:
  • orbits
  • cloudmaps
  • constellations
  • galaxies
  • planets
  • stars
  • nightmaps
  • eclipseshadows
  • ringshadows
  • comettails
  • boundaries
  • markers
  • automag
  • atmospheres
  • grid
  • smoothlines
  • lightdelay
  • partialtrajectories
  • 1.5.0 cloudshadows
  • 1.5.0 nebulae
  • 1.5.0 openclusters
  • 1.6.0 globulars
  • 1.6.0 ecliptic
  • 1.6.0 equatorialgrid
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid

註釋

  1. 可以透過向此方法傳遞多個引數(用逗號分隔)來一次啟用多個功能。

示例
啟用彗星尾的渲染

celestia:show("comettails")


返回 celestia 方法索引。


celestia:hide(string:renderflag)

停用一個或多個渲染功能。此方法為了與舊指令碼的向後相容性而存在。

應該使用 celestia:setrenderflags() 方法來代替。

引數

renderflag
描述要停用的渲染功能的字串。

註釋

  1. 可以透過向此方法傳遞多個引數(用逗號分隔)來一次啟用多個功能。

示例
停用夜地圖的渲染

celestia:hide("nightmaps")


返回 celestia 方法索引。


getrenderflags

[編輯 | 編輯原始碼]

table celestia:getrenderflags()

返回一個包含所有已知渲染標誌(參見 celestia:setrenderflags() 方法)作為鍵的表,以及一個布林值,指示特定渲染標誌是啟用還是停用。

註釋

  1. 此方法特別有用,可以在指令碼開始時儲存所有渲染標誌,以便在指令碼結束或指令碼終止時,使用函式 celestia_cleanup_callback() 重置這些值。

示例

actual_renderflags = celestia:getrenderflags()


返回 celestia 方法索引。


setrenderflags

[編輯 | 編輯原始碼]

celestia:setrenderflags(table:renderflags)

可以使用 celestia:showcelestia:hide 或此 celestia:setrenderflags() 方法,兩者具有等效的功能。

此方法存在的主要原因是作為 celestia:getrenderflags() 方法的對應方法。

引數

renderflags
一個包含渲染標誌作為鍵,以及每個鍵的布林值作為值的表。有效的渲染標誌鍵是
  • orbits
  • cloudmaps
  • constellations
  • galaxies
  • planets
  • stars
  • nightmaps
  • eclipseshadows
  • ringshadows
  • comettails
  • boundaries
  • markers
  • automag
  • atmospheres
  • grid
  • smoothlines
  • lightdelay
  • partialtrajectories
  • 1.5.0 cloudshadows
  • 1.5.0 nebulae
  • 1.5.0 openclusters
  • 1.6.0 globulars
  • 1.6.0 ecliptic
  • 1.6.0 equatorialgrid
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid

示例
啟用彗星尾的渲染並停用夜地圖的渲染

-- create and initialize table
t = {}
t.nightmaps = false
t.comettails = true
celestia:setrenderflags(t)

或更短

-- note the curly braces
celestia:setrenderflags{nightmaps = false, comettails = true}


返回 celestia 方法索引。


showlabel

[編輯 | 編輯原始碼]

1.3.2 celestia:showlabel(string:labelflag)

啟用標籤的渲染。

引數

labelflag
描述要啟用的標籤型別的字串,必須是以下之一:
  • planets
  • moons
  • spacecraft
  • asteroids
  • comets
  • stars
  • galaxies
  • locations
  • constellations
  • 1.5.0 i18nconstellations
    • 用於在啟用星座標記時顯示星座的拉丁文或翻譯後的標籤名稱。
  • 1.5.0 openclusters
  • 1.5.0 nebulae
  • 1.6.0 dwarfplanets
  • 1.6.0 minormoons
  • 1.6.0 globulars

註釋

  1. 可以透過向此方法傳遞多個引數(用逗號分隔)來一次啟用多個標籤功能。

示例
啟用行星和衛星的標記

celestia:showlabel("planets", "moons")


返回 celestia 方法索引。


hidelabel

[編輯 | 編輯原始碼]

1.3.2 celestia:hidelabel(string:labelflag)

停用標籤的渲染。

引數

labelflag
描述要停用的標籤型別的字串。

註釋

  1. 可以透過向此方法傳遞多個引數(用逗號分隔)來一次停用多個標籤功能。

示例
分別啟用星座的本地和拉丁文名稱的標記

 celestia:showlabel("constellations")
 -- Show local translated names for constellations
 celestia:showlabel("i18nconstellations")
 wait(5.0)
 -- Show Latin names for constellations
 celestia:hidelabel("i18nconstellations")
 wait(5.0)
 celestia:hidelabel("constellations")


返回 celestia 方法索引。


getlabelflags

[編輯 | 編輯原始碼]

1.3.2 table celestia:getlabelflags()

返回一個包含所有已知標籤標誌(參見 celestia:setlabelflags() 方法)作為鍵的表,以及一個布林值,指示特定標籤標誌是啟用還是停用。

註釋

  1. 此方法特別有用,可以在指令碼開始時儲存所有標籤標誌,以便在指令碼結束或指令碼終止時,使用函式 celestia_cleanup_callback() 重置這些值。
  2. 要啟用或停用特定標籤標誌,可以使用 celestia:setlabelflags() 方法。

示例

actual_labelflags = celestia:getlabelflags()


返回 celestia 方法索引。


setlabelflags

[編輯 | 編輯原始碼]

1.3.2 celestia:setlabelflags(table:labelflags)

啟用或停用標籤的渲染。

可以使用 celestia:showlabel()celestia:hidelabel() 或此 celestia:setlabelflags() 方法,兩者具有等效的功能。

引數

labelflags
一個包含標籤標誌作為鍵,以及每個鍵的布林值作為值的表。有效的標籤標誌鍵是
  • planets
  • moons
  • spacecraft
  • asteroids
  • comets
  • stars
  • galaxies
  • locations
  • constellations
  • 1.5.0 i18nconstellations
    • 用於在啟用星座標記時顯示星座的拉丁文或翻譯後的標籤名稱。
  • 1.5.0 openclusters
  • 1.5.0 nebulae
  • 1.6.0 dwarfplanets
  • 1.6.0 minormoons
  • 1.6.0 globulars

註釋

  1. 要獲取標籤渲染的當前狀態,可以使用 celestia:getlabelflags() 方法。

示例
啟用行星和矮行星的標記,並停用衛星的標記

-- create and initialize table
table = {}
table.planets = true
table.dwarfplanets = true
table.moons = false
celestia:setlabelflags(table)

或更短

-- note the curly braces
celestia:setlabelflags{planets = true, dwarfplanets = true, moons = false}


返回 celestia 方法索引。


getorbitflags

[編輯 | 編輯原始碼]

1.3.2 table celestia:getorbitflags()

返回一個包含所有已知軌道標誌(參見 celestia:setorbitflags() 方法)作為鍵的表,以及一個布林值,指示
當使用 celestia:setrenderflags() 方法啟用軌道時,特定軌道是啟用還是停用。

註釋

  1. 要啟用或停用特定軌道的渲染,可以使用 celestia:setorbitflags() 方法。

示例

actual_orbitflags = celestia:getorbitflags()


返回 celestia 方法索引。


setorbitflags

[編輯 | 編輯原始碼]

1.3.2 celestia:setorbitflags(table:orbitflags)

啟用或停用特定軌道的渲染,當使用 celestia:setrenderflags() 方法啟用軌道時。

引數

orbitflags
一個包含軌道標誌作為鍵,以及每個鍵的布林值作為值的表。
每個軌道標誌必須是以下之一:
  • Planet
  • Moon
  • Asteroid
  • Comet
  • Spacecraft
  • Invisible
  • Unknown
  • 1.6.0 DwarfPlanet
  • 1.6.0 MinorMoon
  • 1.6.0 Star
注意:注意 celestia 對此 celestia 方法的鍵的區分大小寫 !!!

註釋

  1. 要獲取特定軌道渲染的當前狀態,可以使用 celestia:getorbitflags() 方法。

示例
僅啟用行星和矮行星軌道的渲染

-- create and initialize table first
table = {}
table.Planet = true
table.Moon = false
table.Asteroid = false
table.Comet = false
table.Spacecraft = false
table.Invisible = false
table.Unknown = false
table.DwarfPlanet = true
table.MinorMoon = false
table.Star = false
celestia:setorbitflags(table)
celestia:setrenderflags{orbits = true}

或更短

-- note the curly braces
celestia:setorbitflags{Planet = true, Moon = false, Asteroid = false, Comet = false, Spacecraft = false,
                       Invisible = false, Unknown = false, DwarfPlanet = true, MinorMoon = false, Star = false}
celestia:setrenderflags{orbits = true}


返回 celestia 方法索引。


getambient

[編輯 | 編輯原始碼]

1.3.2 number celestia:getambient()

返回環境光的當前亮度級別,表示為數字。

註釋

  1. 要設定環境光的亮度級別,可以使用 celestia:setambient() 方法。

示例

actual_ambient = celestia:getambient()


返回 celestia 方法索引。


setambient

[編輯 | 編輯原始碼]

1.3.2 celestia:setambient(number:ambient)

設定環境光的亮度級別。

引數

ambient
環境光的新級別,必須在 0 到 1 之間,否則將調整為最接近的有效值 (0 或 1)。
  • 為了真實感,此數字應設定為 0.0。遠離太陽的一側將完全黑暗。
  • 將此數字設定為 1.0 將導致遠離太陽的一側看起來與照亮的一側一樣亮。

註釋

  1. 要獲取環境光的當前亮度級別,可以使用 celestia:getambient() 方法。

示例

celestia:setambient(0.0)


返回 celestia 方法索引。


getfaintestvisible

[編輯 | 編輯原始碼]

1.3.2 number celestia:getfaintestvisible()

返回當前可見的最暗恆星的星等值。

如果啟用了 AutoMag(請參閱 celestia:setrenderflags() 方法),則此方法將返回 45° 時可見的最暗恆星的星等值。

註釋

  1. 要設定可見的最暗恆星的星等值或 45° 時可見的最暗恆星的星等值,可以使用 celestia:setfaintestvisible() 方法。

示例

actual_faintest = celestia:getfaintestvisible()


返回 celestia 方法索引。


setfaintestvisible

[edit | edit source]

1.3.2 celestia:setfaintestvisible(number:faintest)

設定可見的最暗恆星的星等值。

如果啟用了 AutoMag(請參閱 celestia:setrenderflags() 方法),則設定 45° 時可見的最暗恆星的星等值。

引數

faintest
新的可見的最暗恆星的星等值。
Celestia 使用者介面允許的範圍約為 1.0 到 15.0。

註釋

  1. 當使用 celestia:setrenderflags() 方法開啟星系時,星系的亮度也會響應使用此 celestia:setfaintestvisible() 方法設定的可見的最暗恆星的星等值。此方法與 1.5.0 celestia:setgalaxylightgain() 方法相關聯。
  2. 要獲取當前可見的最暗恆星的星等值或當前 45° 時可見的最暗恆星的星等值,可以使用 celestia:getfaintestvisible() 方法。

示例-1
將 45° 時可見的最暗恆星的星等值設定為 9.0

celestia:setrenderflags{automag = true}
celestia:setfaintestvisible(9.0)

示例-2
將可見的最暗恆星的星等值設定為 7.0

celestia:setrenderflags{automag = false}
celestia:setfaintestvisible(7.0)


返回 celestia 方法索引。


getminorbitsize

[edit | edit source]

1.3.2 number celestia:getminorbitsize()

返回當前軌道渲染的最小尺寸,以數字表示。

此值在 Celestia 的 orbits renderflag 選項開啟時使用,使用 celestia:setrenderflags() 方法。
尺寸以畫素為單位測量,與軌道的半徑相關。

註釋

  1. 可以使用 celestia:getscreendimension() 方法獲取實際螢幕尺寸(以畫素為單位)。
  2. 要設定軌道渲染的最小尺寸,可以使用 celestia:setminorbitsize() 方法。

示例

actual_orbitsize = celestia:getminorbitsize()


返回 celestia 方法索引。


setminorbitsize

[edit | edit source]

1.3.2 celestia:setminorbitsize(number:orbitsize)

設定軌道渲染的最小尺寸。

此值在 Celestia 的 orbits renderflag 選項開啟時使用,使用 celestia:setrenderflags() 方法。

引數

orbitsize
軌道渲染的最小尺寸。
負的 orbitsize 值將被視為零。
尺寸以畫素為單位測量,與軌道的半徑相關。
  • 注意:當尺寸大於螢幕尺寸的 50% 時,將完全不渲染軌道。

註釋

  1. 使用此方法,例如,您可以在從太陽系縮小時影響行星內部軌道的淡出時機(反之亦然,在放大太陽系時淡入)。
  2. 不同計算機上的螢幕尺寸可能不同,因此此方法的效果也會有所不同。
  3. 要獲取當前軌道渲染的最小尺寸,可以使用 celestia:getminorbitsize() 方法。

示例
將軌道渲染的最小半徑尺寸設定為 30 畫素,並渲染行星的軌道

celestia:setrenderflags{orbits = true}
celestia:setorbitflags{Planet = true}
celestia:setminorbitsize(30)


返回 celestia 方法索引。


getstardistancelimit

[edit | edit source]

1.3.2 number celestia:getstardistancelimit()

返回 Celestia 將顯示恆星的最遠距離,以光年為單位,以數字表示。

預設值為 1,000,000,但是,從 1.3.1 版本開始,Celestia 僅使用最多 16,000 光年的距離。

註釋

  1. 要設定 Celestia 將顯示恆星的最遠距離,可以使用 celestia:setstardistancelimit() 方法。

示例

actual_stardistancelimit = celestia:getstardistancelimit()


返回 celestia 方法索引。


setstardistancelimit

[edit | edit source]

1.3.2 celestia:setstardistancelimit(number:distance)

設定 Celestia 將顯示恆星的最遠距離。

引數

distance
Celestia 將顯示恆星的最大恆星距離(以光年為單位)。

註釋

  1. 要獲取當前 Celestia 將顯示恆星的最遠距離,可以使用 celestia:getstardistancelimit() 方法。

示例
僅顯示距離小於 100 光年的恆星

celestia:setstardistancelimit(100)


返回 celestia 方法索引。


getminfeaturesize

[edit | edit source]

1.3.2 number celestia:getminfeaturesize()

返回位置標註的最小尺寸。

此值在 Celestia 的 locations labelflag 選項開啟時使用,使用 celestia:setlabelflags()celestia:showlabel() 方法。

註釋

  1. 當從遠處觀察一顆行星或衛星時,從一定距離開始,將首先顯示最大或最重要的位置。隨著您接近行星或衛星,將出現更多位置標籤。
  2. 已定義位置的尺寸是在 Celestia 子目錄中儲存的位置檔案中確定的。尺寸小於位置最小尺寸的已定義位置將不會被標註。
  3. 可以使用 celestia:setminfeaturesize() 方法設定位置標註的最小尺寸。
  4. 可以使用 observer:getlocationflags() 獲取一個包含指示特定 locationflag 是否啟用或停用的鍵的表。

示例

actual_minfeaturesize = celestia:getminfeaturesize()


返回 celestia 方法索引。


setminfeaturesize

[edit | edit source]

1.3.2 celestia:setminfeaturesize(number:size)

設定位置標註的最小尺寸。

此值在 Celestia 的 locations labelflag 選項開啟時使用,使用 celestia:setlabelflags()celestia:showlabel() 方法。

引數

size
位置標註的最小特徵尺寸。
負的 size 值將被視為零。
尺寸小於此尺寸的已定義位置將不會被標註。

註釋

  1. 當從遠處觀察一顆行星或衛星時,從一定距離開始,將首先顯示最大或最重要的位置。隨著您接近行星或衛星,將出現更多位置標籤。
  2. 已定義位置的尺寸是在 Celestia 子目錄中儲存的位置檔案中確定的。
  3. 可以使用 celestia:getminfeaturesize() 方法獲取當前位置標註的最小尺寸。
  4. 可以使用 observer:setlocationflags() 確定特定 locationflag 是否啟用或停用。

示例
將最小特徵尺寸設定為 1,以顯示所有可用位置標籤

celestia:setlabelflags{locations = true}
celestia:setminfeaturesize(1)


返回 celestia 方法索引。


getstarstyle

[edit | edit source]

1.3.2 string celestia:getstarstyle()

返回當前恆星的渲染樣式,以字串表示。

字串將是以下之一

  • disc
    Celestia 繪製一個突出的圓形圓盤,其直徑和亮度會根據恆星的實際大小、星等和距離而變化。
  • fuzzy
    Celestia 繪製一個更小、更逼真的“點”,其大小和亮度會發生變化。
  • point
    Celestia 將恆星繪製為不同亮度的光點。

註釋

  1. 可以使用 celestia:setstarstyle() 方法設定恆星的渲染樣式。

示例

actual_starstyle = celestia:getstarstyle()


返回 celestia 方法索引。


setstarstyle

[edit | edit source]

1.3.2 celestia:setstarstyle(string:starstyle)

設定恆星的渲染樣式。

引數

starstyle
恆星的新渲染樣式。
必須是以下之一
  • disc
    Celestia 繪製一個突出的圓形圓盤,其直徑和亮度會根據恆星的實際大小、星等和距離而變化。
  • fuzzy
    Celestia 繪製一個更小、更逼真的“點”,其大小和亮度會發生變化。
  • point
    Celestia 將恆星繪製為不同亮度的光點。

註釋

  1. 可以使用 celestia:getstarstyle() 方法獲取當前恆星的渲染樣式。

示例
未註釋的行設定了 starstyle

-- celestia:setstarstyle("disc")
-- celestia:setstarstyle("fuzzy")
celestia:setstarstyle("point")


返回 celestia 方法索引。


object celestia:find(string:name)

此 celestia 方法可用於建立 CELX“object”物件。

引數

name
描述所需行星、衛星、小行星、彗星、星系、航天器等的字串。
  • 恆星和天體透過其通用名稱或拜耳和弗拉姆斯蒂德命名法以及 HD 或 HIP 目錄編號命名
    (例如,“北極星”、“HIP 21589”、“41 ari”)。
  • 星系透過其通用名稱或透過其梅西耶編號、NGC、UGC 或 MCG 目錄編號命名
    (例如,“M 33”、“銀河系”)。
  • 行星、衛星、小行星和人造衛星可以透過其通用名稱命名
    (例如,“和平號空間站”、“木星”、“木衛一”、“卡西尼”)。
注意:如果您當前位於太陽系之外,並想尋找太陽系內的物體,
您必須在名稱字串中包含“Sol/”(例如,“Sol/火星”)。
注意:如果您正在尋找行星或衛星上命名的位置,您必須包含該位置所在的行星或衛星的名稱,
以及位置本身,用斜槓 / 分隔(例如,“地球/阿姆斯特丹”或“Sol/地球/阿姆斯特丹”)。

註釋

  1. CELX 的 "object" 物件既可以指代像行星或恆星這樣的天體,也可以指代位置或航天器。
  2. CELX 的 "object" 物件可以使用object 方法。 "Object" 物件也可以用在其他方法中,這些方法需要一個 "object" 物件作為引數。

示例

-- Find Earth and store in object with name "planet_earth", when in our Solar System
planet_earth = celestia:find("Earth")
-- Find Earth and store in object with name "planet_earth", when outside of our Solar System
planet_earth = celestia:find("Sol/Earth")
-- Find Galaxy M33 and store in object with name "galaxy_m33"
galaxy_m33 = celestia:find("M 33")
-- Find Jupiter's moon Callisto and store in object with name "callisto"
callisto = celestia:find("Sol/Jupiter/Callisto")


返回 celestia 方法索引。


getselection

[edit | edit source]

object celestia:getselection()

返回當前選擇項,以 CELX 的 "object" 物件形式。

註釋

  1. CELX 的 "object" 物件既可以指代像行星或恆星這樣的天體,也可以指代位置或航天器。
  2. CELX 的 "object" 物件可以使用object 方法。 "Object" 物件也可以用在其他方法中,這些方法需要一個 "object" 物件作為引數。

示例
獲取當前選擇項。如果未選擇任何內容,則會選擇太陽。

actual_selection = celestia:getselection()
if actual_selection:type() == "null" then
   actual_selection = celestia:find("Sol")
   celestia:select(actual_selection)
end


返回 celestia 方法索引。


select

[edit | edit source]

celestia:select(object:obj)

將當前選擇項設定為指定的物件。

引數

obj
將成為新選擇項的物件。
如果物件無效,則會清除選擇項。

示例
查詢並選擇我們的月球

moon = celestia:find("Sol/Earth/Moon")
celestia:select(moon)

或者更簡短

celestia:select(celestia:find("Sol/Earth/Moon"))


返回 celestia 方法索引。


celestia:mark(object:obj)

標記指定的物件。

引數

obj
要標記的物件。

註釋

  1. 您可能希望使用object:mark() 方法,因為它提供了更多可能性。
  2. 標記僅在 Celestia 的 markers 渲染標誌選項啟用時才會顯示,可以透過 celestia:setrenderflags() 方法啟用。

示例
查詢、居中並標記恆星畢宿五

selection = celestia:find("Aldebaran")
celestia:getobserver():center(selection)
celestia:setrenderflags{markers = true}
celestia:mark(selection)


返回 celestia 方法索引。


unmark

[edit | edit source]

celestia:unmark(object:obj)

從指定的物件中移除標記。

引數

obj
要移除其標記的物件。

註釋

  1. 如果您不取消標記物件,並且不使用 celestia:setrenderflags() 方法關閉 markers 渲染標誌,Celestia 仍會記住已標記的物件。下次啟用 markers 渲染標誌時,所有物件都將再次被標記。
  2. 您可能希望使用object:unmark() 方法。

示例
查詢、居中並標記恆星北極星,並使用閃爍標記標記 10 秒鐘

selection = celestia:find("Polaris")
celestia:getobserver():center(selection)
celestia:setrenderflags{markers = true}
for i = 1, 10 do
   celestia:mark(selection)
   wait(0.5)
   celestia:unmark(selection)
   wait(0.5)
end
celestia:setrenderflags{markers = false}


返回 celestia 方法索引。


unmarkall

[edit | edit source]

celestia:unmarkall()

此 celestia 方法會從 所有 物件中移除任何先前分配的標記。

使用此方法可以避免單獨取消標記所有先前標記的物件。

註釋

  1. 如果您不取消標記物件,並且不使用 celestia:setrenderflags() 方法關閉 markers 渲染標誌,Celestia 仍會記住已標記的物件。下次啟用 markers 渲染標誌時,所有物件都將再次被標記。

示例
查詢、居中並標記恆星北河二和北河三,並在 5 秒鐘後再次取消標記它們

pollux = celestia:find("Pollux")
castor = celestia:find("Castor")
celestia:getobserver():center(pollux)
celestia:setrenderflags{markers = true}
celestia:mark(pollux)
celestia:mark(castor)
wait(5)
celestia:unmarkall()
celestia:setrenderflags{markers = false}


返回 celestia 方法索引。


gettime

[edit | edit source]

number celestia:gettime()

獲取當前模擬時間,以 TDB (質心動力學時間) 儒略日形式表示。

較早的 Celestia 版本使用 UTC (協調世界時) 來計算時間和位置。
從版本 1.5.0 開始,雖然 Celestia 仍然在螢幕上顯示 UTC,
但它在內部使用 TDB 時間尺度進行其他所有操作,因此對於 CELX 指令碼來說 !!!

註釋

  1. 可以使用 celestia:settime() 方法設定模擬時間。
  2. 要獲取當前系統時間而不是當前模擬時間,應使用 1.6.0 celestia:getsystemtime() 方法。
  3. TDB 時間尺度與更熟悉的 UTC 稍有不同。使用 TDB 時,Celestia 可以更準確地放置物件。截至 2008 年 1 月 1 日,兩者之間的差異約為 65 秒。有關詳細資訊,請參閱Celestia/Time_Scales
  4. 要將 UTC 時間和 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  5. 要將普通日曆日期和儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例

actual_tdbtime = celestia:gettime()


返回 celestia 方法索引。


settime

[edit | edit source]

celestia:settime(number:time)

將模擬時間設定為 TDB (質心動力學時間) 儒略日。

較早的 Celestia 版本使用 UTC (協調世界時) 來計算時間和位置。
從版本 1.5.0 開始,雖然 Celestia 仍然在螢幕上顯示 UTC,
但它在內部使用 TDB 時間尺度進行其他所有操作,因此對於 CELX 指令碼來說 !!!

引數

time
表示 TDB 儒略日的數字。
版本早於 1.5.0 的 Celestia 版本使用 UTC 儒略日編號。

註釋

  1. 可以使用 celestia:gettime()observer:gettime() 方法獲取當前模擬時間。
  2. TDB 時間尺度與更熟悉的 UTC 稍有不同。使用 TDB 時,Celestia 可以更準確地放置物件。截至 2008 年 1 月 1 日,兩者之間的差異約為 65 秒。有關詳細資訊,請參閱Celestia/Time_Scales
  3. 要將 UTC 時間和 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  4. 要將普通日曆日期和儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例
將日期和時間精確設定為 UTC:2009 年 10 月 6 日 19 時 15 分 30 秒

tdb_dt = celestia:utctotdb(2009, 10, 06, 19, 15, 30)
celestia:settime(tdb_dt)


返回 celestia 方法索引。


gettimescale

[edit | edit source]

number celestia:gettimescale()

獲取當前時間變化的倍數(速度),即多少秒模擬時間等於一秒實際時間,以數字形式表示。

註釋

  1. 可以使用 celestia:settimescale() 方法設定時間變化的倍數(速度)。

示例

actual_timespeed = celestia:gettimescale()


返回 celestia 方法索引。


settimescale

[edit | edit source]

celestia:settimescale(number:timescale)

設定時間變化的倍數(速度),即多少秒模擬時間等於一秒實際時間。

引數

timescale
新的時間速度。
定義時間倍數(例如 100 倍)。
特殊值為
  • 0: 暫停時間
  • 1: 重置為實際時間
  • 負值會使時間倒流

註釋

  1. 可以使用 celestia:gettimescale() 方法獲取當前時間變化的倍數(速度)。

示例
將時間倍數設定為“快 1000 倍”。

celestia:settimescale(1000)


返回 celestia 方法索引。


getscripttime

[edit | edit source]

number celestia:getscripttime()

返回自指令碼啟動以來的經過時間(以秒為單位,包含小數部分),以數字形式表示。

註釋

  1. 此方法可用於計時目的。

示例
在螢幕上列印經過的指令碼時間。

-- Note: The elapsed time in this example increments with a bit more 
--       than 1 second (as defined in the wait(1.0)). This beacause 
--       the CELX methods themselves also take time to process.
for i = 1, 20 do
  actual_scripttime = celestia:getscripttime()
  celestia:print("Elapsed script time: " .. actual_scripttime, 1.0, -1, -1, 2, 4)
  wait(1.0)
end


返回 celestia 方法索引。


getobserver

[edit | edit source]

observer celestia:getobserver()

返回當前活動的觀察者例項,以 CELX 的 "observer" 物件形式表示。

CELX 的 "observer" 物件用於訪問特定於檢視的屬性,例如觀察者位置、觀察者方向、參考系和跟蹤狀態。

CELX 的 "observer" 物件可以使用observer 方法。 "Observer" 物件也可以用在其他方法中,這些方法需要一個 "observer" 物件作為引數。

註釋

  1. 此方法返回 活動 檢視的觀察者,使用者可以在多檢視情況下使用 1.6.0 observer:makeactiveview() 方法更改檢視。

示例
獲取活動檢視的觀察者例項,並存儲在 obs 中。

obs = celestia:getobserver()


返回 celestia 方法索引。


getobservers

[edit | edit source]

1.3.2 table celestia:getobservers()

返回所有已使用的觀察者列表,即在多檢視情況下每個檢視一個觀察者例項,以 CELX 的 "observer" 物件表形式表示。

CELX 的 "observer" 物件用於訪問特定於檢視的屬性,例如觀察者位置、觀察者方向、參考系和跟蹤狀態。

CELX 的 "observer" 物件可以使用observer 方法。 "Observer" 物件也可以用在其他方法中,這些方法需要一個 "observer" 物件作為引數。

註釋

  1. 每次使用 observer:splitview()observer:deleteview() 方法在多檢視中更改觀察者例項數量時,都需要使用此 celestia:getobservers() 方法更新 "observer" 物件表。

示例
將當前檢視垂直分成兩半。左側轉到金星,右側轉到火星,並在 10 秒鐘後恢復單檢視。

obs = celestia:getobserver()
obs:splitview("V", 0.5)
observers = celestia:getobservers()
venus = celestia:find("Sol/Venus")
observers[1]:goto(venus)
mars = celestia:find("Sol/Mars")
observers[2]:goto(mars)
wait(10.0)
obs:singleview()


返回 celestia 方法索引。


tojulianday

[edit | edit source]

number celestia:tojulianday(number:year [, number:month, number:day, number:hour, number:minute, number:seconds])

將 UTC 日曆日期/時間轉換為 UTC 儒略日,並以數字形式返回此儒略日。

UTC 儒略日是自公元前 4712 年 1 月 1 日格林威治時間中午(12:00:00)以來的天數和幾分之一天的間隔。

引數

year
此日期的年份的整數。
月份 [可選]
日期所在年份的月份的整數(1-12)。預設值為 1。
日期 [可選]
日期所在月份的日期的整數(1-31)。預設值為 1。
小時 [可選]
日期所在日期的小時的整數。預設值為 0。
分鐘 [可選]
日期所在小時的分鐘的整數。預設值為 0。
秒鐘 [可選]
日期所在分鐘的秒鐘的浮點數。預設值為 0.0。

註釋

  1. 1.5.0 版本開始,儘管 Celestia 仍然在螢幕上顯示 UTC,但它在內部使用 TDB 時間尺度進行其他所有操作,因此對於 CELX 指令碼而言 !!! 對於這些較新的 Celestia 版本,在 celestia:settime() 方法中使用 UTC 儒略日(作為此 celestia:tojulianday() 方法的結果),會導致模擬時間設定錯誤。若要設定模擬時間,使用這些較新 Celestia 版本的儒略日,應使用 1.5.0 celestia:utctotdb() 方法,而不是此 celestia:tojulianday() 方法。
  2. 有關 TDB、UTC 以及 Celestia 中如何使用時間的更多資訊,請參閱 Celestia/時間尺度

示例-1
使用比 1.5.0 版本更高的 Celestia 版本,此示例-1 將設定錯誤的模擬時間,這可以透過執行此示例-1 指令碼後讀取螢幕右上角的日期時間來檢查。此示例-1 僅適用於早於 1.5.0 版本的 Celestia 版本。

utc_juliandate = celestia:tojulianday(2009, 10, 06, 12, 00, 0.0)
celestia:settime(utc_juliandate)
celestia:settimescale(0)

示例-2
使用比 1.5.0 版本更高的 Celestia 版本,下一個示例-2 將設定正確的模擬時間,這可以透過執行此示例-2 指令碼後讀取螢幕右上角的日期時間來檢查。

tdb_juliandate = celestia:utctotdb(2009, 10, 06, 12, 00, 0.0)
celestia:settime(tdb_juliandate)
celestia:settimescale(0)


返回 celestia 方法索引。


fromjulianday

[edit | edit source]

1.3.2 表格 celestia:fromjulianday(數字:jd)

將 UTC 儒略日轉換為 UTC 日曆日期/時間。返回的表格包含以下鍵

  • year
  • 月份
  • 日期
  • 小時
  • 分鐘
  • 秒鐘

UTC 儒略日是自公元前 4712 年 1 月 1 日格林威治時間中午(12:00:00)以來的天數和幾分之一天的間隔。

引數

jd
UTC 儒略日數字。
特殊值
  • 0 是上述參考日期的日期
  • 負值可用於前一個日期
  • 儒略日數 (JDN) 是儒略日 (JD) 的整數部分。
    • 2010 年 1 月 1 日的儒略日數為 2455198。
  • 儒略日的十進位制部分
    • 0.1 是 2.4 小時或 144 分鐘或 8640 秒
    • 0.01 是 0.24 小時或 14.4 分鐘或 864 秒
    • 0.001 是 0.024 小時或 1.44 分鐘或 86.4 秒
    • 0.0001 是 0.0024 小時或 0.144 分鐘或 8.64 秒
    • 0.00001 是 0.00024 小時或 0.0144 分鐘或 0.864 秒。

註釋

  1. 1.5.0 版本開始,儘管 Celestia 仍然在螢幕上顯示 UTC,但它在內部使用 TDB 時間尺度進行其他所有操作,因此對於 CELX 指令碼而言 !!! 對於這些較新的 Celestia 版本,使用 celestia:gettime() 方法獲取儒略日,並使用此 celestia:fromjulianday() 方法將其轉換為日曆日期/時間,會導致獲取錯誤的日曆日期/時間。若要獲取正確的日曆日期/時間,使用這些較新 Celestia 版本的 celestia:gettime() 方法中的儒略日,應使用 1.5.0 celestia:tdbtoutc() 方法。
  2. 有關 TDB、UTC 以及 Celestia 中如何使用時間的更多資訊,請參閱 Celestia/時間尺度

示例-1
使用比 1.5.0 版本更高的 Celestia 版本,此示例-1 將獲取錯誤的 TDB 日曆日期/時間,而不是提到的 UTC 日曆日期/時間。這可以透過將列印語句的結果與螢幕右上角顯示的 UTC 日期/時間進行比較來檢查。此示例-1 僅適用於早於 1.5.0 版本的 Celestia 版本。

celestia:settimescale(0)
utc_juliandate = celestia:gettime()
ut = celestia:fromjulianday(utc_juliandate)
celestia:print("Date/time: " .. ut.year .. " " .. ut.month .. " " .. ut.day .. " "
                .. ut.hour .. " " .. ut.minute .. " " .. ut.seconds, 10.0, -1, -1, 2, 4) 
wait(10.0)

示例-2
使用比 1.5.0 版本更高的 Celestia 版本,下一個示例-2 將設定正確的 UTC 日曆日期/時間。這可以透過將列印語句的結果與螢幕右上角顯示的 UTC 日期/時間進行比較來檢查。

celestia:settimescale(0)
tdb_juliandate = celestia:gettime()
ut = celestia:tdbtoutc(tdb_juliandate)
celestia:print("Date/time: " .. ut.year .. " " .. ut.month .. " " .. ut.day .. " "
                .. ut.hour .. " " .. ut.minute .. " " .. ut.seconds, 10.0, -1, -1, 2, 4) 
wait(10.0)


返回 celestia 方法索引。


getscreendimension

[edit | edit source]

1.3.2 x,y celestia:getscreendimension()

以畫素為單位返回當前 Celestia 視窗的寬度 (=x) 和高度 (=y),作為 2 個數字。

示例

x,y = celestia:getscreendimension()
celestia:print("Width: " .. x .. " pixels.\nHeight: " .. y .. " pixels.", 10.0, -1, -1, 4, 4)
wait (10.0)


返回 celestia 方法索引。


newvector

[edit | edit source]

向量 celestia:newvector(數字:x,數字:y,數字:z)

此 celestia 方法可用於從數字建立新的 CELX “向量”物件。

引數

x
新向量的 X 分量,以光年的百萬分之一表示。
y
新向量的 Y 分量,以光年的百萬分之一表示。
z
新向量的 Z 分量,以光年的百萬分之一表示。

註釋

  1. 如果向量分量以公里或英里定義,則必須先將這些分量轉換為光年的百萬分之一。
    因此,可以使用一個常量,該常量必須先在指令碼中初始化
    • 從公里到光年的百萬分之一,使用常量 uly_to_km = 9460730.4725808。
    • 從英里到光年的百萬分之一,使用常量 uly_to_mls = 5912956.5453630。
  2. 接下來,可以將公里或英里轉換為光年的百萬分之一,如下所示
    • 光年的百萬分之一 = 數字:公里 / uly_to_km
    • 光年的百萬分之一 = 數字:英里 / uly_to_mls
  3. CELX “向量”物件是一個幾何物件,它在三維座標系中具有長度和方向 [X、Y、Z]。
  4. 可以在 CELX “向量”物件上使用 向量 方法。“向量”物件也可以用於其他方法,這些方法需要“向量”物件作為引數。

示例-1
建立一個向量,指向 Y 方向,長度為 1。

up_vector = celestia:newvector(0, 1, 0)

示例-2
建立一個向量,指向 X 方向,長度為 5000 公里。

uly_to_km  =  9460730.4725808
x5k_vector = celestia:newvector(5000/uly_to_km, 0, 0)


返回 celestia 方法索引。


newposition

[edit | edit source]

1.3.2 位置 celestia:newposition(數字:x,數字:y,數字:z)

此 celestia 方法可用於從數字建立新的 CELX “位置”物件。

引數

x
新位置的 X 分量,以光年的百萬分之一表示。
y
新位置的 Y 分量,以光年的百萬分之一表示。
z
新位置的 Z 分量,以光年的百萬分之一表示。

註釋

  1. 如果位置分量以公里或英里定義,則必須先將這些分量轉換為光年的百萬分之一。
    因此,可以使用一個常量,該常量必須先在指令碼中初始化
    • 從公里到光年的百萬分之一,使用常量 uly_to_km = 9460730.4725808。
    • 從英里到光年的百萬分之一,使用常量 uly_to_mls = 5912956.5453630。
  2. 接下來,可以將公里或英里轉換為光年的百萬分之一,如下所示
    • 光年的百萬分之一 = 數字:公里 / uly_to_km
    • 光年的百萬分之一 = 數字:英里 / uly_to_mls
  3. CELX “位置”物件包含空間中一個點的精確座標。位置相對於座標系,在進一步使用之前可能需要將其轉換為或從通用座標系轉換。
  4. 可以在 CELX “位置”物件上使用 位置 方法。“位置”物件也可以用於其他方法,這些方法需要“位置”物件作為引數。

示例
從火星中心出發,在“通用”座標系的 X 方向上移動 20,000 公里,並顯示螢幕左下角的火星位置。

uly_to_km = 9460730.4725808
-- Set frame of reference to "universal"
obs = celestia:getobserver()
obs:setframe(celestia:newframe("universal"))
-- Find and select Mars
mars = celestia:find("Sol/Mars")
celestia:select(mars)
-- Obtain and print actual position of Mars
now = celestia:gettime()
posmars = mars:getposition(now)
posmars_x = posmars:getx()
posmars_y = posmars:gety()
posmars_z = posmars:getz()
celestia:print("Actual position of Mars:\nX = " .. posmars_x .. 
               "\nY = " .. posmars_y .. "\nZ = " ..  posmars_z, 15, -1, -1, 1, 6)
-- Determine and goto specified position
pos = celestia:newposition((posmars_x + (20000/uly_to_km)), posmars_y, posmars_z )
obs:goto(pos,5.0)
-- Follow Mars and wait until the goto has finished
obs:follow(mars)
wait(5.0)
-- you are on the right position now, but probably Mars
-- may not be visible yet, so center Mars on your screen.
obs:center(mars,2.0)
wait(10.0)


返回 celestia 方法索引。


newposition (base64)

[edit | edit source]

1.3.2 位置 celestia:newposition(字串:x,字串:y,字串:z)

此 celestia 方法可用於從 URL 樣式的 Base64 編碼值建立新的 CELX “位置”物件。

引數

x
新位置的 X 分量,作為從 cel 樣式 URL 獲取的字串值。
y
新位置的 Y 分量,作為從 cel 樣式 URL 獲取的字串值。
z
新位置的 Z 分量,作為從 cel 樣式 URL 獲取的字串值。

註釋

  1. 字串值可以在 celURL 中的“x=”、“y=” 和“z=”之後,以及下一個出現的“&”之前找到。
  2. CELX “位置”物件包含空間中一個點的精確座標。位置相對於座標系,在進一步使用之前可能需要將其轉換為或從通用座標系轉換。
  3. 可以在 CELX “位置”物件上使用 位置 方法。“位置”物件也可以用於其他方法,這些方法需要“位置”物件作為引數。

示例
根據以下 Celestia 版本 1.6.0 celURL,位於地球北極上方的位置

  • cel://SyncOrbit/Sol:Earth/2009-11-18T22:32:34.46583?x=Z7PNuA&y=sP9vw0j/+w&z=/P7//////////////////w&ow=-0.5&ox=-0.5&oy=0.5&oz=0.5&select=Sol:Earth&fov=26.5729&ts=1&ltd=0&p=0&rf=3987&lm=52864&tsrc=0&ver=3
-- First simulate some essential celURL settings.
earth = celestia:find("Sol/Earth")
obs = celestia:getobserver()
obs:synchronous(earth)
celestia:select(earth)
-- Then create and goto new position
earth_np_pos = celestia:newposition("Z7PNuA", "sP9vw0j/+w", "/P7//////////////////w")
obs:goto(earth_np_pos,2.0)
wait(2.0)
-- you are on the right position now, but probably Earth may not be visible yet,
-- so center Earth on your screen.
obs:center(earth,2.0)
wait(2.0)
-- (Mind the observer orientation may differ from the celURL above).


返回 celestia 方法索引。


newrotation (軸-角)

[edit | edit source]

旋轉 celestia:newrotation(向量:軸,數字:角度)

此 celestia 方法可用於建立繞指定軸旋轉的角度弧度的新的旋轉(即四元數)。

引數

描述此旋轉的 [x、y、z] 軸的向量。必須是“向量”物件。
角度
此旋轉的角度,以弧度表示。必須是數字。

註釋

  1. CELX 中的角度以弧度而不是度數定義。180 度(半圓)與 π 弧度相同 = 3.14159265 弧度 = math.pi 弧度 (LUA)。可以將度數轉換為弧度,反之亦然,如下所示
    • 弧度 = math.rad( 數字:度數 ) = ( 數字:度數 / 180 * math.pi) = ( 數字:度數 / 180 * 3.14159265)。
    • 度數 = math.deg( 數字:弧度 ) = ( 數字:弧度 * 180 / math.pi) = ( 數字:弧度 * 180 / 3.14159265)。
  2. 此方法等效於 rotation:setaxisangle() 方法。僅使用此方法,將建立“旋轉”物件,並且無需先存在。
  3. CELX “旋轉”物件在內部是一個四元數,它是數學上描述三維空間中旋轉的一種可能性(即它可以轉換為旋轉矩陣)。旋轉也可以用於描述物體或觀察者的方向(即觀察者朝哪個方向看,以及“向上”是哪個方向)。
  4. 可以在 CELX “旋轉”物件上使用 旋轉 方法。“旋轉”物件也可以用於其他方法,這些方法需要“旋轉”物件作為引數。

示例-1
將當前相機視角旋轉 180 度(類似於後視鏡)。

-- Define the UP vector for the rotation (Y-axis).
-- Define a rotation object "lookback" with an angle of 180 degrees
-- (= math.pi radians), along the specified Y-axis in the UP vector.
-- Rotate the observer according the specified rotation.
up_vec = celestia:newvector(0,1,0)
lookback = celestia:newrotation(up_vec,math.pi)
obs = celestia:getobserver()
obs:rotate(lookback)

示例-2
在約 10 秒內將當前相機視角旋轉 360 度。

up_vec = celestia:newvector(0,1,0)
obs_rotation = celestia:newrotation(up_vec, 2*math.pi/500)
for i = 1, 500 do
   celestia:getobserver():rotate(obs_rotation)
   wait(10/500)
end


返回 celestia 方法索引。


newrotation

[edit | edit source]

rotation celestia:newrotation(number:ow, number:ox, number:oy, number:oz)

此 celestia 方法可用於根據四個標量值(celURL 中使用的值)建立新的旋轉(即四元數)。

引數

ow
新旋轉的 OW 分量,作為從 cel 樣式 URL 獲取的數字值。
ox
新旋轉的 OX 分量,作為從 cel 樣式 URL 獲取的數字值。
oy
新旋轉的 OY 分量,作為從 cel 樣式 URL 獲取的數字值。
oz
新旋轉的 OZ 分量,作為從 cel 樣式 URL 獲取的數字值。

註釋

  1. 數字值可以在 celURL 中的 "ow="、"ox="、"oy=" 和 "oz=" 之後以及下一個 "&" 之前找到。
  2. 將向量的分量作為 ox-、oy-、oz- 值傳遞與傳遞向量本身不同。
    如果傳遞向量,則必須使用 newrotation (軸-角) 方法建立四元數。
  3. CELX “旋轉”物件在內部是一個四元數,它是數學上描述三維空間中旋轉的一種可能性(即它可以轉換為旋轉矩陣)。旋轉也可以用於描述物體或觀察者的方向(即觀察者朝哪個方向看,以及“向上”是哪個方向)。
  4. 可以在 CELX “旋轉”物件上使用 旋轉 方法。“旋轉”物件也可以用於其他方法,這些方法需要“旋轉”物件作為引數。

示例
根據以下 Celestia 版本 1.6.0 celURL,位於地球北極上方的位置

  • cel://SyncOrbit/Sol:Earth/2009-11-18T22:32:34.46583?x=Z7PNuA&y=sP9vw0j/+w&z=/P7//////////////////w&ow=-0.5&ox=-0.5&oy=0.5&oz=0.5&select=Sol:Earth&fov=26.5729&ts=1&ltd=0&p=0&rf=3987&lm=52864&tsrc=0&ver=3
-- First simulate some essential celURL settings.
earth = celestia:find("Sol/Earth")
obs = celestia:getobserver()
obs:synchronous(earth)
celestia:select(earth)
-- Set the observer orientation according the celURL values.
rot = celestia:newrotation(-0.5, -0.5, 0.5, 0.5)
obs:setorientation(rot)
-- Then create and goto new position
earth_np_pos = celestia:newposition("Z7PNuA", "sP9vw0j/+w", "/P7//////////////////w")
obs:goto(earth_np_pos,2.0)
wait(2.0)


返回 celestia 方法索引。


newframe

[edit | edit source]

frame celestia:newframe(string:coordsysname [, object:reference, object:target])

此 celestia 方法可用於建立新的參考系作為 "frame" 物件。

引數

coordsysname
描述幀型別的字串。它必須是以下之一
reference [可選]
新幀的參考物件。必須是 "object" 物件。
  • 座標系 "universal" 不需要。
target [可選]
此幀的目標物件。必須是 "object" 物件。
  • 僅座標系 "lock" 需要。

註釋

  1. 在 Celestia 版本 1.6.0 中,名稱 bodyfixed 將替換 planetographic,但出於相容性原因,名稱 planetographic 將繼續起作用。
  2. CELX 參考 "frame" 是一個原點和一組軸,它們定義了用於物體的軌跡和方向的座標系。原點是目錄檔案中定義的另一個物體。有幾種方法可以設定座標系軸。
  3. 可以使用 frame 方法在 CELX "frame" 物件上操作。本節還提供了有關使用參考系的更多資訊。"Frame" 物件也可以用在其他方法中,這些方法需要 "frame" 物件作為引數。

示例-1
指示 Celestia 將活動座標系設定為 UNIVERSAL

frame = celestia:newframe("universal")
obs = celestia:getobserver()
obs:setframe(frame)

示例-2
以下示例選擇月球,然後將活動座標系設定為 CHASE 並移至月球

moon = celestia:find("Sol/Earth/Moon")
celestia:select(moon)
frame = celestia:newframe("chase", moon)
obs = celestia:getobserver()
obs:setframe(frame)
obs:goto(moon, 2.0)
wait(2.0)

示例-3
指示 Celestia 將活動座標系設定為 LOCK 地球和太陽。該示例將保持您相對於地球中心的方位,並在時間推移時保持太陽 (Sol) 和地球都在視野中。在執行此示例之前,請確保地球和太陽已在觀察者的視野中。

earth = celestia:find("Sol/Earth")
celestia:select(earth)
sun = celestia:find("Sol")
frame = celestia:newframe("lock", earth, sun)
obs = celestia:getobserver()
obs:setframe(frame)
celestia:settimescale(50000)


返回 celestia 方法索引。


requestkeyboard

[edit | edit source]

1.3.2 celestia:requestkeyboard(boolean:enable)

啟用或停用鍵盤輸入回撥。

引數

enable
布林值,用於確定是否應啟用/停用鍵盤輸入。
  • 如果應啟用鍵盤輸入,則為 true
  • 讓 celestia 處理鍵盤,則為 false。

註釋

  1. 如果已啟用鍵盤輸入,則 celestia 將對每個按鍵執行名為 "celestia_keyboard_callback()" 的函式。呼叫此 celestia:requestkeyboard() 方法時,此函式必須存在。
  2. 按下的鍵作為字串引數提供給函式,其中包含此鍵的 UTF-8 編碼(對於 ASCII 字元,它只是包含正常字元的字串)。
  3. "celestia_keyboard_callback()" 函式可以返回一個布林值,指示是否已處理按鍵 (true) 還是應該繼續正常處理 (false),沒有返回值被視為true
  4. 這些回撥只能在指令碼正在執行 wait() 時發生。

示例
您可以在 CELX 指令碼中使用以下示例來處理鍵盤輸入

-- Initialize variable to have no content:
last_pressed_key = nil
--
-- Define functions section:
--
function celestia_keyboard_callback(key)
   last_pressed_key = key
   return true
end
--
function get_pressed_key()
   last_pressed_key = nil
   celestia:requestkeyboard(true)
   while true do
      if last_pressed_key ~= nil then
         key = last_pressed_key
         last_pressed_key = nil
         celestia:requestkeyboard(false)
         return key
      end
      wait(0.1)
   end
end
--
-- Main CELX script section:
--
-- Section within your script, where you want to handle keyboard input:
while true do
   local key = get_pressed_key()
   if key == string:key1 then
      valid_key = true
      -- specify your own CELX code here, about what to do if key matches string:key1.
   elseif key == string:key2 then
      valid_key = true
      -- specify your own CELX code here, about what to do if key matches string:key2.
   else
      valid_key = false
   end
   if valid_key then
      -- specify your own CELX code here, about what to do if a valid key has been pressed.
   end
   wait(0)
end


返回 celestia 方法索引。


requestsystemaccess

[edit | edit source]

1.3.2 celestia:requestsystemaccess()

請求訪問 Lua 的 ioos 庫的許可權,這些庫提供檔案寫入和程式執行。
有關詳細資訊,請參閱 Lua: 文件參考手冊

註釋

  1. 如果 celestia.cfg 檔案中的 ScriptSystemAccessPolicy 引數設定為 "ask"(預設值),則會詢問使用者是否要允許此操作。此問題將在下一個 wait() 出現,因此您必須在請求生效之前呼叫 wait()
  2. 呼叫 celestia:requestsystemaccess() 方法後,將停用鍵盤處理,因此,如果您需要它,則必須使用 celestia:requestkeyboard(true) 重新啟用鍵盤處理。此行為可能會在將來的 Celestia 版本中發生變化(但重新啟用也不會造成傷害)。

示例
要將 CELX 指令碼中的資訊寫入檔案,首先需要訪問 LUA os & io 函式。如果請求成功,則可以使用以下方式使用 LUA os & io 函式

celestia:requestsystemaccess()
wait(0)
-- Use LUA function to open a file with name "LUAtest.txt"
-- in the Celestia main directory in write mode.
test_file = io.open ("LUAtest.txt" , "w")
-- Write some text to the just opened file.
io.output(test_file):write("This is a test")
-- Close the file. 
io.close (test_file)


返回 celestia 方法索引。


getscriptpath

[edit | edit source]

1.3.2 string celestia:getscriptpath()

以字串形式返回實際執行指令碼的路徑(包括檔名)。

該路徑可能相對於當前工作目錄。

示例

pathname = celestia:getscriptpath()
celestia:print("The path to this script is: " .. pathname, 10.0, -1, -1, 2, 4)
wait(10.0)


返回 celestia 方法索引。


takescreenshot

[edit | edit source]

1.3.2 boolean celestia:takescreenshot([string:filetype, string:name])

擷取螢幕截圖並將其儲存到磁碟(如果您的系統允許)。如果成功,則返回布林值 true。

引數

filetype [可選]
定義螢幕截圖的檔案型別(副檔名),預設值為 "png"
必須是以下之一
  • "png"
  • "jpg"
name [可選]
一個字串,將在此螢幕截圖的檔名中使用,預設值為 ""。
此名稱部分僅限於 A-z、0-9 和 _(下劃線),最大長度為 8 個字元。

註釋

  1. 為了避免覆蓋其他檔案(即非螢幕截圖),檔名始終類似於 "screenshot-000001.png" 或 "screenshot-string:name-000001.png",其中數字從 1 開始,每次啟動指令碼時遞增,name 可以由指令碼選擇 - 如上所述。
  2. 擷取螢幕截圖需要一些時間,但正在進行的任何閃光、列印、goto 或 center 命令都不會等待。這可能會在將來發生變化,但另一方面,還沒有人抱怨過。
  3. 為安全原因在 Celestia 版本 1.3.2 中實施的限制在 Celestia 版本 1.4.0 中已部分解除,因為 CEL 指令碼也提供不太安全的螢幕截圖擷取功能。這意味著可以透過使用 CEL 指令碼來規避安全問題 :-(
  4. 但是,螢幕截圖仍然會寫入 celestia.cfg 檔案中的 config 選項 "ScriptScreenshotDirectory" 設定的目錄,預設設定為主 celestia 目錄(通常類似於 C:\Program Files\Celestia\),具體取決於您的系統,Celestia 可能不允許寫入該目錄的檔案。

示例
擷取當前場景的螢幕截圖並將其儲存在檔名中:"screenshot-test-000001.jpg"。如果此檔名已存在,則數字部分將遞增,直到找到第一個空閒數字。

screenshot = celestia:takescreenshot("jpg", "test")


返回 celestia 方法索引。


createcelscript

[edit | edit source]

celscript celestia:createcelscript(string:CELsource)

從包含有效 CEL 命令的字串建立 "celscript" 物件,並在當前 CELX 指令碼中執行 CEL 指令碼。

引數

CELsource
包含有效 CEL 指令碼原始碼的字串。
注意:如果字串不包含有效的 CEL 指令碼,則此方法將導致錯誤。

註釋

  1. Lua 支援使用雙括號的語法來表示長字串,這在本文中很有用。透過使用它,您幾乎可以在所有情況下將完整的 CEL 指令碼直接複製並貼上到 CELX 指令碼中,而無需修改。
  2. 在 CEL 指令碼執行期間,celscript:tick() 方法會反覆呼叫,直到返回 false,表示 CEL 指令碼已終止。

示例
以下示例選擇地球,前往地球,然後花費 2.5 秒將顯示距離更改為遠離地球。所有這些都是透過將嵌入在 CELX 指令碼中的 CEL 命令來完成的。

celsource = [[
              {
              select { object "Sol/Earth" }
              goto   { time 3 }
              wait   { duration 3 }
              changedistance { duration 2.5 rate 0.5 }
              wait   { duration 2.5 }
              }
            ]]
celscript = celestia:createcelscript(celsource)
while celscript:tick() do 
   wait(0) 
end


返回 celestia 方法索引。


getstarcount

[edit | edit source]

number celestia:getstarcount()

返回星表中恆星的總數,以數字表示。

示例

number_of_stars = celestia:getstarcount()
celestia:print("The total number of stars in the star catalogue: " .. number_of_stars, 10.0, -1, -1, 2, 4)
wait(10.0)


返回 celestia 方法索引。


getstar

[edit | edit source]

object celestia:getstar(number:index_number)

返回一顆恆星,由其在星表中的索引號標識,表示為“object”物件。

引數

index_number
星表中恆星的編號。
必須介於 0(零)和星表中恆星的總數減 1 之間。

註釋

  1. 在 1.6.1 之前,此方法實現不正確,將它的引數視為非常內部的索引,而不是目錄編號。因此,負數大於或等於星表中恆星總數的數字可能會導致 Celestia 錯誤!星表中恆星的總數可以透過使用celestia:getstarcount() 方法來獲取。
  2. CELX 的 "object" 物件既可以指代像行星或恆星這樣的天體,也可以指代位置或航天器。
  3. CELX 的 "object" 物件可以使用object 方法。 "Object" 物件也可以用在其他方法中,這些方法需要一個 "object" 物件作為引數。

示例
透過目錄編號選擇一顆恆星並前往該恆星,同時在螢幕上顯示它的編號和名稱。

number = 12345
star = celestia:getstar(number)
starname = star:name()
celestia:select(star)
obs = celestia:getobserver()
obs:goto(star,5.0)
celestia:print("The name of star number " .. number .. " is: " .. starname, 10.0, -1, -1, 2, 4)
wait(10.0)


返回 celestia 方法索引。


getdsocount

[edit | edit source]

1.5.0 number celestia:getdsocount()

返回深空天體 (DSO) 目錄中深空天體的總數,以數字表示。

示例

number_of_dsos = celestia:getdsocount()
celestia:print("Total number of Deep Space Objects in DSO catalogue: " .. number_of_dsos, 10.0, -1, -1, 2, 4)
wait(10.0)


返回 celestia 方法索引。


getdso

[edit | edit source]

1.5.0 object celestia:getdso(number:index_number)

返回一個深空天體 (DSO),由其在 DSO 目錄中的索引號標識,表示為“object”物件。

引數

index_number
深空天體 (DSO) 目錄中深空天體的編號。
必須介於 0(零)和 DSO 目錄中 DSO 的總數減 1 之間。

註釋

  1. 在 1.6.1 之前,此方法實現不正確,將它的引數視為非常內部的索引,而不是目錄編號。因此,負數大於或等於 DSO 目錄中 DSO 總數的數字可能會導致 Celestia 錯誤!DSO 目錄中 DSO 的總數可以透過使用 1.5.0 celestia:getdsocount() 方法來獲取。
  2. CELX 的 "object" 物件既可以指代像行星或恆星這樣的天體,也可以指代位置或航天器。
  3. CELX 的 "object" 物件可以使用object 方法。 "Object" 物件也可以用在其他方法中,這些方法需要一個 "object" 物件作為引數。

示例
透過目錄編號選擇一個 DSO 並前往該 DSO,同時在螢幕上顯示它的編號和名稱。

number = 0
dso = celestia:getdso(number)
dsoname = dso:name()
celestia:select(dso)
obs = celestia:getobserver()
obs:goto(dso,5.0)
celestia:print("The name of DSO number " .. number .. " is: " .. dsoname, 10.0, -1, -1, 2, 4)
wait(10.0)


返回 celestia 方法索引。


stars

[edit | edit source]

1.5.0 iterator celestia:stars()

返回一個迭代器,它可以與 Lua 的通用“for”語句一起使用,用於列舉 Celestia 星表中的所有恆星。

迭代器可以被認為是一種指標,它具有兩個主要操作:

  1. 引用物件集合中的一個特定元素(稱為元素訪問),
  2. 修改自身以指向下一個元素(稱為元素遍歷)。

還必須有一種方法來建立迭代器,使其指向第一個元素,以及一種方法來確定迭代器是否已遍歷完物件集合中的所有元素。

註釋

  1. 可以使用object 方法對該迭代器進行操作。

示例
以下程式碼使用 celestia:stars() 迭代器來標記所有光譜型為 B 的恆星

celestia:unmarkall()
celestia:setrenderflags{markers = true}
celestia:select(nil)
for star in celestia:stars() do
   first, last = string.find(star:spectraltype(), "B", 1, true)
   if first == 1 then
      star:mark("#00ff00", "square", 10)
   end
end
wait(20.0)
celestia:unmarkall()
celestia:setrenderflags{markers = false}


返回 celestia 方法索引。


1.5.0 iterator celestia:dsos()

返回一個迭代器,它可以與 Lua 的通用“for”語句一起使用,用於列舉 Celestia 目錄中的所有深空天體 (DSO:在 .DSC 檔案中定義的物件)。

迭代器可以被認為是一種指標,它具有兩個主要操作:

  1. 引用物件集合中的一個特定元素(稱為元素訪問),
  2. 修改自身以指向下一個元素(稱為元素遍歷)。

還必須有一種方法來建立迭代器,使其指向第一個元素,以及一種方法來確定迭代器是否已遍歷完物件集合中的所有元素。

註釋

  1. 可以使用object 方法對該迭代器進行操作。

示例
以下程式碼使用 celestia:dsos() 迭代器來標記所有哈勃型別為 SB 的星系

celestia:unmarkall()
celestia:setrenderflags{markers = true}
celestia:select(nil)
for dso in celestia:dsos() do
   if dso:getinfo().type == "galaxy" then
      hubbleType = dso:getinfo().hubbleType
      if string.find(hubbleType, "SB") then
         dso:mark( "green", "disk", 7, 0.7 )
      end
   end
end
wait(20.0)
celestia:unmarkall()
celestia:setrenderflags{markers = false}


返回 celestia 方法索引。


utctotdb

[edit | edit source]

1.5.0 number celestia:utctotdb(number:year [, number:month, number:day, number:hour, number:minute, number:seconds])

將 UTC 日曆日期/時間轉換為 TDB 儒略日,並以數字形式返回該儒略日。

引數

year
此日期的年份的整數。
月份 [可選]
日期所在年份的月份的整數(1-12)。預設值為 1。
日期 [可選]
日期所在月份的日期的整數(1-31)。預設值為 1。
小時 [可選]
日期所在日期的小時的整數。預設值為 0。
分鐘 [可選]
日期所在小時的分鐘的整數。預設值為 0。
秒鐘 [可選]
日期所在分鐘的秒鐘的浮點數。預設值為 0.0。

註釋

  1. 從版本 1.5.0 開始,儘管 Celestia 仍然在螢幕上顯示 UTC,但它在內部使用 TDB 時間標度來處理其他所有內容,因此對於 CELX 指令碼而言 !!! 為了使用儒略日設定模擬時間,對於這些較新的 Celestia 版本,應該使用 1.5.0 celestia:utctotdb() 方法,而不是舊的 celestia:tojulianday() 方法。
  2. 有關 TDB、UTC 以及 Celestia 中如何使用時間的更多資訊,請參閱 Celestia/時間尺度

示例-1
獲取 2007 年 8 月 12 日午夜 UTC 的 TDB 儒略日,並設定該模擬時間。

tdb_juliandate = celestia:utctotdb(2007, 8, 12)
celestia:settime(tdb_juliandate)
celestia:settimescale(0)

示例-2
獲取 1492 年 12 月 25 日 12:50:00 UTC 的 TDB 儒略日,並設定該模擬時間。
請注意,在此示例中,日期實際上是儒略日曆日期(羅馬日曆日期的改革),因為我們今天使用的公曆日期直到 1582 年才被採用。

tdb_juliandate = celestia:utctotdb(1492, 12, 25, 12, 50 , 0.0)
celestia:settime(tdb_juliandate)
celestia:settimescale(0)


返回 celestia 方法索引。


tdbtoutc

[edit | edit source]

1.5.0 table celestia:tdbtoutc(number:tdb)

將 TDB 儒略日轉換為 UTC 日曆日期/時間。返回的表包含以下鍵:

  • year
  • 月份
  • 日期
  • 小時
  • 分鐘
  • 秒鐘

TDB 儒略日是自公元前 4712 年 1 月 1 日 11:59:17 UTC 以來以天和天分數表示的時間間隔。

引數

tdb
TDB 儒略日數字。
特殊值
  • 0 是上述參考日期的日期
  • 負值可用於前一個日期
  • 儒略日數 (JDN) 是儒略日 (JD) 的整數部分。
    • 2010 年 1 月 1 日的儒略日數為 2455198。
  • 儒略日的十進位制部分
    • 0.1 是 2.4 小時或 144 分鐘或 8640 秒
    • 0.01 是 0.24 小時或 14.4 分鐘或 864 秒
    • 0.001 是 0.024 小時或 1.44 分鐘或 86.4 秒
    • 0.0001 是 0.0024 小時或 0.144 分鐘或 8.64 秒
    • 0.00001 是 0.00024 小時或 0.0144 分鐘或 0.864 秒。

註釋

  1. 從版本 1.5.0 開始,儘管 Celestia 仍然在螢幕上顯示 UTC,但它在內部使用 TDB 時間標度來處理其他所有內容,因此對於 CELX 指令碼而言 !!! 對於這些較新的 Celestia 版本,使用 celestia:gettime() 方法獲取儒略日,並將該儒略日轉換為日曆日期/時間,應該使用 1.5.0 celestia:tdbtoutc() 方法,而不是舊的 celestia:fromjulianday() 方法。
  2. 有關 TDB、UTC 以及 Celestia 中如何使用時間的更多資訊,請參閱 Celestia/時間尺度

示例
獲取實際的 TDB 模擬時間,並將其轉換為 UTC 日曆日期/時間。可以透過將 print 語句的結果與螢幕右上角顯示的 UTC 日期/時間進行比較來檢查結果。

celestia:settimescale(0)
tdb_juliandate = celestia:gettime()
ut = celestia:tdbtoutc(tdb_juliandate)
celestia:print("Date/time: " .. ut.year .. " " .. ut.month .. " " .. ut.day .. " "
                .. ut.hour .. " " .. ut.minute .. " " .. ut.seconds, 10.0, -1, -1, 2, 4) 
wait(10.0)


返回 celestia 方法索引。


getaltazimuthmode

[edit | edit source]

1.5.0 boolean celestia:getaltazimuthmode()

返回一個布林值,指示是否啟用了高度方位模式。

  • true:啟用了高度方位模式。
  • false:停用了高度方位模式。

註釋

  1. 高度方位模式對應於水平座標系,該座標系是使用觀測者的當地地平線作為基本面的天球座標系。水平座標是:
    • 高度 (Alt),即天體與觀測者當地地平線之間的夾角。
    • 方位 (Az),即天體繞地平線旋轉的角度,相對於原點。
  2. 當觀測者位於一個天體表面時(透過使用 [Ctrl+G] 鍵或 observer:gotosurface() 方法),按左右箭頭鍵旋轉檢視:
    • "偏航" 如果啟用了高度方位模式 (true)。
    • "橫滾" 如果停用了高度方位模式 (false)。
  3. 可以使用 1.5.0 celestia:setaltazimuthmode() 方法設定高度方位模式。

示例

actual_altaz = celestia:getaltazimuthmode()


返回 celestia 方法索引。


setaltazimuthmode

[edit | edit source]

1.5.0 celestia:setaltazimuthmode(boolean:altaz)

啟用或停用高度方位模式。

引數

altaz
布林值,指示是否必須啟用或停用高度方位模式。
  • true 如果必須啟用高度方位模式。
  • false 如果必須停用高度方位模式。

註釋

  1. 高度方位模式對應於水平座標系,該座標系是使用觀測者的當地地平線作為基本面的天球座標系。水平座標是:
    • 高度 (Alt),即天體與觀測者當地地平線之間的夾角。
    • 方位 (Az),即天體繞地平線旋轉的角度,相對於原點。
  2. 當觀測者位於一個天體表面時(透過使用 [Ctrl+G] 鍵或 observer:gotosurface() 方法),按左右箭頭鍵旋轉檢視:
    • "偏航" 如果啟用了高度方位模式 (true)。
    • "橫滾" 如果停用了高度方位模式 (false)。
  3. 可以使用 1.5.0 celestia:getaltazimuthmode() 方法獲取當前的高度方位模式。

示例
未註釋的行確定是否必須啟用/停用高度方位模式。

-- celestia:setaltazimuthmode(true)     -- alt-azimuth mode must be enabled.
celestia:setaltazimuthmode(false)       -- alt-azimuth mode must be disabled.


返回 celestia 方法索引。


getoverlayelements

[edit | edit source]

1.5.0 table celestia:getoverlayelements()

返回一個表,其中包含所有已知的疊加元素(參見 1.5.0 celestia:setoverlayelements() 方法)作為鍵,以及一個布林值作為值,指示是否渲染特定疊加元素。

疊加元素與螢幕上部/下部、左部/右部的資訊顯示有關。

註釋

  1. 要啟用/停用不同疊加元素的渲染,可以使用 1.5.0 celestia:setoverlayelements() 方法。

示例

actual_overlaytab = celestia:getoverlayelements()


返回 celestia 方法索引。


setoverlayelements

[edit | edit source]

1.5.0 celestia:setoverlayelements(table:overlayelements)

單獨啟用或停用螢幕上每個疊加元素的渲染。

疊加元素與螢幕上部/下部、左部/右部的資訊顯示有關。

引數

overlayelements
一個包含疊加元素作為鍵,布林值作為每個鍵的值的表格。每個疊加元素必須是以下之一
  • Time
    螢幕右上角的疊加元素。
  • Velocity
    螢幕左下角的疊加元素。
  • Selection
    螢幕左上角的疊加元素。
  • Frame
    螢幕右下角的疊加元素。
注意:注意 celestia 對此 celestia 方法的鍵的區分大小寫 !!!

註釋

  1. 類似於線上按下 [V] 鍵,透過兩個詳細程度級別切換整個資訊顯示(所有疊加元素一起)的開關。但是,此方法可以單獨啟用/停用每個疊加元素,但無法在兩個詳細程度級別之間切換
  2. 可以使用 1.5.0 celestia:getoverlayelements() 方法獲取每個疊加元素的當前渲染狀態。

示例
停用所有疊加元素的渲染。

-- create and initialize table first
overlaytab = {}
overlaytab.Time = false
overlaytab.Velocity = false
overlaytab.Selection = false
overlaytab.Frame = false
celestia:setoverlayelements(overlaytab)

或者更簡短

-- Note the curly braces
celestia:setoverlayelements{Time = false, Velocity = false, Selection = false, Frame = false}


返回 celestia 方法索引。


getgalaxylightgain

[edit | edit source]

1.5.0 number celestia:getgalaxylightgain()

返回當前銀河系光增益(亮度)級別,以數字形式表示。

註釋

  1. 可以使用 celestia:setrenderflags() 方法開啟/關閉星系。
  2. 可以使用 1.5.0 celestia:setgalaxylightgain() 方法設定銀河系光增益(亮度)級別。

示例

actual_galaxylightgain = celestia:getgalaxylightgain()


返回 celestia 方法索引。


setgalaxylightgain

[edit | edit source]

1.5.0 celestia:setgalaxylightgain(number:lightgain)

設定銀河系光增益(亮度)級別。

引數

lightgain
定義新的銀河系光增益(亮度)級別的數字。
必須介於 0 (0%) 和 1 (100%) 之間,否則將調整為最接近的有效值 (0 或 1)。

註釋

  1. 可以使用 celestia:setrenderflags() 方法開啟/關閉星系。
  2. 可以使用 1.5.0 celestia:getgalaxylightgain() 方法獲取當前銀河系光增益(亮度)級別。
  3. 當訪問銀河系之外的星系時,增強亮度可以改善你對遙遠星系的觀測,而在銀河系內,降低亮度可以改善你對恆星、行星、衛星等的觀測。
  4. 銀河系亮度也會隨著使用 celestia:setfaintestvisible() 方法設定最微弱可見星等而發生變化。這些方法是關聯的。

示例
啟用星系的渲染並將其亮度最大化。

celestia:setrenderflags{galaxies = true}
celestia:setgalaxylightgain(1)


返回 celestia 方法索引。


gettextwidth

[edit | edit source]

1.5.0 number celestia:gettextwidth(string:text)

以數字形式返回文字字串的寬度(以畫素為單位)。

示例

textwidth = celestia:gettextwidth("This is a text string")


返回 celestia 方法索引。


1.5.0 celestia:log(string:text)

將文字寫入 Celestia 日誌檔案。Celestia 支援 UTF-8 編碼文字字串,用於寫入非 ASCII 字元。

引數

text
包含要寫入 Celestia 日誌的訊息的字串。
也可以在同一個日誌命令中使用變數和文字字串。
這可以透過如下方式連線文字字串和變數來完成
  • "String1 " .. variable1 .. "String2 " .. variable2
注意:celestia:print() 方法不同,此字串引數不能包含換行符“\n”以換行。

註釋

  1. 此方法對於除錯 Lua/CELX 指令碼非常有用。
  2. 可以使用鍵盤上的波浪號 [~] 鍵(或某些系統上的 [~] + [空格鍵])在螢幕上顯示 Celestia 日誌。

示例
在螢幕上顯示 Celestia 日誌,執行此示例並驗證文字是否已寫入日誌。

celestia:log("This message is written to the Celestia log")


返回 celestia 方法索引。


registereventhandler

[edit | edit source]

1.5.0 boolean celestia:registereventhandler(string:eventtype, function:eventhandler)

用指令碼作者選擇的行為(在函式中定義)替換 Celestia 的預設事件處理。

引數

eventtype
指定事件型別的字串。必須是以下之一
  • "key"
  • "mouseup"
  • "mousedown"
  • "tick"
eventhandler
一個接受包含事件屬性的單個表格引數並返回布林值(指示它是否已處理事件)的函式。
使用 nil 取消繫結事件型別與事件處理程式的繫結。

註釋

  1. 如果沒有註冊事件處理程式,或者註冊的事件處理程式返回 false,Celestia 將恢復為該事件的預設行為。
  2. 事件型別與事件處理程式之間的繫結將保留,直到:
    1. Celestia 重新啟動
    2. 在事件型別和另一個事件處理程式(可能在另一個指令碼中)之間指定新的繫結
    3. 透過使用以下命令取消繫結事件型別與事件處理程式的繫結:
      celestia:registereventhandler(string:eventtype, nil)

示例
此鍵盤處理函式示例將鍵盤上的 [P] 和 [Q] 鍵繫結到處理程式 showmessage(),該處理程式會在螢幕上閃爍訊息。

function showmessage()
   celestia:flash("Key pressed")
end

-- The table mapping key names to handlers
keyhandlers = { p = showmessage, q = showmessage }

function handlekey(k)
   -- k is a table containing the event properties; in this simple sample,
   -- we're only interested in char, the name of the key that was pressed.
   handler = keyhandlers[k.char]
   if (handler ~= nil) then
      handler()
      return true
   else
      return false
   end
end

celestia:registereventhandler("key", handlekey)


返回 celestia 方法索引。


geteventhandler

[edit | edit source]

1.5.0 boolean celestia:geteventhandler(string:eventtype)

返回一個布林值,指示 Celestia 對指定事件型別的預設事件處理是否被替換

  • true,預設事件處理被替換。
  • false,預設事件處理被替換。

引數

eventtype
指定事件型別的字串。必須是以下之一
  • "key"
  • "mouseup"
  • "mousedown"
  • "tick"

示例
測試 Celestia 對事件型別“key”的預設事件處理是否被替換。

handler = celestia:geteventhandler("key")
if handler then
   celestia:flash("Default event handling for the event type 'key' is replaced.", 5.0)
else
   celestia:flash("Default event handling for the event type 'key' is NOT replaced.", 5.0)
end


返回 celestia 方法索引。


setlabelcolor

[edit | edit source]

1.5.0 celestia:setlabelcolor(string:label, number:red, number:green, number:blue)

設定標籤調色盤的顏色。

引數

label
描述必須更改其顏色的標籤的字串。必須是以下之一
  • stars
  • planets
  • moons
  • asteroids
  • comets
  • spacecraft
  • locations
  • galaxies
  • constellations
  • equatorialgrid
  • 1.5.0 nebulae
  • 1.5.0 openclusters
  • 1.6.0 globulars
  • 1.6.0 dwarfplanets
  • 1.6.0 minormoons
  • 1.6.0 planetographicgrid
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid
red
顏色的 RGB 值的紅色部分,必須介於 0 和 1 之間。
green
顏色的 RGB 值的綠色部分,必須介於 0 和 1 之間。
blue
顏色的 RGB 值的藍色部分,必須介於 0 和 1 之間。

註釋

  1. 可以使用 1.6.0 celestia:getlabelcolor() 方法獲取特定標籤的當前顏色。
  2. 可以使用 celestia:showlabel()celestia:hidelabel()celestia:setlabelflags() 方法開啟/關閉特定標籤。

示例 1
將恆星標籤的顏色設定為紅色並開啟恆星標籤。

celestia:setlabelcolor("stars", 1, 0, 0)
celestia:setlabelflags{stars = true}

示例 2
ElChristou 的替代標籤顏色。

celestia:setlabelcolor("stars",          0.471, 0.356, 0.682)
celestia:setlabelcolor("planets",        0.407, 0.333, 0.964)
celestia:setlabelcolor("moons",          0.231, 0.733, 0.792)
celestia:setlabelcolor("asteroids",      0.596, 0.305, 0.164)
celestia:setlabelcolor("comets",         0.768, 0.607, 0.227)
celestia:setlabelcolor("spacecraft",     0.930, 0.930, 0.930)
celestia:setlabelcolor("locations",      0.240, 0.890, 0.430)
celestia:setlabelcolor("galaxies",       0.000, 0.450, 0.500)
celestia:setlabelcolor("nebulae",        0.541, 0.764, 0.278)
celestia:setlabelcolor("openclusters",   0.239, 0.572, 0.396)
celestia:setlabelcolor("constellations", 0.125, 0.167, 0.200)
celestia:setlabelcolor("equatorialgrid", 0.095, 0.196, 0.100)


返回 celestia 方法索引。


setlinecolor

[edit | edit source]

1.5.0 celestia:setlinecolor(string:line, number:red, number:green, number:blue)

設定線條調色盤的顏色。

引數

line
描述必須更改其顏色的線條的字串。必須是以下之一
  • starorbits
  • planetorbits
  • moonorbits
  • asteroidorbits
  • cometorbits
  • spacecraftorbits
  • constellations
  • boundaries
  • equatorialgrid
  • 1.6.0 dwarfplanetorbits
  • 1.6.0 minormoonorbits
  • 1.6.0 planetographicgrid
  • 1.6.0 planetequator
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid
  • 1.6.0 ecliptic
red
顏色的 RGB 值的紅色部分,必須介於 0 和 1 之間。
green
顏色的 RGB 值的綠色部分,必須介於 0 和 1 之間。
blue
顏色的 RGB 值的藍色部分,必須介於 0 和 1 之間。

註釋

  1. 可以使用 1.6.0 celestia:getlinecolor() 方法獲取特定線條的當前顏色。
  2. 可以使用 celestia:setorbitflags() 方法開啟/關閉特定軌道。
  3. 可以使用 celestia:setrenderflags() 方法開啟/關閉軌道、網格、星座和邊界。
  4. 1.6.0 planetequator 是行星圖網格的一部分,可以使用 object:addreferencemark() 方法為所有星體型別物件開啟/關閉該網格。

示例 1
將 galacticgrid 的顏色設定為青色並開啟 galacticgrid。

celestia:setlinecolor("galacticgrid", 0.0, 1.0, 1.0)
celestia:setrenderflags{galacticgrid = true}

示例 2
ElChristou 的替代線條顏色。

celestia:setlinecolor("starorbits",       0.500, 0.500, 0.800)
celestia:setlinecolor("planetorbits",     0.300, 0.323, 0.833)
celestia:setlinecolor("moonorbits",       0.080, 0.407, 0.392)
celestia:setlinecolor("asteroidorbits",   0.580, 0.152, 0.080)
celestia:setlinecolor("cometorbits",      0.639, 0.487, 0.168)
celestia:setlinecolor("spacecraftorbits", 0.400, 0.400, 0.400)
celestia:setlinecolor("constellations",   0.000, 0.120, 0.180)
celestia:setlinecolor("equatorialgrid",   0.070, 0.114, 0.073)
celestia:setlinecolor("boundaries",       0.100, 0.006, 0.066)


返回 celestia 方法索引。


getlabelcolor

[edit | edit source]

1.6.0 number, number, number celestia:getlabelcolor(string:label)

返回一個三元組數字(介於 0 和 1 之間),對應於指定標籤的顏色(RGB 值)的紅色、綠色和藍色分量。

引數

label
描述必須返回其顏色的標籤的字串。必須是以下之一
  • stars
  • planets
  • moons
  • asteroids
  • comets
  • spacecraft
  • locations
  • galaxies
  • constellations
  • equatorialgrid
  • 1.5.0 nebulae
  • 1.5.0 openclusters
  • 1.6.0 globulars
  • 1.6.0 dwarfplanets
  • 1.6.0 minormoons
  • 1.6.0 planetographicgrid
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid

註釋

  1. 可以使用 1.5.0 版本的 celestia:setlabelcolor() 方法設定特定標籤的顏色。
  2. 可以使用 celestia:showlabel()celestia:hidelabel()celestia:setlabelflags() 方法開啟/關閉特定標籤。

示例

r, g, b = celestia:getlabelcolor("planets")


返回 celestia 方法索引。


getlinecolor

[edit | edit source]

1.6.0 number, number, number celestia:getlinecolor(string:line)

返回一個三元組數字(介於 0 和 1 之間),對應於指定線條的 RGB 顏色值的紅色、綠色、藍色分量。

引數

line
描述需要返回其顏色的線條的字串。必須是以下之一
  • starorbits
  • planetorbits
  • moonorbits
  • asteroidorbits
  • cometorbits
  • spacecraftorbits
  • constellations
  • boundaries
  • equatorialgrid
  • 1.6.0 dwarfplanetorbits
  • 1.6.0 minormoonorbits
  • 1.6.0 planetographicgrid
  • 1.6.0 planetequator
  • 1.6.0 galacticgrid
  • 1.6.0 eclipticgrid
  • 1.6.0 horizontalgrid
  • 1.6.0 ecliptic

註釋

  1. 可以使用 1.5.0 版本的 celestia:setlinecolor() 方法設定特定線條的顏色。
  2. 可以使用 celestia:setorbitflags() 方法開啟/關閉特定軌道。
  3. 可以使用 celestia:setrenderflags() 方法開啟/關閉軌道、網格、星座和邊界。
  4. 1.6.0 planetequator 是行星圖網格的一部分,可以使用 object:addreferencemark() 方法為所有星體型別物件開啟/關閉該網格。

示例

 r, g, b = celestia:getlinecolor("planetorbits")


返回 celestia 方法索引。


getsystemtime

[edit | edit source]

1.6.0 number celestia:getsystemtime()

以 TDB 儒略日期數字形式返回當前系統時間。

較早的 Celestia 版本使用 UTC (協調世界時) 來計算時間和位置。
從版本 1.5.0 開始,雖然 Celestia 仍然在螢幕上顯示 UTC,
但它在內部使用 TDB 時間尺度進行其他所有操作,因此對於 CELX 指令碼來說 !!!

註釋

  1. 要獲取當前模擬時間而不是當前系統時間,應改用 celestia:gettime()observer:gettime() 方法。
  2. TDB 時間尺度與更熟悉的 UTC 稍有不同。使用 TDB 時,Celestia 可以更準確地放置物件。截至 2008 年 1 月 1 日,兩者之間的差異約為 65 秒。有關詳細資訊,請參閱Celestia/Time_Scales
  3. 要將 UTC 時間和 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  4. 要將普通日曆日期和儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例

actual_systemtime = celestia:getsystemtime()


返回 celestia 方法索引。


ispaused

[edit | edit source]

1.6.0 boolean celestia:ispaused()

返回一個布林值,指示時間是否暫停。

  • 如果時間已暫停,則為 true
  • 否則為 false。

示例

actual_paused = celestia:ispaused()


返回 celestia 方法索引。


showconstellations

[edit | edit source]

1.6.0 celestia:showconstellations([table:constellation_names])

啟用一個或多個星座的渲染。

引數

constellation_names [可選]
包含要顯示的星座名稱的表。必須是以下之一
  • "仙女座", "唧筒座", "天燕座", "寶瓶座", "天鷹座", "天壇座", "白羊座", "御夫座", "牧夫座", "鵰具座", "鹿豹座", "巨蟹座", "獵犬座", "大犬座", "小犬座", "摩羯座", "船底座", "仙后座", "半人馬座", "仙王座", "鯨魚座", "變色龍座", "圓規座", "鴿子座", "后髮座", "南冕座", "北冕座", "烏鴉座", "巨爵座", "南十字座", "天鵝座", "海豚座", "劍魚座", "天龍座", "小馬座", "波江座", "天爐座", "雙子座", "鶴座", "武仙座", "時鐘座", "長蛇座", "水蛇座", "印第安座", "蠍虎座", "獅子座", "小獅座", "天兔座", "天秤座", "狼座", "天貓座", "天琴座", "山案座", "顯微鏡座", "獨角獸座", "蒼蠅座", "矩尺座", "八分儀座", "蛇夫座", "獵戶座", "孔雀座", "飛馬座", "英仙座", "鳳凰座", "繪架座", "雙魚座", "南魚座", "船尾座", "羅盤座", "網罟座", "天箭座", "射手座", "天蠍座", "玉夫座", "盾牌座", "蛇頭座", "蛇尾座", "六分儀座", "金牛座", "望遠鏡座", "三角座", "南三角座", "杜鵑座", "大熊座", "小熊座", "船帆座", "室女座", "飛魚座", "狐狸座"。
  • 如果沒有傳遞 constellation_names,則顯示 **所有** 星座。
  • 如果 ..\celestia\data 目錄中的 **asterisms.dat** 檔案包含備用星群和/或星座名稱,則此引數中也可以使用此檔案中提到的名稱。
**注意**:注意 celestia 在此方法中關於星座名稱的大小寫敏感性 !!!

註釋

  1. 當使用 celestia:setrenderflags() 方法開啟星座時,預設情況下會顯示所有星座。為了使此 **celestia:showconstellations()** 方法生效,您首先必須使用 celestia:hideconstellations() 方法再次停用星座的渲染。
  2. 除了星座的渲染之外,此 **celestia:showconstellations()** 方法還會影響星座名稱。

示例-1
僅顯示室女座和天秤座

-- Note the curly braces
celestia:setrenderflags{constellations = true}
celestia:hideconstellations()
celestia:showconstellations{"Virgo", "Libra"}

示例-2
僅顯示黃道星座

celestia:setrenderflags{constellations = true}
celestia:hideconstellations()
zodiac = {"Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra",
          "Scorpius", "Ophiuchus", "Sagittarius", "Capricornus", "Aquarius"}
celestia:showconstellations(zodiac)

示例-3
顯示 **所有** 星座

celestia:setrenderflags{constellations = true}
celestia:hideconstellations()
celestia:showconstellations()


返回 celestia 方法索引。


hideconstellations

[edit | edit source]

1.6.0 celestia:hideconstellations([table:constellation_names])

停用一個或多個星座的渲染。

引數

constellation_names [可選]
包含要隱藏的星座名稱的表。必須是以下之一
  • "仙女座", "唧筒座", "天燕座", "寶瓶座", "天鷹座", "天壇座", "白羊座", "御夫座", "牧夫座", "鵰具座", "鹿豹座", "巨蟹座", "獵犬座", "大犬座", "小犬座", "摩羯座", "船底座", "仙后座", "半人馬座", "仙王座", "鯨魚座", "變色龍座", "圓規座", "鴿子座", "后髮座", "南冕座", "北冕座", "烏鴉座", "巨爵座", "南十字座", "天鵝座", "海豚座", "劍魚座", "天龍座", "小馬座", "波江座", "天爐座", "雙子座", "鶴座", "武仙座", "時鐘座", "長蛇座", "水蛇座", "印第安座", "蠍虎座", "獅子座", "小獅座", "天兔座", "天秤座", "狼座", "天貓座", "天琴座", "山案座", "顯微鏡座", "獨角獸座", "蒼蠅座", "矩尺座", "八分儀座", "蛇夫座", "獵戶座", "孔雀座", "飛馬座", "英仙座", "鳳凰座", "繪架座", "雙魚座", "南魚座", "船尾座", "羅盤座", "網罟座", "天箭座", "射手座", "天蠍座", "玉夫座", "盾牌座", "蛇頭座", "蛇尾座", "六分儀座", "金牛座", "望遠鏡座", "三角座", "南三角座", "杜鵑座", "大熊座", "小熊座", "船帆座", "室女座", "飛魚座", "狐狸座"。
  • 如果沒有傳遞 constellation_names,則隱藏 **所有** 星座。
  • 如果 ..\celestia\data 目錄中的 **asterisms.dat** 檔案包含備用星群和/或星座名稱,則此引數中也可以使用此檔案中提到的名稱。
**注意**:注意 celestia 在此方法中關於星座名稱的大小寫敏感性 !!!

註釋

  1. 當使用 celestia:setrenderflags() 方法開啟星座時,預設情況下會顯示所有星座。您首先必須使用此 **celestia:hideconstellations()** 方法再次停用星座的渲染,然後 celestia:showconstellations() 方法才能生效。
  2. 除了停用星座的渲染之外,此 **celestia:hideconstellations()** 方法還會影響星座名稱。

示例-1
僅隱藏室女座和天秤座

-- Note the curly braces
celestia:setrenderflags{constellations = true}
celestia:hideconstellations{"Virgo", "Libra"}

示例-2
隱藏所有星座,除了室女座和天秤座

-- Note the curly braces
celestia:setrenderflags{constellations = true}
celestia:hideconstellations()
celestia:showconstellations{"Virgo", "Libra"}


返回 celestia 方法索引。


setconstellationcolor

[edit | edit source]

1.6.0 celestia:setconstellationcolor(number:red, number:green, number:blue [, table:constellation_names])

設定單個星座的顏色。

引數

red
顏色的 RGB 值的紅色分量必須介於 0 和 1 之間。
green
顏色的 RGB 值的綠色分量必須介於 0 和 1 之間。
blue
顏色的 RGB 值的藍色分量必須介於 0 和 1 之間。
constellation_names [可選]
包含應用顏色更改的星座名稱的表。必須是以下之一
  • "仙女座", "唧筒座", "天燕座", "寶瓶座", "天鷹座", "天壇座", "白羊座", "御夫座", "牧夫座", "鵰具座", "鹿豹座", "巨蟹座", "獵犬座", "大犬座", "小犬座", "摩羯座", "船底座", "仙后座", "半人馬座", "仙王座", "鯨魚座", "變色龍座", "圓規座", "鴿子座", "后髮座", "南冕座", "北冕座", "烏鴉座", "巨爵座", "南十字座", "天鵝座", "海豚座", "劍魚座", "天龍座", "小馬座", "波江座", "天爐座", "雙子座", "鶴座", "武仙座", "時鐘座", "長蛇座", "水蛇座", "印第安座", "蠍虎座", "獅子座", "小獅座", "天兔座", "天秤座", "狼座", "天貓座", "天琴座", "山案座", "顯微鏡座", "獨角獸座", "蒼蠅座", "矩尺座", "八分儀座", "蛇夫座", "獵戶座", "孔雀座", "飛馬座", "英仙座", "鳳凰座", "繪架座", "雙魚座", "南魚座", "船尾座", "羅盤座", "網罟座", "天箭座", "射手座", "天蠍座", "玉夫座", "盾牌座", "蛇頭座", "蛇尾座", "六分儀座", "金牛座", "望遠鏡座", "三角座", "南三角座", "杜鵑座", "大熊座", "小熊座", "船帆座", "室女座", "飛魚座", "狐狸座"。
  • 如果沒有傳遞 constellation_names 表,則將 **所有** 星座設定為指定顏色。
  • 如果 ..\celestia\data 目錄中的 **asterisms.dat** 檔案包含備用星群和/或星座名稱,則此引數中也可以使用此檔案中提到的名稱。
**注意:**注意 Celestia 在此方法中關於星座名稱的大小寫敏感性 !!!

註釋

  1. 可以使用 celestia:setrenderflags() 方法開啟/關閉星座。
  2. 要僅渲染特定星座,可以使用 celestia:showconstellations()celestia:hideconstellations() 方法。
  3. 除了設定星座的顏色之外,此 **celestia:setconstellationcolor()** 方法還會影響星座名稱。

示例-1
將所有星座的顏色設定為紅色

celestia:setrenderflags{constellations = true}
celestia:setconstellationcolor(1, 0, 0)

示例-2
將所有黃道星座顯示為黃色

celestia:setrenderflags{constellations = true}
zodiac = {"Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra",
          "Scorpius", "Ophiuchus", "Sagittarius", "Capricornus", "Aquarius"}
celestia:setconstellationcolor(1, 1, 0, zodiac)


返回 celestia 方法索引。


gettextureresolution

[edit | edit source]

1.6.0 number celestia:gettextureresolution()

返回當前紋理解析度,表示為數字。

  • 0 為低解析度 (lores)
  • 1 為中等解析度 (medres)
  • 2 為高解析度 (hires)

示例

actual_textureres = celestia:gettextureresolution()


返回 celestia 方法索引。


settextureresolution

[edit | edit source]

1.6.0 celestia:settextureresolution(number:resolution)

設定紋理解析度。

  • 引數
resolution
與可用紋理解析度之一對應的數字
  • 0 為低解析度 (lores)
  • 1 為中等解析度 (medres)
  • 2 為高解析度 (hires)

示例
未註釋的行決定紋理解析度。

-- celestia:settextureresolution(0)  -- lores
-- celestia:settextureresolution(1)  -- medres
celestia:settextureresolution(2)     -- hires


返回 celestia 方法索引。


windowbordersvisible

[edit | edit source]

1.6.0 boolean celestia:windowbordersvisible()

返回一個布林值,指示在多檢視場景的情況下,每個檢視周圍的視窗邊框是否可見。

  • 如果視窗邊框可見,則為 true。
  • 如果視窗邊框不可見,則為 false。

示例

actual_visible = celestia:windowbordersvisible()


返回 celestia 方法索引。


setwindowbordersvisible

[edit | edit source]

1.6.0 celestia:setwindowbordersvisible(boolean:visible)

設定在多檢視場景的情況下,每個檢視周圍的視窗邊框的可見性。

引數

visible
布林值,指示在多檢視場景的情況下,每個檢視周圍的視窗邊框是否可見
  • true:視窗邊框可見。
  • flase:視窗邊框不可見。

示例
未註釋的行設定在多檢視場景的情況下,每個檢視周圍的視窗邊框的可見性。

celestia:setwindowbordersvisible(true)      -- Window borders visible
-- celestia:setwindowbordersvisible(false)  -- Window borders NOT visible


返回 celestia 方法索引。


synchronizetime

[edit | edit source]

1.6.1 celestia:synchronizetime(boolean:synched)

設定在多檢視場景的情況下,所有檢視之間的時間是否同步。

引數

synched
布林值,指示在多檢視場景的情況下,所有檢視之間的時間是否同步。
  • true:每個檢視中的時間都相同。
  • false:可以在每個檢視中獨立設定不同的時間。

註釋

  1. 重新開啟時間同步會將所有檢視中的時間重置為活動檢視的時間。

示例
未註釋的行決定在多檢視場景的情況下,所有檢視之間的時間是否同步。

-- celestia:synchronizetime(true)      -- Time is the same in each view
celestia:synchronizetime(false)        -- Time can be set in each view independently


返回 celestia 方法索引。


istimesynchronized

[edit | edit source]

1.6.1 boolean celestia:istimesynchronized()

返回一個布林值,指示在多檢視場景的情況下,所有檢視之間的時間是否同步。

  • true:所有檢視之間的時間同步。
  • false:所有檢視之間的時間不同步。

示例

actual_synched = celestia:istimesynchronized()


返回 celestia 方法索引。


1.6.1 celestia:seturl(string:celURL [, observer:obs])

使觀察者轉到指定的 celURL。

引數

celURL
包含位置、方向、時間、渲染選項和視野的文字字串(超連結)。
celURL 字串具有特定的 Celestia 可識別格式
  1. 字串始終以 "cel://" 開頭;
  2. 然後是: "Follow"、"SyncOrbit"、"Chase"、"PhaseLock" 或 "Freeflight"
    • 後面跟著兩個 "/" 字元之間的物件(例如 "/Sol:Earth/");
    • --或者-- "Freeflight" 情況下只有一個 "/" 字元。
  3. 日期格式: yyyy-mm-dd
    • 年份前可以加上 "-" 字元,表示公元前。
  4. 時間以 "T" 字元開頭,以 "?" 字元結尾,格式為
    • hh:mm:ss.sssss TDB 時間,略微不同於 UTC 時間。
      有關 TDB、UTC 以及 Celestia 中如何使用時間的更多資訊,請參閱 Celestia/時間尺度
  5. 觀察者在空間中的位置 (x,y,z),以當前參考系表示
    • "x=" 後面跟著 X 位置(例如 "AKknXYYNARE")
    • "&y=" 後面跟著 Y 位置(例如 "ACb9ForuURI")
    • "&z=" 後面跟著 Z 位置(例如 "AJLCIRc5vuz//////////w")
  6. 觀察者的方向 (ow, ox, oy, oz)
    • "ow=" 後面跟著旋轉的 OW 分量(例如 "0.429893")
    • "&ox=" 後面跟著旋轉的 OX 分量(例如 "0.319956")
    • "&oy=" 後面跟著旋轉的 OY 分量(例如 "-0.786188")
    • "&oz=" 後面跟著旋轉的 OZW 分量(例如 "-0.307779")
  7. 然後可以按順序使用其他選項,例如
    • "&track=" 物件名稱
    • "&select=" 物件名稱
    • "&fov=" 視野(度)
    • "&ts=" 時間刻度
    • "&ltd=" 光線延遲(0 = 關閉,1 = 開啟)
    • "&p=" 暫停(0 = 關閉,1 = 開啟)
    • "&rf=" 渲染標誌。rf 數字由這些單獨標誌的總和組成
      1 = 星星
      2 = 行星
      4 = 星系
      8 = 星座線
      16 = 雲
      32 = 軌道
      64 = 天球網格
      128 = 夜間燈光
      256 = 大氣
      512 = 軌道平滑線
      1024 = 日食陰影
      2048 = 光線傳播 ???
      4096 = 環形陰影
      8192 = 星座邊界
      16384 = 自動星等
      32768 = 彗星尾巴
      65536 = 標記
      131072 = 部分軌跡(尚未實現)
      262144 = 星雲
      524288 = 星團
      1048576 = 球狀星團
      2097152 = 雲的陰影
      4194304 = 銀河網格
      8388608 = 黃道網格
      16777216 = 水平網格
      33554432 = 黃道
    • "&lm=" 標籤標誌。lm 數字由指示顯示的標籤的這些單獨標誌的總和組成
      1 = 星星
      2 = 行星
      4 = 月亮
      8 = 星座
      16 = 星系
      32 = 小行星
      64 = 飛船
      128 = 地點
      256 = 彗星
      512 = 星雲
      1024 = 星團
      2048 = 星座的本地名稱
      4096 = 矮行星
      8192 = 小型衛星
      16384 = 球狀星團
    • "&tsrc=" ???
    • "&ver=3" 用於 Celestia 1.6 及更高版本(目前)
obs [可選]
celestia:seturl() 方法生效的 "觀察者" 物件。
如果沒有指定觀察者,則 seturl 將應用於當前活動檢視。

註釋

  1. Celestia 1.6.01.6.1 的 celURL 型別為 "ver=3"(string:celURL 中的最後一個引數),與早期版本的 celURL 不完全相容。因此,與早期版本的 Celestia 相比,在 Celestia 1.6.01.6.1 中使用 ver=2 celURL 時,此 celestia:seturl() 方法的結果可能會有所不同。
  2. 要從 Celestia 線上獲取 celURL,請按 [Ctrl+C] 或 [Ctrl+Ins] 鍵。這會將 celURL 儲存到計算機的剪貼簿中。要將 celURL 貼上到 CELX 指令碼中,只需將游標定位在 CELX 指令碼中的適當位置,然後按 [Ctrl+V] 鍵。要將其設為 string:celURL,請在其前後加上雙引號。
  3. 要從 CELX 指令碼內部獲取 celURL,必須使用 1.6.1 celestia:geturl() 方法。

示例
將自己定位在珠穆朗瑪峰頂部,觀看一個非常特殊的日出。

obs=celestia:getobserver()
celestia:seturl("cel://SyncOrbit/Sol:Earth/2009-07-21T22:47:04.72721?
x=N1WRszkGAg&y=R5015O+GFA&z=h+mfTNDb2P///////////w&ow=0.551145&ox=0.273737&oy=-
0.643962&oz=0.454554&select=Sol&fov=29.1666&ts=50.0&ltd=0&p=0&rf=20227&lm=1243136&tsrc=0&ver=3", obs) wait(180.0)


返回 celestia 方法索引。


1.6.1 string celestia:geturl([observer:obs])

以 celURL 型別字串形式返回指定觀察者的位置、方向、時間、渲染選項和視野。
有關 celURL 型別字串格式的描述,請參閱 1.6.1 celestia:seturl() 方法。

引數

obs [可選]
celestia:geturl() 方法生效的 "觀察者" 物件。
如果沒有指定觀察者,則會返回活動觀察者的 celURL。

註釋

  1. Celestia 1.6.01.6.1 的 celURL 型別為 "ver=3"(string:celURL 中的最後一個引數),與早期版本的 celURL 不完全相容。因此,與早期版本的 Celestia 相比,在 Celestia 1.6.01.6.1 中使用 ver=2 celURL 時,此 celestia:seturl() 方法的結果可能會有所不同。
  2. 要從 CELX 指令碼內部設定 celURL,必須使用 1.6.1 celestia:seturl() 方法。

示例

obs=celestia:getobserver()
actual_celurl = celestia:geturl(obs)


返回 celestia 方法索引。


settextcolor

[編輯 | 編輯原始碼]

1.6.1 celestia:settextcolor(number:red, number:green, number:blue)

設定 Celestia 訊息和指令碼訊息(即 celestia:print()celestia:flash() 方法)的文字顏色。

引數

red
顏色的 RGB 值的紅色部分必須介於 0 到 1 之間。
green
顏色的 RGB 值的綠色部分必須介於 0 到 1 之間。
blue
顏色的 RGB 值的藍色部分必須介於 0 到 1 之間。

註釋

  1. 當你放大到明亮物體(例如太陽或水星)時,此方法非常有用。當你的螢幕被物體填滿時,標準白色文字訊息非常難以閱讀。在這種情況下,更改文字顏色可能有助於提高文字訊息的可讀性。
  2. 無法在同一文字訊息中更改文字顏色。
  3. 可以使用 1.6.1 celestia:gettextcolor() 方法獲取當前的文字訊息顏色。

示例
將 Celestia 和指令碼訊息的文字顏色設定為綠色

celestia:settextcolor(0.0, 1.0, 0.0)
celestia:flash("This text is printed GREEN", 5.0)
wait(5.0)


返回 celestia 方法索引。


gettextcolor

[編輯 | 編輯原始碼]

1.6.1 number, number, number celestia:gettextcolor()

返回一個三元組數字(介於 0 到 1 之間),它對應於文字訊息顏色的 RGB 值的紅色、綠色、藍色分量。

註釋

  1. 可以使用 1.6.1 celestia:settextcolor() 方法設定文字訊息的顏色。

示例

r, g, b = celestia:gettextcolor()


返回 celestia 方法索引。


runscript

[編輯 | 編輯原始碼]

1.6.1 celestia:runscript(string:scriptname)

在 celx 指令碼末尾新增此命令,可以啟動任何 celx 或 cel 指令碼,一旦原始 celx 指令碼完成。

引數

scriptname
包含要啟動的 celx 或 cel 指令碼名稱的文字字串。

註釋

  1. 此方法使用相對指令碼名稱。
  2. 在 celx 指令碼中,此方法後面始終應加上 wait(0) 命令。
  3. 使用此方法,你可以進行指令碼“鏈”。
  4. 一旦啟動了第二個指令碼,主指令碼就會終止。這意味著 celestia:runscript() 命令下方的所有額外程式碼行都將被忽略。

示例 1
啟動一個名為 "myscriptname.celx" 的 celx 指令碼,該指令碼位於與當前執行指令碼相同的目錄中。

celestia:runscript("myscriptname.celx")
wait(0)

示例 2
指令碼 "myscriptname.celx" 位於一個名為 "myDir2" 的不同目錄中。

celestia:runscript("../mydir2/myscriptname.celx")
wait(0)


返回 celestia 方法索引。


華夏公益教科書