Forum rules - please read before posting.

[Custom Action] Variables: MultiBoolCheck

Hi,

after not coding in C# for at least 10 years I sat myself down yesterday to code my first custom action. I call it "MultiBoolCheck" and it is used to check a unlimited number of global boolean variables if they meet given conditions. I need this to clean up my action lists if there are to many variable state checks.

Or simply said, it can turn this:
image
into this:
image

The Action is based on the "Variable: Check" Action. It only works with global boolean variables and does not support ActionList parameters. Maybe someone else has a use for it.

Comments

  • Oops. I wanted to post the code here but it tells me "Body is 82371 characters too long.". Any ideas how to share the code?
  • I made up a wiki page for this.
  • Thanks for posting!  The page can be found here.
  • Thank you! :)
  • This is very useful indeed! Thank's :)
  • edited August 2018
    @MAC

    This does not work for me in Unity 2018.2
    I put the MultiBoolCheck.cs where the AC scripts are and nothing ...
    Anything changed in scripting for 2018 this file ?
  • Custom Actions must be correctly installed following the guidelines outlined in the Manual's "Custom Actions" chapter as well as this tutorial.
  • 1. "If it is, choose to another platform, such as PC, Mac & Linux Standalone temporarily." checked
    2. "Within the Custom Action scripts panel, click Set directory." checked

    I do not think it is something I did wrong. What else should I check ?
  • I found the problem: I put the cs file in the Actionlist folder instead of Actions. And this is why it was not finding my new Action :)
  • This is such an amazing script...I've used it a lot in my game, which has several puzzle pieces that need to be positioned correctly over markers.  It's a great way to check if all the pieces are in the right spot.

    Can anyone help me modify this script to check Integer variables instead of Boolean variables? (I know just enough C# to get me into trouble!)
  • @sonicjoy: This won't do it completely, but you'll have a good start by renaming all instances of MultiBool to MultiInt, BoolValue to int, and boolValue to intValue (all case-sensitive).

    From there, it should mostly be a case of correcting errors that then appear in the Console.
  • Thanks Chris! I'll give it a go.
  • I know it's been a while, but this is extremely useful... but I can't get it to work. It's telling me there's an error on line 97: ActionMultiBoolCheck.cs(97,35): error CS0115: 'ActionMultiBoolCheck.End(List)': no suitable method found to override

    Any ideas?

  • Welcome to the community, @midnightdojo.

    It's an old Action that uses the old Action API, deprecated with AC v1.73.

    A guide to changes made to the API can be found here, but I've attempted to update the wiki page with the corrections - have a try now and see if it works.

  • Thanks @ChrisIceBox. You're epic! I got it to work, there were only two minor issues that I fixed. Maybe you can update the wiki with them.

    line 51 we have:
    Hits++:
    I changed it to
    Hits++;

    Then on line 61 we have
    {
    ACDebug.LogWarning("The 'Variable: MultiBoolCheck' Action halted the ActionList because it cannot find the Global Variable with an ID of " + _multiBool.variableID);
    return GenerateStopActionEnd();
    }

    I changed it to:
    {
    ACDebug.LogWarning($"The 'Variable: MultiBoolCheck' Action halted the ActionList because it cannot find the Global Variable with an ID of {_multiBool.variableID}");
    GenerateStopActionEnd();
    return false;
    }

    It seems to be working now! Tested it out with a few variables. This is going to save me a ton of time.

  • Amended - thanks for the pointers.

  • Cheers! I'm mostly just a composer who is working on a click adventure, so I'm not that good at coding yet, but I was able to hack around until I figured out what worked. Anyway, thanks again. It's been extremely useful.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.