public void InitFromMap(InteractionMap map){
		item = map.item;                 
    	response = map.response;             
    	response_title = map.response_title;
    	tooltip = map.tooltip;
    	note = map.note;
    	sound = map.sound;
    	task = map.task;
    	list = map.list;
    	time = map.time;
    	log = map.log;
    	max = map.max;
		confirm = map.confirm;
		confirm_audio = map.confirm_audio;
		Enabled = map.Enabled;
		scriptName = map.scriptName;
		objectName = map.objectName;
		
		if (map.prereq != null){
			prereq = new System.Collections.Generic.List<string>();
			for (int i = 0; i<map.prereq.Count; i++)
				prereq.Add (map.prereq[i]);
		}
		if (map.category != null){
			category = new System.Collections.Generic.List<string>();
			for (int i = 0; i<map.category.Count; i++)
				category.Add (map.category[i]);
		}
		if (map.param != null){
			param = new System.Collections.Generic.List<string>();
			for (int i = 0; i<map.param.Count; i++)
				param.Add (map.param[i]);
		}
	}
Beispiel #2
0
 public InteractMsg(GameObject obj, InteractionMap item, bool log)
 {
     string name = (obj != null) ? obj.name : "null";
     this.gameObject = name;
     this.map = item;
     this.log = log;
 }
Beispiel #3
0
 public InteractMsg(GameObject obj, string item)
 {
     string name = (obj != null) ? obj.name : "null";
     this.gameObject = name;
     this.map = new InteractionMap(item, null, null, null, null, null, null, true);
     this.log = true;
 }
Beispiel #4
0
 public InteractMsg(GameObject obj, InteractionMap item)
     : base()
 {
     string name = (obj != null) ? obj.name : "null";
     this.gameObject = name;
     this.map = item;
     this.log = true;
 }
Beispiel #5
0
    public InteractStatusMsg(string name)
    {
        // save name
        InteractName = name;
        // lookup interact
        InteractMap = InteractionMgr.GetInstance().Get(name);
		// create new param list
		Params = new List<string>();
    }
Beispiel #6
0
	public bool IsCommandAvailable( string command )
	{
		InteractionMap map = InteractionMgr.GetInstance().Get(command);
		if (map == null){
			map = new InteractionMap();
			map.item = command;
		}
		foreach(ObjectInteraction testActor in actors){
			ScriptedObject sco = null;
			if (testActor.IsValidInteraction(map)){
				sco = testActor.GetComponent<ScriptedObject>();
				foreach (InteractionMap imap in sco.QualifiedInteractions()){
					if (imap.item == command)
						return true;
				}
			}
		}	
		return false;
	}
	InteractionScript BuildScriptFromInteraction(InteractionMap map){
		// assume we start with the top level map, either there's a single task, or an interaction list.
		GameObject ISGO = new GameObject(map.item);
		InteractionScript IS = ISGO.AddComponent<InteractionScript>();
		IS.triggerStrings = new string[1];
		IS.triggerStrings[0] = map.item;
		
		int hasSound = 0;
		if (map.sound != null && map.sound != "" )
			hasSound = 1;
		
		IS.scriptLines = new ScriptedAction[CountLines(map)+hasSound+1]; // gonna send an interact message too?  add one
		int index = 0;
		
		///* lets not built this top level message, as the menu probably already sent it.
		ScriptedAction SA = BuildSendInteractMessage(map);
		IS.scriptLines[index] = SA;
		// build the unity hierachy
		SA.gameObject.transform.parent = IS.gameObject.transform;			
		index++;
		//*/
		
		if (hasSound > 0)
		{
			// add handling the sound here from the interaction map
			SA = BuildPlaySound(map.sound);
			IS.scriptLines[index] = SA;
			// build the unity hierachy
			SA.gameObject.transform.parent = IS.gameObject.transform;			
			index++;
		}
		
		index = AddLines (map,IS,index);
		
		IS.scriptLines[index-1].stringParam4 = map.item+":COMPLETE"; //override the final task message
		// we could move that overwritten message up to a blank slot if it's needed...
		// or add one extra script line just to send that message up.
		
		// the InteractionScript should probably be using an interaction map for these, but they are individual fields
		IS.item = map.item;
		IS.prettyname = StringMgr.GetInstance().Get(map.item); // maybe this is a reasonable default?
		IS.response = "Script for "+map.item+" is running";
		IS.response_title = map.item;
		IS.task = ""; // putting map.item here might either help logging or trigger unwantede interactions ?
		
		return IS;
	}
