BotDialogEvent¶
Triggered when a bot gets a dialog, the screen that a command
like /dialog show opens for a player.
A bot has no screen, so this event is how a spell knows that a bot was shown a dialog, for
example to play-test the form of a mini-game: does the player get it, and does each button do
what it says. Bot.dialog tells the same at any later time, and Bot:clickDialog presses a
button. The event also fires for a dialog that a button opens by itself, without the server.
This event cannot be canceled.
Note: Dialogs need Minecraft 1.21.6 or newer. Before that, this event never fires.
Example: See what a bot is shown
local queue = spell:collect("BotDialogEvent")
local bot = Bot:spawn("Bob", spell.pos)
spell:execute("/dialog show Bob minecraft:server_links")
local evt = queue:next(20) --[[@as BotDialogEvent?]]
if evt then
print(evt.bot.name .. " sees " .. evt.dialog.title)
print("Buttons: " .. table.concat(evt.dialog.buttons, ", "))
end
Fields¶
bot: Bot — Read-Only¶
A reference to the bot that got the dialog.
dialog: BotDialog — Read-Only¶
A copy of what a player would see of the dialog.
name: string — Read-Only¶
The name of the event.