How do plugins return data?

0 favourites
  • 7 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • I have looked at the plugin template, and under Parameter Types it lists things like:

    Number

    String

    CmpParam

    etc.

    These are for input (passed to the plugin).

    How are values passed back from the plugin call to the game? Either an action, like "connect()" or an event, such as "onError()"). I think events are called conditions in the SDK.

    If its possible pass data back, can a two dimensional array of numbers be passed back? If so, how, if no, is there a way to hack into arrays already defined in the project, and modify them?

    There is no mention of returning data in the SDK documentation that I can find, except for expressions.

    Many thanks for any help.

  • nutmix

    Using expression, check official websocket plugin, "expression:MessageText".

  • rexrainbow - good tip.

    I see that the flags are things like "ef_return_string". The is no ef_return_array. ef_return_any is an integer, float or string, according to the doc, so no way to return an array. I guess i could return JSON, or a coma separated string list, but parsing this is adding as much work than the plugin saves. I dont understand what ef_variadic_parameters are. These are designed for input, looks like the plugin system was not really designed to return data more complicated that a string or number. I need to return hundreds of numbers, unfortunately.

    The plugin stuff looks very clever, but pretty bewildering and daunting as i don't have the time to invest to reverse engine it from examples.

  • nutmix

    Yes, using JSON to pass array/hash table. There is a hash table plugin, you could use it to parse JSON string, or embed the parsing into your plugin.

  • nutmix - look at the source to the Array object. Instead of returning all the values at once, it has expressions to tell you how many values are available, and then an expression to get the value at an index.

    Conditions just return true/false directly from the condition method, and actions don't return anything.

  • Each plugin returns a packet of data, which is added to with a few defaults. Each plugin is guaranteed to always have the following data:

    name:The name of the plugin. This is also the key in the array, of the full list of plugins, and is placed here since that is not always available.

    module:The module that supplied the plugin.

    file:The actual file containing the plugin.

    path:The path to the file containing the plugin. This is useful for using secondary files, such as templates, css files, images, etc, that may come with a plugin.

    By using this above the plugin return the data always

  • Try Construct 3

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

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

    Using expression, check official websocket plugin, "expression:MessageText".

    <img src="smileys/smiley36.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)