Beispiel #8
0
	public bool ExecuteCommand(InteractionMap map){

		// menu commands are coming thru here
		InteractionMgr.GetInstance().EvaluateInteractionSet( map.item);

		GameObject preferredGO = ObjectManager.GetInstance().GetGameObject(map.objectName);	
	
	    InteractMsg msg = new InteractMsg( preferredGO, map);
		
		return DispatchMessage (  msg );		
		
	}
	void Execute(InteractionMap item)
	{
//		InteractionMgr.GetInstance().EvaluateInteractionSet(item.item);	
		
        SetVisible(false);
		if (interactObject != null)
        {
            // send message to object
            interactObject.PutMessage(new InteractMsg(interactObject.gameObject, item, item.log));
        }
        else
        {
            // send message to ourselves (for classes that inherit the base class)
            this.PutMessage(new InteractMsg(null, item, item.log));
        }
	}
Beispiel #10
0
	public void ConfirmInteractDialogCallback( string msg )
	{
		// obj should be us, and the button
		
		bool handled = false;
		
		if (msg.Contains("onbutton="))
		{
	        if (msg.Contains("interact="))
        	{
	            // get rid of tag
            	string map;
            	if (ScriptedAction.GetToken(msg, "interact", out map) == true)
            	{
                   	// create interaction map
                  	InteractionMap imap;
					// lookup interaction map
                    imap = InteractionMgr.GetInstance().Get(map);
                    if (imap == null)
                    {
	                       // not found, generic...make one
                       	imap = new InteractionMap(map, null, null, null, null, null, null, true);
                    }
					// get object to send to....if no object then assume that we are sending msg to script owner
					BaseObject obj = null;
					// first look for object token
					string _object;
                	if (ScriptedAction.GetToken(msg, "object", out _object) == true)
                	{
						// we have an object, go find it
	                    // get object
                    	obj = ObjectManager.GetInstance().GetBaseObject(_object);
                	}

					// send to object if we have one!
                    if (obj != null)
                    {
						// create InteractMsg
                       	InteractMsg imsg = new InteractMsg(obj.gameObject, imap);
                       	imsg.map.confirm = false;
                       	obj.PutMessage(imsg);
                    }
            	}
			}
		}

	}
