Lua 腳本:列舉與值
本頁連結到 EliteMobs Lua 方法使用的每個列舉類型的 Spigot Javadocs。在 Lua 程式碼中使用精確的列舉常數名稱(如 "FLAME"、"ZOMBIE"、"STONE")作為字串。
- 拼寫必須與列舉常數名稱完全匹配
- 大小寫通常在內部標準化,但為了安全起見請匹配 Javadoc 的拼寫
- 無效值的處理方式取決於具體方法:有些會記錄警告,有些會傳回
nil或不執行任何操作,具有輸入驗證的 API 則可能引發 Lua 錯誤
Enum Reference
| Enum | Used for | Javadoc |
|---|---|---|
BarColor | Boss bar color | BarColor |
BarStyle | Boss bar style | BarStyle |
EntityEffect | Entity visual effects | EntityEffect |
EntityType | Entity spawning | EntityType |
FireworkEffect.Type | Firework shape | FireworkEffect.Type |
Material | Blocks and items | Material |
Particle | Particle effects | Particle — 舊名稱轉換另見有效粒子清單 |
PotionEffectType | Potion effects | PotionEffectType |
Sound | 音效播放 | Sound |
每個 Lua 音效輔助方法(boss:play_sound_at_self、entity:play_sound_at_entity、world:play_sound_at_location)都會分兩步解析該字串:先嘗試 Spigot Sound 列舉名稱(會轉成大寫,所以 "entity_blaze_shoot" 可用),若失敗則把該字串視為具命名空間的音效鍵(會轉成小寫,所以 "entity.blaze.shoot" 與你自己資源包的鍵 "mypack:boss.roar" 都可用)。
這代表你不必再挑選格式 —— 但兩種形式的拼字錯誤都會被靜默忽略,因為後備路徑無法分辨錯誤的列舉名稱與一個單純尚未安裝的自訂資源包音效。
Non-Spigot Values
Zone shapes
Used by native zone definitions (kind field) and script utility zone specs (shape field).
Native (kind) | Script Utility (shape) |
|---|---|
sphere | SPHERE |
dome | DOME |
cylinder | CYLINDER |
cuboid | CUBOID |
cone | CONE |
static_ray | STATIC_RAY |
rotating_ray | ROTATING_RAY |
translating_ray | TRANSLATING_RAY |
Entity filters
Used by context.zones and context.entities query options. 不區分大小寫,且每個都有複數別名。
| Filter | Matches |
|---|---|
player / players | Players only |
elite / elites | Elite mobs only |
mob / mobs | Non-player living entities(包含精英) |
living | All living entities,包含玩家(預設) |
all / entities | 所有實體,包含非生物實體。僅 context.entities:get_nearby_entities 會辨識 |
非上述字串的任何值都會退回為 living 的行為而不會報錯,因此像 "playr" 這樣的拼字錯誤會靜默地傳回所有生物實體。
context.script:zone({...}) 使用的是另一組大寫的篩選條件(PLAYER、ELITE、LIVING),因為它執行的是 EliteScript 引擎。
Weather values
Used by context.world:set_weather(weather).
| Value | Effect |
|---|---|
CLEAR | Clear skies |
RAIN | Rain |
THUNDER | Thunderstorm |
Target types
Used by context.script:target() specs.
| Value | Resolves to |
|---|---|
SELF | The boss entity |
SELF_SPAWN | The boss's spawn location |
DIRECT_TARGET | The entity involved in the current event |
NEARBY_PLAYERS | Players within range of the boss |
NEARBY_MOBS | Non-player mobs within range |
NEARBY_ELITES | Elite mobs within range |
ALL_PLAYERS | All online players |
WORLD_PLAYERS | All players in the boss's world |
ZONE_FULL | Entities/locations inside a zone volume |
ZONE_BORDER | Entities/locations on a zone border |
LOCATION | A specific location from the spec's location field |
LOCATIONS | Several specific locations from the spec's locations list |
LANDING_LOCATION | Where a falling block or summoned entity landed |
ACTION_TARGET | Inherits the targets of the surrounding EliteScript action |
INHERIT_SCRIPT_TARGET | Inherits the target of the calling EliteScript |
INHERIT_SCRIPT_ZONE_FULL | Inside the calling EliteScript's zone |
INHERIT_SCRIPT_ZONE_BORDER | On the border of the calling EliteScript's zone |
最後四項只有在有外圍 EliteScript 可供繼承時才會解析,因此從 Lua 使用它們實際意義不大。完整語意請參閱 EliteScript 目標 —— context.script 使用的正是那套實作。
