SmugRainbowPony's Recent Forum Activity

  • Thanks for the answers! I guess my "workarounds" are the best options I have then.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello.

    I'm working on an ink integration plugin for Construct 3.

    I managed very well on my own for a while but now am faced with a very small road block. I have workarounds but I also have questions. Here are the problems.

    Ink is a language/library for interactive storytelling, and allows to use 'variable watchers' to register a javascript callback to be called when a story variable changes. I would like to use a Construct Event Trigger as an end-user API for this.

    I am facing two issues:

    1. I need to know in advance which variables to watch.

    I can do this with a dedicated action to start watching a variable, but it's not ideal. If there's some way to generate some 'startup' function based on the event sheet content at compile time, it would be way better, but I have not found anything like that.

    For now I'm using a separate 'start watching variable' action. I have no hard-counters against this, it's just an extra step for the end user.

    2. I want to trigger a c3 trigger condition, telling it which variable has changed and what the new values are.

    My 'start watching' action looks like this:

    StartObservingVariable(name) {
     this._story.ObserveVariable(name, (name, new_value) => {
     this.Trigger(C3.Plugins.PLUGIN_ID_PLACEHOLDER.Cnds.VariableChanged)
     });
    }
    

    I have no idea how to tell the trigger condition which variable has changed.

    The condition looks like this in aces.json:

    {
     "id": "var-changed",
     "scriptName": "VariableChanged",
     "isTrigger": true,
     "params": [{"id": "var-name","type": "string"}]
    }
    

    where the given name is the ink variable that will need to have changed for this specific trigger block to fire.

    The corresponding function would look like this (basic idea):

    VariableChanged(nameFromEventSheet, nameFromTriggerCall) {
     return (nameFromEventSheet == nameFromTriggerCall);
    }
    

    The core of my goal is to have a simple trigger condition fire when "this variable has changed". I could do this with a fake trigger and a living dictionary of changed ink variables that I would populate in my watcher callback and then read on each tick to compare against the name given as condition parameter, and that probably is what I will end up doing, but I found it very troubling to not really be able to give a parameter to my trigger condition. Something like this.Trigger(C3.Plugins.PLUGIN_ID_PLACEHOLDER.Cnds.VariableChanged, myvalue)

    TL;DR: Is there a way to give parameters to a trigger condition? If not, how hard would it be to implement?

SmugRainbowPony's avatar

SmugRainbowPony

Member since 9 Feb, 2021

Twitter
SmugRainbowPony has 1 followers

Trophy Case

  • 3-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

5/44
How to earn trophies