Browse Source

Merge pull request #473 from snozbot/menu-dialog-active

runblock() Lua function takes an optional command index
master
Chris Gregan 9 years ago
parent
commit
f82ccc5b51
  1. 5
      Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt
  2. 384
      Assets/Tests/Lua/FungusTests.unity

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

@ -265,8 +265,9 @@ end
-- Runs the specified Block in a Flowchart
-- flowchart: The Fungus Flowchart containing the Block to run.
-- blockname: The name of the Block to run.
-- commandindex: Index of the command to start execution at
-- nowait: If false, will yield until the Block finishes execution. If true will continue immediately.
function M.runblock(flowchart, blockname, nowait)
function M.runblock(flowchart, blockname, commandindex, nowait)
assert(flowchart, "flowchart must not be nil")
assert(blockname, "blockname must not be nil")
local block = flowchart.FindBlock(blockname)
@ -275,7 +276,7 @@ function M.runblock(flowchart, blockname, nowait)
return
end
local e = block.Execute();
local e = block.Execute(commandindex or 0);
if (nowait) then
M.run( e )

384
Assets/Tests/Lua/FungusTests.unity

@ -125,6 +125,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes:
@ -755,6 +757,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes: []
@ -766,6 +770,57 @@ MonoBehaviour:
Transform:
m_PrefabParentObject: {fileID: 495584, guid: 49031c561e16d4fcf91c12153f8e0b25, type: 2}
m_PrefabInternal: {fileID: 1320193925}
--- !u!1 &49402497
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 49402499}
- 114: {fileID: 49402498}
m_Layer: 0
m_Name: RunBlock
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &49402498
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 49402497}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3}
m_Name:
m_EditorClassIdentifier:
timeout: 5
ignored: 0
succeedAfterAllAssertionsAreExecuted: 0
expectException: 0
expectedExceptionList:
succeedWhenExceptionIsThrown: 0
includedPlatforms: -1
platformsToIgnore: []
dynamic: 0
dynamicTypeName:
--- !u!4 &49402499
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 49402497}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1669001930}
- {fileID: 1516562100}
m_Father: {fileID: 0}
m_RootOrder: 14
--- !u!1 &56584888
GameObject:
m_ObjectHideFlags: 0
@ -1461,6 +1516,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes: []
@ -2840,6 +2897,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes: []
@ -3790,6 +3849,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes:
@ -5099,6 +5160,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes:
@ -7496,6 +7559,156 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1449816145}
--- !u!1 &1516562099
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 179118, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1516562100}
- 114: {fileID: 1516562105}
- 114: {fileID: 1516562104}
- 114: {fileID: 1516562103}
- 114: {fileID: 1516562102}
- 114: {fileID: 1516562101}
m_Layer: 0
m_Name: Lua
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1516562100
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 466848, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 49402499}
m_RootOrder: 1
--- !u!114 &1516562101
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11437776, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c10f0b861365b42b0928858f7b086ff3, type: 3}
m_Name:
m_EditorClassIdentifier:
fungusModule: 0
activeLanguage: en
stringTables: []
registerTypes:
- {fileID: 4900000, guid: 9c3ab7a98d51241bbb499643399fa761, type: 3}
- {fileID: 4900000, guid: 93fddea8208764a2dbb189cc238aed40, type: 3}
--- !u!114 &1516562102
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11483650, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ba19c26c1ba7243d2b57ebc4329cc7c6, type: 3}
m_Name:
m_EditorClassIdentifier:
remoteDebugger: 0
--- !u!114 &1516562103
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11499092, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 1516562102}
tableName:
registerTypes: 1
boundTypes:
- UnityEngine.GameObject, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.PrimitiveType, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Component, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- UnityEngine.SendMessageOptions, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.SceneManagement.Scene, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.Object, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Fungus.Flowchart, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.Block, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Vector2, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Action, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Fungus.Variable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.Label, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.Command, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.CommandInfoAttribute, Assembly-CSharp, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.Rect, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
boundObjects:
- key: flowchart
obj: {fileID: 1669001929}
component: {fileID: 1669001934}
--- !u!114 &1516562104
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11417560, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 446caeace65234baaacd52095d24f101, type: 3}
m_Name:
m_EditorClassIdentifier:
luaEnvironment: {fileID: 1516562102}
luaFile: {fileID: 0}
luaScript: '-- Test running a block
runblock(flowchart, "RunBlock")
-- Test running a block at an index
runblock(flowchart, "RunBlockAtIndex", 1)'
runAsCoroutine: 1
--- !u!114 &1516562105
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11415008, guid: 3ddf9f33ba98e4b31ba4d2b9722bea00,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1516562099}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ee79785811ba49399c1b56d7309e3df, type: 3}
m_Name:
m_EditorClassIdentifier:
executeAfterTime: 1
repeatExecuteTime: 1
repeatEveryTime: 1
executeAfterFrames: 1
repeatExecuteFrame: 1
repeatEveryFrame: 1
hasFailed: 0
executeMethods: 2
executeMethodName: OnExecute
--- !u!4 &1526161870 stripped
Transform:
m_PrefabParentObject: {fileID: 495584, guid: 49031c561e16d4fcf91c12153f8e0b25, type: 2}
@ -7965,6 +8178,169 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1667495163}
--- !u!1 &1669001929
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1669001930}
- 114: {fileID: 1669001934}
- 114: {fileID: 1669001933}
- 114: {fileID: 1669001932}
- 114: {fileID: 1669001931}
- 114: {fileID: 1669001935}
- 114: {fileID: 1669001936}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1669001930
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 49402499}
m_RootOrder: 0
--- !u!114 &1669001931
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4920f47cde1a84b11ad07b7317568494, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 2
errorMessage:
indentLevel: 0
--- !u!114 &1669001932
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2dcb71131f45b47fead560a97ef55f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 1
errorMessage:
indentLevel: 0
failMessage:
--- !u!114 &1669001933
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 241
y: 51
width: 141
height: 40
itemId: 0
blockName: RunBlockAtIndex
description: Test will pass if execution starts at index 1
eventHandler: {fileID: 0}
commandList:
- {fileID: 1669001932}
- {fileID: 1669001931}
--- !u!114 &1669001934
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
blockViewHeight: 400
zoom: 1
scrollViewRect:
serializedVersion: 2
x: -350
y: -370
width: 1255
height: 911
selectedBlock: {fileID: 1669001935}
selectedCommands: []
variables: []
description:
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
localizationId:
showLineNumbers: 0
hideCommands: []
--- !u!114 &1669001935
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 67
y: 48
width: 120
height: 40
itemId: 3
blockName: RunBlock
description: 'Test passes if the block runs
'
eventHandler: {fileID: 0}
commandList:
- {fileID: 1669001936}
--- !u!114 &1669001936
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1669001929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea6e8f632db87477eb750446b28d73a3, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 4
errorMessage:
indentLevel: 0
commenterName:
commentText: This block does nothing
--- !u!1 &1676590047
GameObject:
m_ObjectHideFlags: 0
@ -8340,7 +8716,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1730192709
MonoBehaviour:
m_ObjectHideFlags: 0
@ -8416,6 +8792,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes:
@ -8873,7 +9251,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedFlowchart: {fileID: 56584893}
selectedFlowchart: {fileID: 1669001934}
--- !u!4 &1791050794
Transform:
m_ObjectHideFlags: 1
@ -10047,6 +10425,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4cc8a659e950044b69d7c62696c36962, type: 3}
m_Name:
m_EditorClassIdentifier:
allEnvironments: 1
luaEnvironment: {fileID: 0}
tableName:
registerTypes: 1
boundTypes:

Loading…
Cancel
Save