diff --git a/Assets/Fungus/Narrative/Scripts/Conversation.cs b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs similarity index 99% rename from Assets/Fungus/Narrative/Scripts/Conversation.cs rename to Assets/Fungus/Narrative/Scripts/ConversationManager.cs index 8e981d20..eefa8b4c 100644 --- a/Assets/Fungus/Narrative/Scripts/Conversation.cs +++ b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs @@ -6,7 +6,7 @@ using UnityEngine; namespace Fungus { - public class Conversation + public class ConversationManager { protected struct ConversationItem { @@ -20,7 +20,7 @@ namespace Fungus protected bool exitSayWait; - public Conversation () + public void PopulateCharacterCache() { // cache characters for faster lookup characters = UnityEngine.Object.FindObjectsOfType(); diff --git a/Assets/Fungus/Narrative/Scripts/Conversation.cs.meta b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs.meta similarity index 100% rename from Assets/Fungus/Narrative/Scripts/Conversation.cs.meta rename to Assets/Fungus/Narrative/Scripts/ConversationManager.cs.meta diff --git a/Assets/Fungus/Narrative/Scripts/Stage.cs b/Assets/Fungus/Narrative/Scripts/Stage.cs index dabc0424..d8e7d642 100644 --- a/Assets/Fungus/Narrative/Scripts/Stage.cs +++ b/Assets/Fungus/Narrative/Scripts/Stage.cs @@ -82,6 +82,17 @@ namespace Fungus } return null; } + + public static Stage GetActiveStage() + { + if (Stage.activeStages == null || + Stage.activeStages.Count == 0) + { + return null; + } + + return Stage.activeStages[0]; + } } } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt b/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt index 87ab134c..17581c96 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt +++ b/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt @@ -197,10 +197,14 @@ function M.say(text, voiceclip) M.runwait(e) end --- Say series of lines --- conv: A string of conversational lines +-- Say a series of lines, setting speakign character, portrait or stage position on each line. +-- All parameters may be ommitted. The first three parameters can appear in any order. +-- The story text starts with a ':' and runs to the next newline character. +-- conv: A string of conversational lines using the following format. +-- [character] [portrait] [position] <: Story text> +-- e.g. john happy left: Hi, I'm happy. function M.conversation(conv) - local e = luautils.Conversation(conv) + local e = luautils.DoConversation(conv) M.runwait(e) end diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs index 3728ec45..d4171031 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs @@ -72,7 +72,7 @@ namespace Fungus protected StringSubstituter stringSubstituter; - protected Conversation conversation; + protected ConversationManager conversationManager; /// /// Called by LuaEnvironment when initializing. @@ -285,7 +285,8 @@ namespace Fungus stringSubstituter = new StringSubstituter(); - conversation = new Conversation(); + conversationManager = new ConversationManager(); + conversationManager.PopulateCharacterCache(); if (fungusModule == FungusModuleOptions.UseGlobalVariables) { @@ -475,9 +476,9 @@ namespace Fungus /// Use the conversation manager to play out a conversation /// /// - public virtual IEnumerator Conversation(string conv) + public virtual IEnumerator DoConversation(string conv) { - return conversation.DoConversation(conv); + return conversationManager.DoConversation(conv); } } diff --git a/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity b/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity index 8e100992..eb94a07c 100644 --- a/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity +++ b/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity @@ -423,7 +423,7 @@ MonoBehaviour: indentLevel: 0 luaEnvironment: {fileID: 0} luaFile: {fileID: 0} - luaScript: 'conversation[[ + luaScript: 'conversation [[ watson annoyed left: What the deuce! @@ -507,7 +507,7 @@ MonoBehaviour: indentLevel: 0 luaEnvironment: {fileID: 0} luaFile: {fileID: 0} - luaScript: "conversation [[\r\nsherlock right: Character+position.\r\nThis is a + luaScript: "conversation [[\r\nsherlock right: Character+position.\r\nThis is a continuation of the last line.\nS bored left:All three options with name shortened.\nwatson annoyed right: Adding a new character on the right.\r\nW, confident, offscreen right: Move Watson offscreen using commas.\r\n]]"