Beispiel #11
0
	public virtual bool ExecuteCommand( string command, string preferredHandler = ""){
		// commands initialed thru the NLU, Menu, or Filter should pass thru this for processing

		InteractionMgr.GetInstance().EvaluateInteractionSet(command); //		
		
		InteractionMap map = InteractionMgr.GetInstance().Get(command);
		if (map == null){
			Debug.LogWarning("InteractionMgr found no map for "+command);
			map = new InteractionMap();
			map.item = command;
			// return false;
		}
		
		GameObject preferredGO = null;
		if (preferredHandler != null){
			preferredGO = ObjectManager.GetInstance().GetGameObject(preferredHandler);	
		}
		
	    InteractMsg msg = new InteractMsg( preferredGO, map);
		bool dispatched = DispatchMessage (  msg );

		if (dispatched && scribeNurse != null && scribeNurse.GetComponent<ScriptedObject>().scriptArray.Count<1){
			// have the scribe nurse write this down.
			InteractionMap recordMap = new InteractionMap();
			recordMap.item = "RECORD:RESULT";
			recordMap.param = new List<string>();
			recordMap.param.Add(command);
			InteractMsg recordMsg = new InteractMsg( scribeNurse.gameObject, recordMap);
			recordMsg.scripted = true;
			scribeNurse.PutMessage(recordMsg);
		}

		return dispatched;
	
//		PutMessage (msg); // use our normal code to find the best character to do this.
	}
    public void AddItem(InteractionMap item)
    {
        if (ItemResponse == null)
            ItemResponse = new List<InteractionMap>();

        // check to see if item is already here
        foreach (InteractionMap i in ItemResponse)
        {
            if (i.item == item.item)
            {
                // item already here, cya!
                return;
            }
        }

        // add it
        ItemResponse.Add(item);
		AllMaps.Add (item); // this needs to be in here, too.
		
    }
 public void Add( InteractionMap map )
 {
     InteractionMap imap = new InteractionMap();
     imap = map;
     imap.time = Time.time;
     Interactions.Add(imap);
 }
 public bool IsValidInteraction(InteractionMap map)
 {
     return IsValidInteraction(map.item);
 }
	int AddLines(InteractionMap map, InteractionScript IS, int index){

		// if we have an interaction list, then accumulate the number of character tasks in each map's task
		if (map.list != null && map.list.Length > 0){ // foreach isn't guaranteed to traverse in order, should index
			foreach (Interaction intr in InteractionMgr.GetInstance ().GetList(map.list).Interactions){
				index = AddLines(intr.Map,IS,index);
			}
		}
		else
		{	// no list. if we have a task, then add lines for each character tasks in it's data
			if (map.task != null 
				&& TaskMaster.GetInstance().GetTask(map.task) != null
				&& TaskMaster.GetInstance().GetTask(map.task).data != null
				&& TaskMaster.GetInstance().GetTask(map.task).data.characterTasks != null)
			{
				int hasSound = 0;
				if (map.sound != null && map.sound != "" ){
					hasSound = 1;
Debug.Log ("found sound");
				}
		
				ScriptedAction SA = BuildSendInteractMessage(map);
				IS.scriptLines[index] = SA;
				// build the unity hierachy
				SA.gameObject.transform.parent = IS.gameObject.transform;			
				index++;
				
				// add handling the sound here from the interaction map
				if (hasSound > 0)
				{
					SA = BuildPlaySound(map.sound);
					IS.scriptLines[index] = SA;
					// build the unity hierachy
					SA.gameObject.transform.parent = IS.gameObject.transform;			
					index++;
				}
												
				int lineCount = TaskMaster.GetInstance().GetTask(map.task).data.characterTasks.Count;
				foreach (CharacterTask c in TaskMaster.GetInstance().GetTask(map.task).data.characterTasks)
				{
					SA = BuildLineFromCharacterTask(c);
					IS.scriptLines[index] = SA;
					// build the unity hierachy
					SA.gameObject.transform.parent = IS.gameObject.transform;
					index++;
				}
				
				// crosslink the lines within this character task to wait for each other,
				if (lineCount > 1){
					for (int sai = index-lineCount; sai<index; sai++){
						IS.scriptLines[sai].syncToTasks = new ScriptedAction[lineCount-1];
						int insertPtr = 0;
						for (int linkPtr = index-lineCount; linkPtr < index; linkPtr++){
							if (linkPtr != sai)
								IS.scriptLines[sai].syncToTasks[insertPtr++] = IS.scriptLines[linkPtr];
						}
					}
				}
				
				// set the COMPLETE mesasge on the last one, and WaitForCompletion only on the last one
				IS.scriptLines[index-1].stringParam4 = map.item+":COMPLETE";
				IS.scriptLines[index-1].waitForCompletion = true;
			}
				
			else
			{
				ScriptedAction SAE = BuildLineFromMap(map);
				IS.scriptLines[index] = SAE;
				// build the unity hierachy
				SAE.gameObject.transform.parent = IS.gameObject.transform;
				index++; // this is really an error condition we need to resolve
				
			}
		}
		return index;
	}
	public string EditMappedString(string label,string key,InteractionMap map){
		GUILayout.BeginHorizontal ();
		GUILayout.Label (label,GUILayout.Width(125));
		// use this group of controls to display/edit a mapped string
		
		if (key == null){
			key = ""; // avoids errors with textField
		}
		
		// we'll only allow one stringmap to be edited at a time, and name of the key will flag
		// which one we are editing.
		
		// click the EDIT button to make us the one being edited.
		if (editingStrmapKey != "" && editingStrmapKey == key){
			// we are open for edit
			Color old = GUI.backgroundColor;
			GUI.backgroundColor = Color.red;
			GUILayout.Label ("Editing map key, value below");
			if (GUILayout.Button ("SAVE")){
				StringMgr.GetInstance().UpdateOrAdd(editStrmap.key,editStrmap.value);				
				editingStrmapKey = "";
				//editStrmap.key = ""; // this is pointing into the node's map so don't clear it!
				//editStrmap.value = "";
				// if the original key has changed, then we have to update the task or whatever this strmap was used in
				// kind of a hack, but...
				if (map != null){
					InteractionMgr.GetInstance().UpdateOrAdd(map);
					InteractionMgr.GetInstance().SaveXML("Assets/Resources/XML/Interactions/Interactions.xml");
				}
			}
			if (GUILayout.Button ("CANCEL")){
				editingStrmapKey = "";
				//editStrmap.key = "";
				//editStrmap.value = "";
			}
			GUILayout.EndHorizontal();
			editStrmap.key = EditorGUILayout.TextField("key = ",editStrmap.key); // how do we make the label narrower ?
			// if we are editing, and the key has been changed, we should look up the mapped value again...
			if (key != editStrmap.key){
				editStrmap.value = StringMgr.GetInstance().Get(editStrmap.key);
				if (editStrmap.value == editStrmap.key) editStrmap.value = "NOT MAPPED YET";
				key = editStrmap.key; // pass back the edited value
				editingStrmapKey = key;
			}
			editStrmap.value = GUILayout.TextField(editStrmap.value);
			GUI.backgroundColor = old;
			GUILayout.BeginHorizontal();
		}
		else
		{
			// we are just displaying
			string mappedValue = StringMgr.GetInstance().Get(key);
			if (mappedValue == key) mappedValue = "NOT MAPPED YET";
			GUILayout.Label("["+key+"]:"+mappedValue,GUILayout.Width(175));
			if (editingStrmapKey == ""){
				if (GUILayout.Button ("Edit Stringmap",GUILayout.Width(100))){
					if (key == "") key = map.item; // we can't lock to an empty key, so try this initial value
					editingStrmapKey = key;
					editStrmap.key = key;			// initialize the persistent temp strmap
					editStrmap.value = mappedValue;
				}
			}
			else
				GUILayout.Button ("-edit is busy-");
		}
		GUILayout.EndHorizontal();
		return key;
	}
	public void EditTask(string label, string key, InteractionMap map){
		GUILayout.BeginHorizontal();
		
		
		
		
	}
