Dialog

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

對話對象允許使用者創建非玩家角色(NPC),玩家可以使用一個選擇列表與其進行對話。對話對象可以插入到像人形的頭部等零件中,然後玩家會看到上面有一個對話泡泡,他們可以單擊以開始對話。位置的創建者可以通過插入 DialogChoice 物件來選擇玩家可以說的選擇。

概要

屬性

方法

活動

屬性

平行讀取

對話框的行為類型決定是否多名玩家可以一次與對話框互動。此特性的預設值為單人玩家。

單人玩家

當對話配置為單一玩家時,只有一名玩家可以一次與它互動。一旦玩家與對話框互動,其他玩家將無法在第一位玩家完成之前啟動對話框。

當玩家與對話框互動時,其他玩家會看到啟動對話的玩家的對話選項以及回應。

多個玩家

當對話設為多個玩家時,任何玩家都可以隨時啟動對話,即使另一名玩家已經啟動了對話。但與單人玩家不同,設為多人玩家的對話框不會向任何人顯示對話選項和回應,只有對話中的玩家可以看到。


local Workspace = game:GetService("Workspace")
local singlePlayerDialog = Instance.new("Dialog")
local singlePlayerPart = Workspace.SinglePlayerPart
singlePlayerDialog.BehaviorType = Enum.DialogBehaviorType.SinglePlayer
singlePlayerDialog.InitialPrompt = "Only one person can interact with me at once."
singlePlayerDialog.Parent = singlePlayerPart
local multiplePlayersDialog = Instance.new("Dialog")
local multiplePlayersPart = Workspace.MultiplePlayersPart
multiplePlayersDialog.BehaviorType = Enum.DialogBehaviorType.MultiplePlayers
multiplePlayersDialog.InitialPrompt = "Any number of players can interact with me at once."
multiplePlayersDialog.Parent = multiplePlayersPart

ConversationDistance

平行讀取

玩家可以從對話的父處到最遠的距離開始對話。

GoodbyeChoiceActive

平行讀取

切換是否顯示再見選項。如果真實,對話框將顯示 Dialog.GoodbyeDialog 的內容作為其他對話選項的最後選項。單擊再見選項將退出對話框。

GoodbyeDialog

平行讀取

設置對話框在聊天結束時顯示給玩家的句子

InUse

平行讀取

如果真實,這個對話框被至少一名玩家使用。

InitialPrompt

平行讀取

設置對話框會向玩家顯示的第一句話,一旦聊天開始。

平行讀取

設置初始對話框顯示的圖示。

平行讀取

設置 NPC 的對話泡泡的顏色。

TriggerDistance

平行讀取

設置對話框可以被觸發的最大距離。

TriggerOffset

平行讀取

設置對話框與對話框父元素親的偏移。

方法

GetCurrentPlayers

Instances

對話框的 GetCurrentPlayers 功能將返回一個列表,其中包含 Player 目前正在使用對話框的玩家。如果沒有使用對話框的玩家,則返回的列表將為空。


返回

Instances

範例程式碼

Dialog:GetCurrentPlayers

local dialog = script.Parent
local function onChoiceSelected(_player, _choice)
local currentPlayers = dialog:GetCurrentPlayers()
print("The current players in the dialog:")
for _, player in ipairs(currentPlayers) do
print(player)
end
end
dialog.DialogChoiceSelected:Connect(onChoiceSelected)

活動

DialogChoiceSelected

當玩家選擇說話時,通過 Dialog 實個體、實例發射。

這個事件只是客戶端,不會在伺服器上發射。它應該連接到 LocalScriptModuleScriptLocalScript 要求的任何一個。

參數

player: Instance
dialogChoice: Instance