i am trying to make basic nodes for dialogue that can execute functions after the dialogue finishes, (practical use cases include shops, making enemies attack you after you finish talking to them, etc.) but when i tried to make it, all it did was provide the dreaded “script timeout” error. i don’t know why this is happening, and any help would be appreciated.
-- id table
local idTable = {
"Node1",
"Node2",
"Node3",
}
-- dialogue nodes
local dialogueNodes = {
Node1 = {
text = "this is node 1.",
nextNode = "node2",
action = function()
print("executing action for node 1.")
end
},
Node2 = {
text = "this is node 2.",
nextNode = "node3",
action = function()
print("executing action for node 2.")
end
},
Node3 = {
text = "this is node 3.",
nextNode = "node1", -- loop back to node1 for demonstration purposes
action = function()
print("executing action for node 3.")
end
},
}
local function startDialogue(startingNode)
local currentNode = dialogueNodes[startingNode]
while currentNode do
print(currentNode.text)
if currentNode.action then
currentNode.action()
end
currentNode = dialogueNodes[currentNode.nextNode]
end
end
startDialogue("node1")