Lua-Scripting: Welt & Umgebung
Diese Seite behandelt sämtliche Methoden, die auf context.world, context.vectors, context.settings und context.event verfügbar sind. Damit können deine Lua-Kräfte mit der Minecraft-Welt interagieren -- Entitäten spawnen, Effekte abspielen, Blöcke abfragen und mehr. Wenn du neu bei Lua-Kräften bist, beginne zuerst mit Erste Schritte.
EliteMobs-Bosskräfte verwenden die Lua-Sandbox von MagmaCore wieder. Das context.world eines Bosses geht von der gemeinsamen MagmaCore-Welttabelle aus, sodass allgemeine Koordinaten-Helfer wie get_block_at(...), set_block_at(...) und spawn_particle(...) weiterhin verfügbar sind. Diese Seite konzentriert sich auf die bossspezifischen Ergänzungen und Überschreibungen von EliteMobs für context.world, context.vectors, context.settings und context.event. Die allgemeine Welt-API findest du unter MagmaCore Lua Scripting Engine.
context.world
Die Welttabelle stellt Methoden bereit, um Entitäten zu spawnen, Effekte abzuspielen, Blöcke zu verändern und den Weltzustand zu ändern. Alle Methoden werden mit der Doppelpunkt-Syntax aufgerufen (world:method()).
world:spawn_particle_at_location(location, particleSpec)
Erzeugt Partikel an einer Position. Das zweite Argument kann ein einfacher Partikelname als Zeichenkette oder eine vollständige Partikel-Spezifikationstabelle für erweiterte Kontrolle sein.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo die Partikel erzeugt werden |
particleSpec | Zeichenkette oder Tabelle | Partikelname oder eine Partikel-Spezifikationstabelle (siehe unten) |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Simple particle by name
context.world:spawn_particle_at_location(context.boss:get_location(), "FLAME")
-- Full particle spec table with red dust
context.world:spawn_particle_at_location(context.boss:get_location(), {
particle = "DUST",
amount = 10,
x = 0.5,
y = 0.5,
z = 0.5,
speed = 0.02,
red = 255,
green = 0,
blue = 0,
})
end
}
Format der Partikel-Spezifikationstabelle
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
particle | Zeichenkette | erforderlich | Partikelname |
amount | int | 1 | Anzahl der Partikel |
x, y, z | Zahl | 0 | Streuung/Versatz je Achse |
speed | Zahl | 0 | Partikelgeschwindigkeit |
red, green, blue | int | 255 | RGB-Farbe für DUST und DUST_COLOR_TRANSITION |
toRed, toGreen, toBlue | int | 255 | Zielfarbe des Übergangs für DUST_COLOR_TRANSITION |
Für DUST_COLOR_TRANSITION kannst du auch snake_case-Schlüssel verwenden: to_red, to_green, to_blue.
Anders als bei EliteScript-YAML-Konfigurationen unterstützen Lua-Partikelnamen keine Umwandlung alter Partikelnamen. Du musst die aktuellen Namen der Spigot-API verwenden (z. B. FIREWORK statt FIREWORKS_SPARK, SMOKE statt SMOKE_NORMAL, DUST statt REDSTONE). Die vollständige Liste der aktuellen Namen und ihrer alten Entsprechungen findest du in der Liste gültiger Partikel.
world:play_sound_at_location(location, sound, volume, pitch)
Spielt einen Klang an einer Position ab.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | Location-Tabelle | Wo der Klang abgespielt wird | |
sound | Zeichenkette | Minecraft-Klangschlüssel (z. B. "entity.blaze.shoot") oder ein Spigot-Sound-Enum-Name. Ressourcenpaket-Schlüssel funktionieren ebenfalls. | |
volume | Zahl | 1.0 | Lautstärke |
pitch | Zahl | 1.0 | Tonhöhe |
Beispiel
return {
api_version = 1,
on_spawn = function(context)
context.world:play_sound_at_location(
context.boss:get_location(),
"entity.wither.spawn",
1.0,
0.5
)
end
}
world:strike_lightning_at_location(location)
Lässt an einer Position einen Blitz einschlagen (visuell und schadensverursachend).
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo der Blitz einschlägt |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("lightning", 100) then return end
context.world:strike_lightning_at_location(context.player:get_location())
context.player:send_message("&eA bolt of lightning strikes you!")
end
}
world:spawn_entity_at_location(entityType, location, options)
Spawnt eine gewöhnliche Minecraft-Entität.
| Parameter | Typ | Hinweise |
|---|---|---|
entityType | Zeichenkette | Entitätstyp-Name (z. B. "FIREBALL", "ARROW") |
location | Location-Tabelle | Wo gespawnt wird |
options | Tabelle (optional) | Spawn-Optionen (siehe unten) |
Spawn-Optionen für Entitäten
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
velocity | Vektortabelle | nil | Anfangsgeschwindigkeit {x, y, z} |
effect | Zeichenkette | nil | EntityEffect, der beim Spawnen abgespielt wird |
duration | int | 0 | Nach so vielen Ticks automatisch entfernen (0 = nie) |
on_land | Funktion | nil | Rückruf, wenn die Entität auf dem Boden landet |
max_ticks | int | 6000 | Maximale Anzahl an Ticks zur Überwachung, bevor der on_land-Rückruf erzwungen wird |
Gibt eine Entitäts-Wrappertabelle zurück. Nicht-lebende Entitäten (FIREBALL, ARROW, TNT, ...) kommen als
Referenz-Wrapper für nicht-lebende Entitäten zurück, bei denen is_valid() eine Methode ist.
Lebende Entitätstypen (ZOMBIE, GIANT, ...) kommen stattdessen als vollwertiger
Wrapper für lebende Entitäten zurück, bei dem is_valid ein boolesches Feld ist -- ein Aufruf von
entity:is_valid() auf einem solchen Wrapper löst attempt to call a boolean value aus.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("fireball_spawn", 100) then return end
-- Spawn a fireball aimed at the player
local boss_loc = context.boss:get_location()
local dir = context.vectors.get_vector_between_locations(boss_loc, context.player:get_location())
dir = context.vectors.normalize_vector(dir)
context.world:spawn_entity_at_location("FIREBALL", boss_loc, {
velocity = { x = dir.x * 2, y = dir.y * 2, z = dir.z * 2 },
duration = 100,
})
end
}
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Spawn a primed TNT with a landing callback
context.world:spawn_entity_at_location("TNT", context.boss:get_location(), {
velocity = { x = 0, y = 1.5, z = 0 },
on_land = function(land_location, entity_ref)
context.world:spawn_particle_at_location(land_location, {
particle = "EXPLOSION_EMITTER",
amount = 1,
})
end,
})
end
}
world:spawn_falling_block_at_location(location, material, options)
Spawnt eine fallende Block-Entität.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo gespawnt wird |
material | Zeichenkette | Materialname (z. B. "STONE", "MAGMA_BLOCK") |
options | Tabelle (optional) | Spawn-Optionen (siehe unten) |
Optionen für fallende Blöcke
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
velocity | Vektortabelle | nil | Anfangsgeschwindigkeit {x, y, z} |
drop_item | boolean | false | Ob der Block als Gegenstand fällt |
hurt_entities | boolean | false | Ob der Block Entitäten schadet, auf denen er landet |
on_land | Funktion | nil | Rückruf function(land_location, entity_ref), wenn der Block landet |
Gibt eine Entitätsreferenz-Tabelle zurück.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Rain magma blocks from above
local loc = context.boss:get_location()
for i = 1, 5 do
local offset_loc = {
x = loc.x + math.random(-3, 3),
y = loc.y + 10,
z = loc.z + math.random(-3, 3),
world = loc.world
}
context.world:spawn_falling_block_at_location(offset_loc, "MAGMA_BLOCK", {
velocity = { x = 0, y = -0.5, z = 0 },
hurt_entities = true,
on_land = function(land_location, entity_ref)
context.world:spawn_particle_at_location(land_location, { particle = "LAVA", amount = 8 })
end,
})
end
end
}
world:spawn_custom_boss_at_location(filename, location, options)
Spawnt einen benutzerdefinierten EliteMobs-Boss aus einer Konfigurationsdatei.
| Parameter | Typ | Hinweise |
|---|---|---|
filename | Zeichenkette | Dateiname der Boss-Konfiguration (z. B. "my_boss.yml") |
location | Location-Tabelle | Wo gespawnt wird |
options | Tabelle (optional) | Spawn-Optionen (siehe unten) |
Spawn-Optionen für benutzerdefinierte Bosse
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
level | int | Bosslevel | Überschreibt das Level des gespawnten Bosses |
silent | boolean | false | Unterdrückt Spawn-Nachrichten |
velocity | Vektortabelle | nil | Anfangsgeschwindigkeit |
add_as_reinforcement | boolean | false | Als Verstärkung des aktuellen Bosses registrieren |
Gibt eine Entitäts-Wrappertabelle zurück oder nil, falls der Boss nicht erstellt werden konnte.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local minion = context.world:spawn_custom_boss_at_location(
"skeleton_minion.yml",
context.boss:get_location(),
{ level = 10, add_as_reinforcement = true }
)
if minion ~= nil then
context.boss:send_message("&cMinions, arise!")
end
end
}
world:spawn_boss_at_location(filename, location, level)
Eine einfachere Methode zum Spawnen von Bossen. Spawnt einen benutzerdefinierten Boss an einer Position mit optionalem Level.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
filename | Zeichenkette | Dateiname der Boss-Konfiguration | |
location | Location-Tabelle | Bossposition | Wo gespawnt wird (optional, standardmäßig die Bossposition) |
level | int | Bosslevel | Überschreibt das Spawn-Level (optional) |
Gibt eine Entitäts-Wrappertabelle zurück oder nil.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.world:spawn_boss_at_location("zombie_guard.yml", context.boss:get_location(), 5)
context.boss:send_message("&cGuards, defend me!")
end
}
world:spawn_reinforcement_at_location(filename, location, level, velocity)
Spawnt eine Verstärkung, die vom Verstärkungssystem von EliteMobs verfolgt wird.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
filename | Zeichenkette | Dateiname der Boss-Konfiguration | |
location | Location-Tabelle | Wo gespawnt wird | |
level | int | 0 | Level der Verstärkung. Bei 0 bestimmt der Beschwörungs-Helfer sein Standardverhalten für das Level. |
velocity | Vektortabelle | nil | Anfangsgeschwindigkeit (optional) |
Gibt eine Entitäts-Wrappertabelle zurück oder nil.
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.world:spawn_reinforcement_at_location(
"necro_skeleton.yml",
context.boss:get_location(),
0,
{ x = 0, y = 0.5, z = 0 }
)
context.boss:send_message("&5Rise, my servant!")
end
}
world:spawn_fireworks_at_location(location, spec)
Spawnt eine Feuerwerks-Entität mit voller Kontrolle über die Effekte.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo gespawnt wird |
spec | Tabelle | Feuerwerks-Spezifikation (siehe unten) |
Feuerwerks-Spezifikationstabelle
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
power | int | 1 | Flugkraft (Höhe) |
velocity | Vektortabelle | nil | Anfangsgeschwindigkeit |
shot_at_angle | boolean | true | Ob das Feuerwerk in einem Winkel abgeschossen wird (wird verwendet, wenn velocity gesetzt ist) |
effects | Tabelle aus Tabellen | nil | Array von Feuerwerkseffekt-Spezifikationen. Wird sie weggelassen, gilt die oberste Spezifikation als einzelner Effekt. |
Spezifikation eines Feuerwerkseffekts
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
type | Zeichenkette | "BALL_LARGE" | "BALL", "BALL_LARGE", "STAR", "BURST", "CREEPER" |
flicker | boolean | true | Funkeleffekt |
trail | boolean | true | Schweifeffekt |
colors | Tabelle | nil | Array von Farbnamen oder {red, green, blue}-Tabellen |
fade_colors | Tabelle | nil | Array von Verblassfarben-Namen oder {red, green, blue}-Tabellen |
Farbnamen: "WHITE", "SILVER", "GRAY", "BLACK", "RED", "MAROON", "YELLOW", "OLIVE", "LIME", "GREEN", "AQUA", "TEAL", "BLUE", "NAVY", "FUCHSIA", "PURPLE", "ORANGE"
Gibt eine Entitätsreferenz-Tabelle zurück. Du kannst darauf :detonate() aufrufen, um die sofortige Detonation zu erzwingen.
Beispiel
return {
api_version = 1,
on_spawn = function(context)
local fw = context.world:spawn_fireworks_at_location(context.boss:get_location(), {
power = 0,
effects = {
{
type = "STAR",
flicker = true,
trail = true,
colors = { "RED", "ORANGE", { red = 255, green = 200, blue = 0 } },
fade_colors = { "YELLOW" },
},
},
})
-- Detonate immediately for a visual burst
context.scheduler:run_after(1, function()
fw:detonate()
end)
end
}
world:spawn_splash_potion_at_location(location, spec)
Spawnt eine geworfene Wurftrank-Entität.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo gespawnt wird |
spec | Tabelle | Trank-Spezifikation (siehe unten) |
Spezifikationstabelle für Wurftränke
| Schlüssel | Typ | Hinweise |
|---|---|---|
velocity | Vektortabelle | Anfangsgeschwindigkeit des geworfenen Tranks |
effects | Tabelle aus Tabellen | Array von Trankeffekt-Spezifikationen |
Spezifikation eines Trankeffekts
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
type | Zeichenkette | erforderlich | Name des Trankeffekttyps (z. B. "SLOWNESS", "POISON") |
duration | int | 0 | Dauer in Ticks |
amplifier | int | 0 | Effektverstärker (0 = Stufe I) |
overwrite | boolean | true | Ob bestehende Effekte desselben Typs überschrieben werden |
Gibt eine Entitätsreferenz-Tabelle zurück oder nil.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("potion_throw", 200) then return end
local dir = context.vectors.get_vector_between_locations(
context.boss:get_location(),
context.player:get_location()
)
dir = context.vectors.normalize_vector(dir)
context.world:spawn_splash_potion_at_location(context.boss:get_location(), {
velocity = { x = dir.x * 1.5, y = 0.5, z = dir.z * 1.5 },
effects = {
{ type = "SLOWNESS", duration = 100, amplifier = 1 },
{ type = "WEAKNESS", duration = 60, amplifier = 0 },
},
})
end
}
world:place_temporary_block_at_location(location, material, duration, requireAir)
Platziert einen temporären Block, der nach Ablauf einer Dauer automatisch zurückgesetzt wird.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | Location-Tabelle | Wo platziert wird | |
material | Zeichenkette | Materialname | |
duration | int | 0 | Ticks, bis der Block zurückgesetzt wird (0 = dauerhaft) |
requireAir | boolean | false | Bei true wird nur platziert, wenn der Block derzeit Luft ist |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Create a temporary ice floor under the boss
local loc = context.boss:get_location()
for dx = -2, 2 do
for dz = -2, 2 do
context.world:place_temporary_block_at_location(
{ x = loc.x + dx, y = loc.y - 1, z = loc.z + dz, world = loc.world },
"PACKED_ICE",
100,
false
)
end
end
end
}
world:set_block_at_location(location, material, requireAir)
Setzt einen Block dauerhaft. Verwende place_temporary_block_at_location, wenn er zurückgesetzt werden soll.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | Location-Tabelle | Wo platziert wird | |
material | Zeichenkette | Materialname | |
requireAir | boolean | false | Bei true wird nur platziert, wenn der Block derzeit Luft ist |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Place fire at the boss's location
context.world:set_block_at_location(context.boss:get_location(), "FIRE", true)
end
}
world:get_block_type_at_location(location)
Gibt den Materialnamen des Blocks an einer Position als Zeichenkette zurück.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local block_type = context.world:get_block_type_at_location(context.boss:get_location())
if block_type == "WATER" then
context.boss:send_message("&bThe boss is empowered by water!")
context.boss:apply_potion_effect("SPEED", 200, 1)
end
end
}
world:get_highest_block_y_at_location(location)
Gibt die Y-Koordinate des höchsten Nicht-Luft-Blocks an der angegebenen X/Z-Position zurück.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position (X und Z werden verwendet) |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("skyport", 200) then return end
local loc = context.player:get_location()
local ground_y = context.world:get_highest_block_y_at_location(loc)
-- Teleport the player to the surface
context.player:teleport_to_location({
x = loc.x, y = ground_y + 1, z = loc.z, world = loc.world
})
context.player:send_message("&eYou are teleported to the surface!")
end
}
world:get_blast_resistance_at_location(location)
Gibt den Explosionswiderstand des Blocks an einer Position als Zahl zurück.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local resistance = context.world:get_blast_resistance_at_location(context.boss:get_location())
context.log:info("Blast resistance at boss: " .. resistance)
end
}
world:is_air_at_location(location)
Gibt true zurück, wenn der Block an der Position Luft ist.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local loc = context.boss:get_location()
local above = { x = loc.x, y = loc.y + 2, z = loc.z, world = loc.world }
if context.world:is_air_at_location(above) then
-- There is space above the boss, launch upward
context.boss:set_velocity_vector({ x = 0, y = 1.5, z = 0 })
end
end
}
world:is_passable_at_location(location)
Gibt true zurück, wenn der Block an der Position passierbar ist (Entitäten können hindurchgehen).
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
if context.world:is_passable_at_location(context.boss:get_location()) then
context.log:info("Boss is in a passable block")
end
end
}
world:is_passthrough_at_location(location)
Gibt true zurück, wenn der Block an der Position nicht fest ist (ähnlich wie passierbar, aber basierend auf der Festkörper-Prüfung).
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local loc = context.boss:get_location()
local above = { x = loc.x, y = loc.y + 1, z = loc.z, world = loc.world }
if context.world:is_passthrough_at_location(above) then
context.log:info("Boss can move upward")
end
end
}
world:is_on_floor_at_location(location)
Gibt true zurück, wenn der Block an der Position nicht fest ist UND der Block darunter fest ist (die Position "steht" also auf dem Boden).
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
if context.world:is_on_floor_at_location(context.boss:get_location()) then
context.boss:send_message("&aThe boss slams the ground!")
context.world:spawn_particle_at_location(context.boss:get_location(), {
particle = "CLOUD",
amount = 30,
})
end
end
}
world:is_standing_on_material(location, material)
Gibt true zurück, wenn der Block direkt unterhalb der Position dem angegebenen Material entspricht.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Abzufragende Position |
material | Zeichenkette | Zu prüfender Materialname |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if context.world:is_standing_on_material(context.player:get_location(), "SOUL_SAND") then
context.player:send_message("&8The soul sand saps your strength!")
context.player:apply_potion_effect("SLOWNESS", 60, 2)
end
end
}
world:set_world_time(time) / world:set_world_time(location, time)
Setzt die Weltzeit. Optional kannst du eine Position übergeben, um festzulegen, welche Welt gemeint ist.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle (optional) | Welche Welt betroffen ist. Standardmäßig die Bosswelt. |
time | int | Weltzeit in Ticks (0 = Morgengrauen, 6000 = Mittag, 13000 = Nacht, 18000 = Mitternacht) |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Set to midnight when combat starts
context.world:set_world_time(18000)
context.boss:send_message("&8Darkness falls...")
end
}
world:set_world_weather(weather, duration) / world:set_world_weather(location, weather, duration)
Setzt das Wetter in der Bosswelt.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | Location-Tabelle (optional) | Bosswelt | Welche Welt betroffen ist |
weather | Zeichenkette | "CLEAR", "RAIN" (oder "PRECIPITATION"), "THUNDER" | |
duration | int | 6000 | Wetterdauer in Ticks |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Start a thunderstorm for 200 ticks
context.world:set_world_weather("THUNDER", 200)
context.boss:send_message("&eA storm gathers!")
end
}
world:generate_fake_explosion(blockLocations, sourceLocation)
Erzeugt eine visuelle Schein-Explosion über das Explosions-Regenerationssystem von EliteMobs (Blöcke zerbrechen und regenerieren sich).
| Parameter | Typ | Hinweise |
|---|---|---|
blockLocations | Tabelle aus Location-Tabellen | Array von Blockpositionen, die "explodieren" sollen |
sourceLocation | Location-Tabelle (optional) | Explosionsquelle für Richtungsberechnungen |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
local loc = context.boss:get_location()
local blocks = {}
for dx = -1, 1 do
for dz = -1, 1 do
table.insert(blocks, { x = loc.x + dx, y = loc.y, z = loc.z + dz, world = loc.world })
end
end
context.world:generate_fake_explosion(blocks, loc)
end
}
world:run_console_command(command)
Führt einen Konsolenbefehl als Server aus.
| Parameter | Typ | Hinweise |
|---|---|---|
command | Zeichenkette | Der auszuführende Befehl (ohne führenden /) |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.world:run_console_command("say The boss has entered phase 2!")
end
}
world:run_empowered_lightning_task_at_location(location)
Führt die visuelle Aufgabe für verstärkte Blitze aus (wird von Enderdrachen-Kräften genutzt). Das erzeugt einen dramatischeren Blitzeinschlag mit zusätzlichen Effekten.
| Parameter | Typ | Hinweise |
|---|---|---|
location | Location-Tabelle | Wo der Blitz einschlägt |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
context.world:run_empowered_lightning_task_at_location(context.boss:get_location())
context.boss:send_message("&eFeel the power of the storm!")
end
}
world:spawn_fake_gold_nugget_at_location(location, velocity, hasGravity)
Spawnt ein Schein-Goldklumpen-Projektil, das vom Bullet-Hell-System verwendet wird.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
location | Location-Tabelle | Spawn-Position | |
velocity | Vektortabelle | Anfangsgeschwindigkeit | |
hasGravity | boolean | false | Ob das Projektil der Schwerkraft unterliegt |
Gibt eine Schein-Projektiltabelle mit den Methoden get_location(), set_gravity(bool), remove() und is_removed() zurück.
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("nugget", 60) then return end
local dir = context.vectors.get_vector_between_locations(
context.boss:get_location(),
context.player:get_location()
)
dir = context.vectors.normalize_vector(dir)
context.world:spawn_fake_gold_nugget_at_location(
context.boss:get_location(),
{ x = dir.x, y = dir.y, z = dir.z }
)
end
}
world:run_fake_gold_nugget_damage(projectiles)
Verarbeitet den Schaden einer Tabelle von Schein-Goldklumpen-Projektilen gegen nahegelegene Entitäten.
| Parameter | Typ | Hinweise |
|---|---|---|
projectiles | Tabelle | Array von Schein-Projektiltabellen aus spawn_fake_gold_nugget_at_location |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
-- Spawn some projectiles and store them
context.state.active_projectiles = {}
local loc = context.boss:get_location()
for i = 1, 5 do
local angle = (i / 5) * math.pi * 2
local nugget = context.world:spawn_fake_gold_nugget_at_location(
loc,
{ x = math.cos(angle) * 0.5, y = 0.3, z = math.sin(angle) * 0.5 }
)
table.insert(context.state.active_projectiles, nugget)
end
-- Process damage each tick for 3 seconds
local task_id
task_id = context.scheduler:run_every(1, function(tick_context)
tick_context.world:run_fake_gold_nugget_damage(tick_context.state.active_projectiles)
end)
context.scheduler:run_after(60, function(later_context)
later_context.scheduler:cancel_task(task_id)
end)
end
}
world:generate_player_loot(times)
Erzeugt Beute für Spieler, die dem Boss Schaden zugefügt haben.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
times | int | 1 | Anzahl der Beutewürfe |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
local pct = context.boss:get_health() / context.boss:get_maximum_health()
if pct < 0.5 and not context.boss:has_tag("bonus_loot") then
context.boss:add_tag("bonus_loot")
context.world:generate_player_loot(2)
context.boss:send_message("&6Bonus loot drops!")
end
end
}
world:drop_bonus_coins(multiplier)
Lässt Bonusmünzen für alle Spieler fallen, die zum Schaden am Boss beigetragen haben.
| Parameter | Typ | Standard | Hinweise |
|---|---|---|---|
multiplier | Zahl | 2.0 | Multiplikator für die Münzmenge |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
local pct = context.boss:get_health() / context.boss:get_maximum_health()
if pct < 0.25 and not context.boss:has_tag("bonus_coins") then
context.boss:add_tag("bonus_coins")
context.world:drop_bonus_coins(3.0)
context.boss:send_message("&6Gold spills everywhere!")
end
end
}
context.vectors
Helfer für Vektorrechnung. Diese werden als gewöhnliche Funktionen aufgerufen (Punktsyntax), nicht als Methoden.
| Methode | Gibt zurück | Hinweise |
|---|---|---|
vectors.get_vector_between_locations(loc1, loc2[, options]) | Vektortabelle | Richtung von loc1 nach loc2 |
vectors.normalize_vector(vec) | Vektortabelle | Gibt einen Vektor der Länge 1 zurück |
vectors.rotate_vector(vec, pitch, yaw) | Vektortabelle | Dreht einen Vektor um Pitch- und Yaw-Grad |
Alle Vektortabellen haben die Felder x, y, z.
vectors.get_vector_between_locations(loc1, loc2, options)
| Parameter | Typ | Hinweise |
|---|---|---|
loc1 | Location-Tabelle | Startpunkt |
loc2 | Location-Tabelle | Endpunkt |
options | Tabelle (optional) | Optionen zur Nachbearbeitung (siehe unten) |
Vektor-Optionen
| Schlüssel | Typ | Standard | Hinweise |
|---|---|---|---|
normalize | boolean | false | Normalisiert den resultierenden Vektor |
multiplier | Zahl | 1.0 | Skaliert den Vektor |
offset | Vektortabelle | nil | Fügt einen Versatzvektor hinzu |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("dash", 100) then return end
-- Compute a normalized direction from boss to player, scaled to speed 2
local dir = context.vectors.get_vector_between_locations(
context.boss:get_location(),
context.player:get_location(),
{ normalize = true, multiplier = 2.0 }
)
-- Launch the boss toward the player
context.boss:set_velocity_vector(dir)
end
}
vectors.normalize_vector(vec)
| Parameter | Typ | Hinweise |
|---|---|---|
vec | Vektortabelle | Eingabevektor |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
local raw = context.vectors.get_vector_between_locations(
context.boss:get_location(),
context.player:get_location()
)
local unit = context.vectors.normalize_vector(raw)
context.log:info("Direction: " .. unit.x .. ", " .. unit.y .. ", " .. unit.z)
end
}
vectors.rotate_vector(vec, pitch, yaw)
| Parameter | Typ | Hinweise |
|---|---|---|
vec | Vektortabelle | Eingabevektor |
pitch | Zahl | Drehung um die X-Achse in Grad |
yaw | Zahl | Drehung um die Y-Achse in Grad |
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.player == nil then return end
if not context.cooldowns:check_local("spread_shot", 100) then return end
local forward = context.vectors.normalize_vector(
context.vectors.get_vector_between_locations(
context.boss:get_location(),
context.player:get_location()
)
)
-- Fire three fireballs in a spread pattern
for _, yaw_offset in ipairs({ -30, 0, 30 }) do
local dir = context.vectors.rotate_vector(forward, 0, yaw_offset)
context.boss:summon_projectile(
"FIREBALL",
context.boss:get_eye_location(),
{
x = context.boss:get_location().x + dir.x * 10,
y = context.boss:get_location().y + dir.y * 10,
z = context.boss:get_location().z + dir.z * 10,
world = context.boss:get_location().world
},
1.0
)
end
end
}
Du kannst eine Streuung von Richtungen erzeugen, indem du einen Basisvektor in einer Schleife drehst:
local base = context.vectors.normalize_vector(
context.vectors.get_vector_between_locations(boss_loc, target_loc)
)
for angle = 0, 360, 30 do
local dir = context.vectors.rotate_vector(base, 0, angle)
-- Use dir for spawning projectiles in a ring
end
context.settings
Nur-Lese-Zugriff auf kraftbezogene Konfigurationswerte.
| Methode | Gibt zurück | Hinweise |
|---|---|---|
settings:warning_visual_effects_enabled() | boolean | Ob visuelle Warneffekte in den Mob-Kampfeinstellungen aktiviert sind |
Beispiel
return {
api_version = 1,
on_enter_combat = function(context)
if context.settings:warning_visual_effects_enabled() then
context.world:spawn_particle_at_location(context.boss:get_location(), {
particle = "DUST",
amount = 20,
red = 255, green = 0, blue = 0,
})
end
end
}
context.event
Ereignisdaten für den aktuellen Hook. Welche Felder verfügbar sind, hängt davon ab, welcher Hook den Aufruf ausgelöst hat.
| Feld oder Methode | Verfügbar bei | Hinweise |
|---|---|---|
event.damage_amount | Schadens-Hooks | Der aktuelle Schadenswert (Momentaufnahme zum Zeitpunkt des Aufrufs) |
event.damage_cause | Schadens-Hooks | Name des Bukkit-DamageCause-Enums (z. B. "ENTITY_ATTACK") |
event.cancel_event() | Abbrechbare Ereignisse | Bricht das Ereignis ab |
event.set_damage_amount(value) | Hooks auf Basis von EliteDamageEvent | Setzt den Schaden direkt |
event.multiply_damage_amount(multiplier) | Hooks auf Basis von EliteDamageEvent | Multipliziert den aktuellen Schaden |
event.damager | Schadensereignisse mit einer schädigenden Entität | Entitätsreferenz-Wrapper für den Schadensverursacher |
event.projectile | Schadensereignisse, bei denen der Verursacher ein Projektil ist | Entitätsreferenz-Wrapper des Projektils |
event.spawn_reason | on_spawn | Name des Spawn-Grund-Enums |
event.entity | on_death, Zonenereignisse | Der betreffende Entitäts-Wrapper |
Beispiel: Eingehenden Schaden halbieren
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.event ~= nil then
local dmg = context.event.damage_amount
context.log:info("Boss took " .. dmg .. " damage, halving it")
context.event.multiply_damage_amount(0.5)
end
end
}
Beispiel: Schaden von Projektilen abbrechen
Beispiel
return {
api_version = 1,
on_boss_damaged_by_player = function(context)
if context.event ~= nil and context.event.damage_cause == "PROJECTILE" then
context.event.cancel_event()
if context.player ~= nil then
context.player:send_message("&cThe boss deflects your projectile!")
end
end
end
}
Beispiel: Schadensursache auslesen
Beispiel
return {
api_version = 1,
on_player_damaged_by_boss = function(context)
if context.event ~= nil then
context.log:info("Damage cause: " .. (context.event.damage_cause or "unknown"))
end
end
}
damage_amountist eine Momentaufnahme. Der Wert wird nach dem Aufruf vonset_damage_amount()odermultiply_damage_amount()nicht automatisch aktualisiert.- Innerhalb geplanter Rückrufe ist
context.eventgleichnil. Verwende Ereignis-Hooks, um Ereignisse zu verändern.
