fungus

Open full view…

How do I write if statements that check non-fungus variables?

academyoff
Thu, 12 Sep 2019 20:04:51 GMT

TL;DR: Let's say I am using another library that knows nothing about fungus. How could I use a Fungus If statement that checks a variable from that library? Here's my real situation: I'm making an open world visual novel. I want to have lots and lots of quests. I *don't* want to represent the state of every quest with a bunch of Fungus variables because I think the quest system should be a first class concept. By that, I mean I want to have structure like this: --- QuestLog { List<Quest> quests; Quest activeQuest; } Quest { List<String> questSteps; QuestState questState; } QuestState { Unassigned, Started, Succeeded, Failed } --- One thing I'm definitely going to want to do with this is in Fungus is have if statements that say something like this: --- if questStarted("Get a can of beans") and questStepCompleted("Get a can of beans", "Talk to Mia") Say("Player", "I already talked to Mia, and she told me to get the beans at the store."); end --- But how can I write those if statements if these variables aren't Fungus variables? I've seen that you can create a GameObject variable, but the only thing it seems you can do with that is compare it to other GameObject variables. I'm comfortable with coding. I'm wondering if the right way to approach this to copy and modify the If command to work with my quest system?

wolfrug
Fri, 13 Sep 2019 04:22:13 GMT

I see you're mainly working in Lua, which is nice, but my memory of how it deals with these things is a little hazy, sorry! But in pseudo-code, what I'd do is have (in this case) three dummy Fungus variables in a flowchart (which might contain nothing but these dummy variables) into which you load the relevant information prior to querying it. So in pseudocode: bool questStarted = myCustomCommandThing.IsQuestStarted("quest_tag") int questStep = muCustomCommandThing.QuestSteps("quest_tag" if (questStarted or questStep > 0) yada yada This is the way I deal with most Fungus-external variables that need to be dynamic: the actual Fungus variable doesn't store any info, it's just a temporary container. When you want to save the new state of the quest, you'll just run your custom command again and save it into the external component, from where it can be queried again at will. Having 'work horse' variables like this in Fungus can be quite useful in a variety of situat ions, like for example when doing more complex math inside a Flowchart, or when collecting return variables from event handlers or the like.

Steve Halliwell
Fri, 13 Sep 2019 10:42:04 GMT

I wouldn't recommend modifying the fungus if statement. I look at either lua as wolfrug suggests or creating custom command(s) to query your quest system that put its result into a fungus boolean, which can then use the existing fungus if on.

academyoff
Fri, 13 Sep 2019 15:47:46 GMT

Steve: I think I'm going to do the latter. It seems error prone to write the same Lua code over and over again with different parameters passed in.