I'm working on adding a menu to a lift that the player can use to select which floor they wish to travel to. I had a quick look through the documentation and the forums and managed to generate entries depending on how many floors the lift had in its destination list.
I have a couple of questions regarding the rest of the implementation:
1. I can't seem to delete the entries after the end of the conversation- can't really seem to find any information that specifies how to remove a dialogue entry. Is there a way to do this?
My current code is like this:
Code: Select all
public void AddMenuOptions()
{
var template = Template.FromDefault();
int newLevelID = conversation.dialogueEntries.Max(existingEntry => existingEntry.id);
DialogueEntry menuEntry = conversation.GetDialogueEntry(liftMenuID);
for (int i = 0; i < localWaypoints.Length; i++) //for every floor stored in the lift controller
{
if (i != DialogueLua.GetVariable("LiftPosition").asInt) //if we are not already on this floor, add a dialogue entry
{
newLevelID++;
var newEntry = template.CreateDialogueEntry(newLevelID, conversation.id, "Level " + (newLevelID-1).ToString()); //-1 because id 1 is taken by menu node
newEntry.ActorID = 1;
newEntry.DialogueText = "Level " + (newLevelID - 1).ToString();
conversation.dialogueEntries.Add(newEntry);
var link = new Link(conversation.id, liftMenuID, conversation.id, newEntry.id);
menuEntry.outgoingLinks.Add(link);
}
}
}
public void ResetMenuOptions()
{
for (int i = 2; i < conversation.dialogueEntries.Count; i++) //for every node beyond the menu in the lift conversation
{
DialogueEntry entry = conversation.dialogueEntries[i];
//delete the node?????????????????
}
}
2. I wrote a sequencer command to move the lift to the position the player selected. However, I need to get a reference to the lift controller script which I cannot specify as the listener or the speaker in the conversation due to the conversation being used across multiple instances.
I tried using ConversationStarter.conversant, but got an 'object reference is required for a non-static field, method or property' error. I manually set the conversant in the Dialogue System Trigger component of the lift, using the Start Conversation action. Is there a way around this error? I don't think I should use GameObject.Find because there could be multiple different lifts in the scene.
Thanks for your help!