Forum rules - please read before posting.

Attaching MetaData to variables.

Hi
Our game has various variables. Our "Stat" system will use variables.
When the variable changes, other things should also happen (ie a +5 Love above the above the players head in the color red). The "Love" and Red color are different for each "stat" variable. There will be other things beyond name and color.

IE: We need to associate metadata with variables.

My plan to do this is
1. These variables will link to a custom script (so code can be notified)
2. A mapping of VariableID -> MetaData scriptable object/class exists.
3. When the code is notified a variable changed, it will lookup the ID in the mapping and, if required, use the metadata to do additional things

Does this approach make sense?

IMO: It would be nicer if GVARs could
1. Have a optional scriptable object associated with them, as meta data on variables seems like a typical thing games would need
2. We could extend GVAR to add our own custom variables (types)

(Maybe the above exist and Ive missed how to do it?)

Thanks as always

Comments

  • Situation understood, but sadly it would be more of a case of having a script that references the variables by ID.

    As an alternative to variables, however, is it possible to consider Inventory items? They have much more in the way of extentions, because they can be categorised, have properties defined, and changes to those property values will be stored in save-game files.

    For example, a Stat item could have Name and Color properties, that would be Love and Red for your example item.

  • Thanks for the response.

    I considered (and use Inventory items), but I/Design really like the easy of using the variable actions to add/compare values - we have alot of stats :).

    I'll check to see if the two (stats + inv) can somehow be used together. However, I wanted to avoid writing my own actions to change stats when the variable action already does all that.

  • So Inventory + Custom Properties looks promising. They work great for compile time properties (color, display name).

    However I'm stuck on the actual Value for the Love stat. We need to change it and compare to it at runtime. After a cursory, but not detailed, review - I dont see any action to assign/compare a custom property on a script.

    How would you recommend modifying the actual property for Love. Would that be a normal variable? Or could it be contained in the inventory as a property. If so, how do we modify it .

    Note: I do see Inventory: Property to Variable (and vv) but dont understand when/how to use this yet.

    (And to be clear, I can write my own actions to do all this, but id love to do it the AC way without customization)

  • Under the hood, inventory properties are a special kind of variable - so they have all the features/behaviour of regular variables as well.

    The Inventory: Property to Variable lets you transfer a property's value to/from a Global Variable, so that it can be checked/set using regular Variable Actions before being put back.

    If you want to modify the property directly, you can - through script. If you right-click the field's label in the Inventory Manager, it'll give you an API reference you can use in your code.

  • Yes, thats how I thought it worked. Thanks for the response.

    However does the Inventory: Property to Variable need to be used each time you want to change, or check a value? (ie synced before any use)

    Or does it only need to be run once?

    If it needs to be run every time we can do that, but it seems very error prone as if someone forgets to the value will be out of date.

    (OOO this week or I would try, I will regardless when I get back)

  • It needs to be used each time. I'd recommend creating a custom Action if you want to frequently access it, but otherwise use parameters to create a generic ActionList that can be used each time you want to updated it. That way, you can avoid duplicating such Actions and only have a single set.

  • Sounds good. Thanks!

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.