Beispiel #18
0
	public bool IsCommandQueued( string command )
	{
		// return true if the command is in someone's queue or already running...
		InteractionMap map = InteractionMgr.GetInstance().Get(command);
		if (map == null){
			map = new InteractionMap();
			map.item = command;
		}
		foreach(ObjectInteraction testActor in actors){
			ScriptedObject sco = null;
			if (testActor.IsValidInteraction(map)){
				sco = testActor.GetComponent<ScriptedObject>();

				//In the Que ?
				foreach (object obj in sco.scriptArray){
					foreach (string trigger in((obj as ScriptedObject.QueuedScript).script.triggerStrings)){
						if (trigger == command)
							return true;
					}
				}
				// already runnning ?
				foreach (ScriptedObject.QueuedScript qs in sco.scriptStack){
					foreach (string trigger in qs.script.triggerStrings){
						if (trigger == command)
							return true;
					}
				}
			}
		}	
		return false;
	}
Beispiel #19
0
    public InteractStatusMsg(InteractMsg msg)
    {
        // save name
        InteractName = msg.map.item;
        // save msg
        InteractMap = msg.map;
		// create new param list
		Params = new List<string>();
    }
	ScriptedAction BuildSendInteractMessage(InteractionMap map){
		GameObject SAGO = new GameObject("sendInteract"+map.item);
		ScriptedAction SA = SAGO.AddComponent<ScriptedAction>();
		
		InteractionMapForm MF = SAGO.AddComponent<InteractionMapForm>();
		SA.gameMsgForm = SAGO.AddComponent<GameMsgForm>();
		MF.InitFromMap(map);
		SA.gameMsgForm.map = MF;
		SA.gameMsgForm.msgType = GameMsgForm.eMsgType.interactMsg;
		SA.type = ScriptedAction.actionType.putMessage;
		SA.waitForCompletion = false; 
	
		return SA;	
	}
	public float GetCost(InteractionMap map){
		// currently, only InteractionScripts have a meaningful cost metric
    	ScriptedObject so = this.GetComponent<ScriptedObject>();
        if (so != null)
		{
			InteractionScript s = so.TriggeredScript(map.item,this as BaseObject);
			if (s != null){
				return s.GetCost(this);
			}
		}	
		return 99999; // we don't know how to do this.
	}
	ScriptedAction BuildLineFromMap(InteractionMap map){
		GameObject SAGO = new GameObject("TaskXMLIncompleteFor"+map.item);
		ScriptedAction SA = SAGO.AddComponent<ScriptedAction>();
	
		SA.type = ScriptedAction.actionType.characterTask;
		SA.fadeLength = 0;
		SA.stringParam4 = map.item+":COMPLETE"; // send this just so we don't bog down waiting for it...
		
		SA.waitForCompletion = false; // we'll set this to true for the last line of a list of CT's
	
		return SA;	
	}
	// this temporary method is just to keep characters from saying they don't know how to do tasks PAA
	public void AddToAllMaps( InteractionMap map){
		if (!AllMaps.Contains(map)) // this is almost certain to pass, as this is a different instance
			AllMaps.Add ( map );	
	}
	int CountLines(InteractionMap map){ // we use this just to dimension each IS.lines array
		// how many character interactions will it take for this script	
		int count = 0;
		// if we have an interaction list, then accumulate the number of character tasks in each map's task
		if (map.list != null && map.list.Length > 0){
			foreach (Interaction intr in InteractionMgr.GetInstance ().GetList(map.list).Interactions){
				count += CountLines (intr.Map);
			}
		}
		else
		{	// no list. if we have a task, then count the character tasks in it's data
			if (map.task != null 
				&& TaskMaster.GetInstance().GetTask(map.task) != null
				&& TaskMaster.GetInstance().GetTask(map.task).data != null
				&& TaskMaster.GetInstance().GetTask(map.task).data.characterTasks != null){
				count += TaskMaster.GetInstance().GetTask(map.task).data.characterTasks.Count;
				count++; // to add one line for an interact message for this task
				if (map.sound != null && map.sound != "" )
					count++; // we'll add a play sound here or voice message
			}
			else
				count++; // this is really an error condition we need to resolve
		}
		return count;
	}
 public Info(BaseObject obj, InteractionMap map, float percent)
 {
     this.obj = obj;
     this.map = map;
     this.percent = percent;
 }
	// handles messages coming back from the GUI.  these messages are setup in the DialogMsg,
	// and passed when the button button specified.  The messages can be either an "onbutton=" event or
	// a default "button" event
    public bool ProcessMessage(string msg)
    {
		bool handled = false;

		// make lower case version
		string msgLower = msg.ToLower();
		
		if (msgLower.Contains("onbutton=") || 
		    msgLower.Contains("interact=") || 
		    msgLower.Contains("script=") || 
		    msgLower.Contains("audio=") || 
		    msgLower.Contains("action="))
		{
			// check name of pressed button
			string buttonName;
			if ( GetToken(msgLower, "onbutton", out buttonName) == true )
			{
				if ( msgLower.Contains("pressed"))
				{
					string pressedName;
					if ( GetToken(msgLower,"pressed", out pressedName) == true )
					{
						// if button pressed is not equal to this action, return
						if ( buttonName != pressedName )
							return false;
					}
				}
			}
			
	        if (msgLower.Contains("interact="))
        	{
	            // get rid of tag
            	string map;
            	if (GetToken(msg, "interact", out map) == true) // this used to process msgLower, but produced unmatchable tags
            	{
                   	// create interaction map
                  	InteractionMap imap;
					// lookup interaction map
                    imap = InteractionMgr.GetInstance().Get(map);
                    if (imap == null)
                    {
	                       // not found, generic...make one
                       	imap = new InteractionMap(map, null, null, null, null, null, null, true);
                    }
					// get object to send to....if no object then assume that we are sending msg to script owner
					BaseObject obj = null;
					// first look for object token
					string _object;
                	if (GetToken(msgLower, "object", out _object) == true)
                	{
						// we have an object, go find it
	                    // get object
                    	obj = ObjectManager.GetInstance().GetBaseObject(_object);
                	}
					else
					{
						// sending msg to script owner
						if ( executedBy != null && executedBy.caller != null )
							obj = executedBy.caller.ObjectInteraction;
					}
					// send to object if we have one!
                    if (obj != null)
                    {
						if ( executedBy.debug == true )
		            		UnityEngine.Debug.Log("GUIButton.ProcessMessage() : obj=" + obj.name + " : map=" + map);
                       	// create InteractMsg
                       	InteractMsg imsg = new InteractMsg(obj.gameObject, imap);
                       	imsg.map.confirm = false;
                       	obj.PutMessage(imsg);
                    }
					else
					{
						if ( executedBy.debug == true )
			            	UnityEngine.Debug.Log("GUIButton.ProcessMessage() : can't find obj=" + obj.Name + " : map=" + map);
					}
            	}
			}

			// this is the audio handling block.  Allows audio to play on button
			if (msgLower.Contains("audio"))
			{
				string audio;
               	if (GetToken(msgLower, "audio", out audio) == true)
               	{	
					// play some audio
					Brain.GetInstance().PlayAudio(audio);
				}
			}	
				
			// this is the script handling block.  the specified script will be executed on either the
			// calling object or on the object=obj specified.  system queues the script on the ScriptedObject
			// to be completed after the object is finished with the current script.
        	if (msgLower.Contains("script="))
        	{
				string _script;
				// NOTE!! don't use lower case here because scripts need to be literal
               	if (GetToken(msg, "script", out _script) == true)
               	{	
					BaseObject obj=null;
					
					// get object to send script too
					string _object;
               		if (GetToken(msgLower, "object", out _object) == true)
               		{
						// we have an object, go find it
                   		obj = ObjectManager.GetInstance().GetBaseObject(_object);
               		}
					else
					{
						// no target, sending msg to script owner
						if ( executedBy != null && executedBy.caller != null )
							obj = executedBy.caller.ObjectInteraction;
					}	

					// split to see if we have multiple scripts
					string[] scripts = _script.Split(',');

					// process all of them
					foreach ( string item in scripts )
					{
						BaseObject thisObj = obj;
						string thisItem = item; // so we can assign
						// added feature to allow sending the object name along with the script name, using  "@"
						if (item.Contains("@")){
							string[] parts = item.Split('@');
							thisItem = parts[1];
							if (ObjectManager.GetInstance().GetBaseObject(parts[0])!= null)
								thisObj = ObjectManager.GetInstance().GetBaseObject(parts[0]);
						}
						// send it
						if ( thisObj != null )
						{
							// we have a valid object and script....execute it!
							if ( executedBy.debug == true )
								UnityEngine.Debug.Log("ScriptedAction.ProcessMessage(" + msgLower + ") script=" + thisItem + " : object=" + thisObj.Name);							
							// try finding the named game object and look for an interaction script there
							GameObject isGO = GameObject.Find(thisItem);
							if (isGO != null)
								scriptToExecute = isGO.GetComponent<InteractionScript>();
							
							if (scriptToExecute != null){					
								//build a string with our script's args and add to stringParam args...
								string paramString = "trigger=" + "DIALOG" ;
								ScriptedObject sObj = thisObj.GetComponent<ScriptedObject>();
								if (sObj != null)
									sObj.QueueScript(scriptToExecute, paramString, thisObj.gameObject);
								else
									executedBy.caller.QueueScript(scriptToExecute, paramString, thisObj.gameObject);
								// yield until we get an update. which will complete us.  we HAVE to wait, no multi threading support yet.
								waitingForUpdate = true;
							}
							else
							{
								if ( executedBy.debug == true )
									Debug.LogError("scriptedAction could not find script to execute at "+name+executedBy.name);
								waitingForUpdate = true;
								handled = true; // should probably do this in the other branches as well...s
							}
						}
					}
				}
        	}
						
			// all buttons execpt for close must provide either action=abort, or action=ok to
			// make the dialog continue execution.  We do this because we have to have the buttons
			// be able to continue scripts
			if (msgLower.Contains("action"))
			{
	            string action;
           		if (GetToken(msgLower, "action", out action) == true)
           		{
					if ( executedBy.debug == true )
						UnityEngine.Debug.Log("ScriptedAction.ProcessMessage() : action=" + action);
					// set specific lines based on action
					if ( action == "abort" )
					{
						executedBy.nextLineLabel = "abort"; // this is setting the abort case
						error = "abort";					// this is error case
						handled = true;
					}
					if ( action == "else" )
					{
						if (dialogIfThen){ // either treat like if-then, or abort
							executedBy.nextLineLabel = "else";
						}
						else{
							executedBy.nextLineLabel = "abort"; 
							error = "abort";
						}
						handled = true;
					}
					if ( action == "ok" || action == "close" )
					{
						executedBy.nextLineLabel = ""; 		// this means just continue execution
						handled = true;
					}
				}
			}
			// this is not a closer
			return handled;
       	}		

		// Default button handling...
		if ( msgLower.Contains("button") )
		{
            string button;
       		if (GetToken(msgLower, "button", out button) == true)
        	{
				if ( executedBy.debug == true )
					UnityEngine.Debug.Log("ScriptedAction.ProcessMessage() : button=" + button);
				switch( button.ToLower() )
				{
				case "close":
				case "cancel":
				case "buttonnext": // traumaQuickFast sends this
					if (dialogIfThen){ // either treat like if-then, or abort
						executedBy.nextLineLabel = "else";
					}
					else{
						executedBy.nextLineLabel = "abort"; 
						error = "abort";
					}
					handled = true;
					break;
				case "ok":
					executedBy.nextLineLabel = ""; 
					handled = true;
					break;
				}
			}
		}
		
		return handled;		
    }
	public InteractionMap GetMap(){
		InteractionMap map = new InteractionMap(item,response,response_title,note,tooltip,sound,task,log);
		map.objectName = objectName;
		map.scriptName = scriptName;
		if (prereq != null){
			map.prereq = new System.Collections.Generic.List<string>();
			for (int i = 0; i<prereq.Count; i++)
				map.prereq.Add (prereq[i]);
		}
		if (category != null){
			map.category = new System.Collections.Generic.List<string>();
			for (int i = 0; i<category.Count; i++)
				map.category.Add (category[i]);
		}
		if (param != null){
			map.param = new System.Collections.Generic.List<string>();
			for (int i = 0; i<param.Count; i++)
				map.param.Add (param[i]);
		}
		
		return map;
	}
	public InteractionMap ToMap(string objectName){
		InteractionMap map = new InteractionMap(item,prettyname,response_title,note,tooltip,sound,task,log); // using prettyname for response PAA 7/3/15
				
		map.scriptName = name;
		map.objectName = objectName;
		if (prereq != null){
			map.prereq = new System.Collections.Generic.List<string>();
			for (int i = 0; i<prereq.Count; i++)
				map.prereq.Add (prereq[i]);
		}
		if (category != null){
			map.category = new System.Collections.Generic.List<string>();
			for (int i = 0; i<category.Count; i++)
				map.category.Add (category[i]);
		}
		if (param != null){
			map.param = new System.Collections.Generic.List<string>();
			for (int i = 0; i<param.Count; i++)
				map.param.Add (param[i]);
		}
		map.readyState = readyState; // assume this got set the last time isReady<> was called
		map.startPriority = startPriority;
		
		return map;
	}
	IEnumerator AddItems(){
		yield return new WaitForSeconds(2); // this delay was to be sure the xml got parsed first
		
		// Add a simple menu based on our data
		if (scripts != null){
	    	foreach (InteractionScript s in scripts){
				InteractionMap map = new InteractionMap( s.item,  s.prettyname,  s.response_title,  s.note,  s.tooltip,  s.sound,  s.task,  s.log); // using prettyname for response PAA 7/3/15
				// copy prereqs, categories, param
				if (s.prereq != null){
					map.prereq = new System.Collections.Generic.List<string>();
					for (int i = 0; i<s.prereq.Count; i++)
						map.prereq.Add (s.prereq[i]);
				}
				if (s.category != null){
					map.category = new System.Collections.Generic.List<string>();
					for (int i = 0; i<s.category.Count; i++)
						map.category.Add (s.category[i]);
				}
				if (s.param != null){
					map.param = new System.Collections.Generic.List<string>();
					for (int i = 0; i<s.param.Count; i++)
						map.param.Add (s.param[i]);
				}
				if (s.AddToMenu ) //&& s.isReadyFor(GetComponent<BaseObject>())
			    	myOI.AddItem(map);
				InteractionMgr.GetInstance().Add(map);
				if (s.prettyname != null && s.prettyname != "")
				{  // update the string map from the script menu
					StringMgr.GetInstance ().Load(s.item,s.prettyname);
				}
				else
				{  // see if you can get a nice menu name from the string map, or show just the ITEM:
					s.prettyname = StringMgr.GetInstance(). Get (s.item);
				}
			}
		}
		
		if (startupScript != null)
			QueueScript(startupScript,"trigger=startup",gameObject,4);
		
	}
	void LoadNewMenu(InteractionMap item) {
		page = 0;
		breadcrumbs.Add(item.item);
		menuLocation = item.item;
		string newXML = item.item.Remove(0, 4);
		
		InteractDialogMsg idmsg = new InteractDialogMsg();
        //idmsg.command = DialogMsg.Cmd.open;
        idmsg.LoadXML("XML/Interactions/" + newXML);
		items = idmsg.items;
        //InteractDialog.GetInstance().PutMessage(idmsg);
	}