Hello!

I'm working on a game that's part visual novel, part tactical RPG. I've gone through the ORK game tutorial, as well as the grid battles tutorial. It's excellent, and does nearly everything I need. I'm hoping to integrate Fungus, an open-source dialogue system that I have some experience with which I've chosen because it gives me the visual novel capabilities that suit my game best. (It's here: http://fungusgames.com/)

Fungus conversations are laid out in flowcharts. These can be called by script, and I have successfully done so with trigger boxes. In theory, I expect I can call them from an ORK event with the Call Function node. However, I'm having trouble doing so from a Battle Start Event.

I'd like to, at various points in the grid battle, call these flowcharts to insert dialogues from a character that will give instructions and advice. For example, a dialogue overlay that says something like "Hey, decide where you want to place Character X on the map" before/as the player placement occurs. And "Character X is a melee fighter, so you have to get close to the enemy!" or something when the player starts to move the character, and so on.

I have found a number of threads that deal with the Call Function node, but my options appear a bit different in the Battle Start Event. For example, my Actor options are the faction groups, and I'm not able to assign an actor in the Event Settings node. I'm not sure what to apply my script to so that I can correctly call it in the node.

I'd really appreciate some outside perspective on this. I think I've been staring at it all to long, and I suspect the answer is right in front of my face. Thanks!
  • Additional info:

    I'm basing a lot off the ORK game tutorial series. Currently, I have an opening scene that is just a flat plane where BrownPants spawns. If he runs into a cube with this script attached, a Fungus flowchart is called and a dialogue box appears.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Fungus;

    public class tutboxTrigger : MonoBehaviour {

    public Flowchart Flowchart;

    void OnTriggerEnter(Collider other) {
    Flowchart.ExecuteBlock ("Start");
    }

    }
    Since I was having difficulty with the Battle Start Event, I attempted to call the function from a Game event, the game start event from the tutorial. I attached the following code to the BrownPants prefab:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Fungus;
    using ORKFramework;

    public class tutcall : MonoBehaviour {

    public Flowchart Flowchart;

    public void startTut () {
    Debug.Log ("triggered");
    Flowchart.ExecuteBlock ("Start");
    }
    }
    I added a Call Function node after the final node from the gamestart event (adding the Fire Sword recipe), and called the startTut function. It appears to call it, as my console displays the "triggered" notification, but it's followed by an error that an exception has been thrown. I understand that means there's an error in my function, but I'm failing to understand what that error is. I have set no parameters on the node.

    I hope that helps explain where I'm at. Thanks again!
  • edited March 2017
    Since your function only calls another (static) function, you could do this directly from ORK's event system, without going over a custom component attached to a game object.

    Use a Call Function node with the following settings (based on your code example):
    - set Component Name to Flowchart
    - enable Is Static
    - set Function Name to ExecuteBlock
    - click on Add Parameter
    - set Parameter Type to String
    - set String Value to Start (or whatever other value you want to use)

    As you noticed, other event types than game events don't allow setting up actors, as they rely on a special set of actors (e.g. user and target in battle events). If you need to use other game objects, you'll need to e.g. use a Search Object node and store them in found/global object lists to use them in the event.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2017
    Thank you so much for the quick response! I appreciate your bearing with me while I get a handle on everything. :)

    I gave your first suggestion a try, and get this alert:
    Method call failed (Fungus.Flowchart): ExecuteBlock
    Non-static method requires a target.
    Am I right in understanding that means it isn't actually a static function?

    I'll play with the search object approach and see what I can get. Thanks again!
    Post edited by meglish on
  • Sorry, missread your code, thought it's a call to a public function. You'll have to go the game object way in that case, or write some custom static functions :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2017
    No problem, thanks for looking at it at all, GiL. :D I can't imagine how many out-of-context snippets you see daily.

    I'm going to give some other game objects & events a try, but I do know the function gets called successfully in the Start Event, when the script is attached to BrownPants. An exception is thrown at the
    Flowchart.ExecuteBlock ("Start");
    line, even though that line is executed perfectly fine when attached to a box trigger. I think that discrepancy is really throwing me, too. Does something load in an unfortunate order, perhaps?

    Thanks again!
    Post edited by meglish on
  • Update: it does seem to be a load-order related issue. I'm starting to get results by using different objects (instead of BrownPants) and the Find Object method in a standard Game Event (not the game start or battle start events - yet). Hopefully a weekend of tinkering will yield the results I'm looking for.

    Thanks so much again for all the help! I can't wait to share where this goes. :D
  • edited March 2017
    Strange - can you post the exception you get?
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hey GiL, sorry for the delay. I got caught up in it all for a bit. :) I had a little help working out what was going on, though their expertise is straight C# rather than Unity.

    The exception being thrown was this:
    Method call failed (tutcall): startTut Exception has been thrown by the target of an invocation. at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115 at …http://ORKFramework.Reflection.CallMethod.Call (System.Object instance) [0x00000] in :0 UnityEngine.Debug:LogWarning(Object) ORKFramework.Reflection.CallMethod:Call(Object) http://ORKFramework.Events .Steps.CallFunctionStep:Continue(BaseEvent) http://ORKFramework.Events .Steps.CallFunctionStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StepFinished(Int32) http://ORKFramework.Events .Steps.LearnRecipeStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StepFinished(Int32) http://ORKFramework.Events .Steps.LearnRecipeStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StepFinished(Int32) http://ORKFramework.Events .Steps.LearnLogTextStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StepFinished(Int32) http://ORKFramework.Events .Steps.SpawnPlayerStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StepFinished(Int32) http://ORKFramework.Events .Steps.JoinActiveGroupStep:Execute(BaseEvent) http://ORKFramework.Events .GameEvent:ExecuteNextStep() http://ORKFramework.Events .BaseEvent:StartEvent() http://ORKFramework.Events .GameEvent:StartEvent(IEventStarter, Object) ORKFramework.Behaviours.d__29:MoveNext() UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) ORKFramework.Behaviours.EventInteraction:StartEvent(GameObject) ORKFramework.Behaviours.BaseInteraction:DoAutoStart() ORKFramework.Behaviours.EventInteraction:CheckAutoStart() ORKFramework.Behaviours.EventInteraction:Start()
    Something about the load order was making it so the Flowchart was null when the Start Event was looking for it on the BrownPants character. Moving the script to an object in the scene fixed it, so I just have an empty object with these functions on it for now. We'll see how long that works. :D

    It seems to be doing the job from within a Battle Start Event, though interspersing steps of the battle with these Flowchart calls is still something I'm working out.

    Thanks again!
Sign In or Register to comment.