Forum rules - please read before posting.

Running ActionLists from script

edited July 2014 in Technical Q&A
Looked into this in the code and it seems like especially if you're going to run an actionlist from an asset file with a parameter, that there's a decent amount of overhead in terms of setting it up - is that right? Or is there some really simple way to run one from C# that I'm missing! :)

Use case would be - want to control some aspect of the game from script, or Playmaker - and ActionLists as assets that take parameters seem like the best way to do that - but there always seems to be a really simple way to do things with AC so wanted to check to make sure I'm not making life hard on myself!

Comments

  • The simple way to do it is to use the Engine: Run ActionList Action!  It is indeed quite complex to do through script, but the feature was designed with the Action system in mind.

    To do it through script, have a look at ActionRunActionList.cs' SendParameters function. Essentially, you need to set the value of each parameter in the ActionLists' parameters List using the class' SetValue function.
  • Got it - and actually, it turned out to be pretty straightforward to do. For others' benefit here's the basic gist of it:

    // First, load the ActionListAsset from the .asset file in resources
    actList = (ActionListAsset)Resources.Load("your_asset_list") as ActionListAsset;

    // Then, populate the parameters if they exist - they need to be integer IDs - ie. the Constant ID component
    actList.parameters[0].SetValue(constantID);

    // Run the action list!
    AdvGame.RunActionListAsset (actList);

    Pretty simple in the end. A bit of cleanup would allow you to make this a Playmaker action pretty easily.

    Thanks for the tip!
  • Thanks for sharing! very useful info. A Playmaker action would be very handy indeed.


  • You can now make an ActionListAsset variable:
    public ActionListAsset actionList;

    And then assign an ActionList via the inspector, and call it with:
    actionList.RunFromIndex(0);
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.