snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.63k stars 290 forks source link

(Help Request) Customising IF to query variables from external database #917

Closed TheEmbracedOne closed 3 years ago

TheEmbracedOne commented 3 years ago

Let me preface this by saying that I am aware that the way I use Fungus is not quite an intend way of using it. I am using an external database (Databox) to store variables instead of using Fungus variables. It's easier to query them by my other systems and I'd like to avoid using PlayerPrefs altogether.

Because my variables are stored elsewhere, I cant just get the IF/ELSEIF commands to fetch them like you would with normal Fungus variables - instead I have to use Invoke Method first, then save the return value to a variable, and then query those without saving them. This is a bit of a workaround that I'm hoping to bridge by creating a custom IF/ELSEIF command that basically have a functionality similar to that of InvokeMethod built in and directly work with the return values of the function that query these values from a database.

I've already managed to create a new IF_2 command that takes a list of strings (statConditions) that get sent to another script, which then returns a bool. The operation is called "IsStatGreaterOrEqual".

Unity_n4vGZbYzYE

I made the following modifications:

Current Behaviour

The scripts communicate, and there is a return value triggered, but the IF_2 command never gets it back: image

Intended Behaviour

The return values from the Dbox_ChapterStats' IsStatGreaterOrEqual methods to be "given back" to the If_2 so that it may perform actions with it. It should essentially work like a simple bool operation, but instead of taking the bool from a fungus variable, it takes it from the return value.

Any advice would be appreciated. Thank you

TheEmbracedOne commented 3 years ago

I decided this is perhaps a bit too advanced for what I need it for.