Browse Source

conversation() lua function supports string substitution

master
Christopher 8 years ago
parent
commit
7d82252834
  1. 5
      Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt
  2. 89
      Assets/Tests/Narrative/ConversationTests.unity

5
Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt vendored

@ -203,8 +203,9 @@ end
-- conv: A string of conversational lines using the following format. -- conv: A string of conversational lines using the following format.
-- [character] [portrait] [position] <: Story text> -- [character] [portrait] [position] <: Story text>
-- e.g. john happy left: Hi, I'm happy. -- e.g. john happy left: Hi, I'm happy.
function M.conversation(conv) function M.conversation(text)
local e = luautils.DoConversation(conv) local subbed = M.sub(text)
local e = luautils.DoConversation(subbed)
M.runwait(e) M.runwait(e)
end end

89
Assets/Tests/Narrative/ConversationTests.unity

@ -1178,6 +1178,9 @@ GameObject:
- 114: {fileID: 1286795359} - 114: {fileID: 1286795359}
- 114: {fileID: 1286795380} - 114: {fileID: 1286795380}
- 114: {fileID: 1286795391} - 114: {fileID: 1286795391}
- 114: {fileID: 1286795392}
- 114: {fileID: 1286795386}
- 114: {fileID: 1286795393}
m_Layer: 0 m_Layer: 0
m_Name: Flowchart m_Name: Flowchart
m_TagString: Untagged m_TagString: Untagged
@ -1284,11 +1287,12 @@ MonoBehaviour:
y: -385.42166 y: -385.42166
width: 1563 width: 1563
height: 1097.6444 height: 1097.6444
selectedBlock: {fileID: 1286795365} selectedBlock: {fileID: 1286795370}
selectedCommands: selectedCommands:
- {fileID: 1286795363} - {fileID: 1286795392}
variables: variables:
- {fileID: 1286795390} - {fileID: 1286795390}
- {fileID: 1286795386}
description: description:
stepPause: 0 stepPause: 0
colorCommands: 1 colorCommands: 1
@ -1383,7 +1387,7 @@ MonoBehaviour:
indentLevel: 0 indentLevel: 0
conversationText: conversationText:
stringRef: {fileID: 0} stringRef: {fileID: 0}
stringVal: 'john bored left: {$StringVar}{w=1}{x}' stringVal: 'john bored left: {$StringVar1}{w=1}{x}'
--- !u!114 &1286795360 --- !u!114 &1286795360
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -1615,6 +1619,8 @@ MonoBehaviour:
commandList: commandList:
- {fileID: 1286795359} - {fileID: 1286795359}
- {fileID: 1286795380} - {fileID: 1286795380}
- {fileID: 1286795392}
- {fileID: 1286795393}
--- !u!114 &1286795371 --- !u!114 &1286795371
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -1812,9 +1818,9 @@ MonoBehaviour:
itemId: 43 itemId: 43
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
luaEnvironment: {fileID: 0} luaEnvironment: {fileID: 66556862}
luaFile: {fileID: 0} luaFile: {fileID: 0}
luaScript: check (storytext.text == "TestString") luaScript: check (storytext.text == "TestString1")
runAsCoroutine: 1 runAsCoroutine: 1
waitUntilFinished: 1 waitUntilFinished: 1
returnVariable: {fileID: 0} returnVariable: {fileID: 0}
@ -1831,7 +1837,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
nodeRect: nodeRect:
serializedVersion: 2 serializedVersion: 2
x: 334.88962 x: 335.92807
y: 64.4227 y: 64.4227
width: 120 width: 120
height: 40 height: 40
@ -1918,6 +1924,20 @@ MonoBehaviour:
conversationText: conversationText:
stringRef: {fileID: 0} stringRef: {fileID: 0}
stringVal: 'john bored left:' stringVal: 'john bored left:'
--- !u!114 &1286795386
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1286795350}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4580f28dd8581476b810b38eea2f1316, type: 3}
m_Name:
m_EditorClassIdentifier:
scope: 1
key: StringVar2
value: TestString2
--- !u!114 &1286795387 --- !u!114 &1286795387
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -2004,11 +2024,11 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
scope: 0 scope: 0
key: StringVar key: StringVar1
value: TestString value: TestString1
--- !u!114 &1286795391 --- !u!114 &1286795391
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1286795350} m_GameObject: {fileID: 1286795350}
@ -2020,12 +2040,61 @@ MonoBehaviour:
itemId: 45 itemId: 45
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
luaEnvironment: {fileID: 0} luaEnvironment: {fileID: 66556862}
luaFile: {fileID: 0} luaFile: {fileID: 0}
luaScript: storytext.text = "" luaScript: storytext.text = ""
runAsCoroutine: 1 runAsCoroutine: 1
waitUntilFinished: 1 waitUntilFinished: 1
returnVariable: {fileID: 0} returnVariable: {fileID: 0}
--- !u!114 &1286795392
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1286795350}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71f455683d4ba4405b8dbba457159620, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 46
errorMessage:
indentLevel: 0
luaEnvironment: {fileID: 66556862}
luaFile: {fileID: 0}
luaScript: 'storytext.text = ""
conversation [[
sherlock bored right: {$StringVar2}{w=1}{x}
]]
'
runAsCoroutine: 1
waitUntilFinished: 1
returnVariable: {fileID: 0}
--- !u!114 &1286795393
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1286795350}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71f455683d4ba4405b8dbba457159620, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 47
errorMessage:
indentLevel: 0
luaEnvironment: {fileID: 66556862}
luaFile: {fileID: 0}
luaScript: check (storytext.text == "TestString2")
runAsCoroutine: 1
waitUntilFinished: 1
returnVariable: {fileID: 0}
--- !u!1 &1349948625 --- !u!1 &1349948625
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

Loading…
Cancel
Save