edited February 2022 in ORK Scripting
How to get/set equipment/item variables via script? (ORK 3)
Post edited by sherzh on
  • Generally, you can access the variables of an equipment, item or ability (if you already have it's instance) via it's Variables property, e.g.:
    instance.Variables.Set("key", value);
    The value is the value you want to set, e.g. a bool, int, float, string or Vector3 variable.
    The instance is an EquipShortcut, ItemShortcut or AbilityShortcut - all implementations of the IShortcut interface.

    Now, how to get those instances depends on what you want to access, e.g. an equipped equipment (via the combatant's Equipment property) or something from the inventory (via the combatant's Inventory property).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Yep, thanks, got it! But if this value does not change during the game, i.e.
    I set it in the editor and don't touch it anymore. Is it possible to somehow take this value? I know that a separate asset is created for each object, doesn't it store this information? I mean, I don’t see the point in finding the object somewhere (in the combatant’s inventory or equipment), since it has a static value.
  • edited February 2022
    There is a difference between editor and playing.
    The editor data is part of the asset, the individual instances in-game all have their own unique variables that can be changed.
    Edit: So, in the editor you basically define the default/start variables of the equipment, they'll be used in-game when the equipment instance is created - afterwards, each equipment has it's own unique variables that can be changed without interfering with others.

    Changing stuff in the editor is completely different, as you need to change the settings - which is a lot harder and more complex to do.
    I'd recommend to use variable change templates instead.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I remember doing something similar in the Opsive Ultimate Inventory System. It also creates a separate asset for each object. I just attach this asset in the inspector to a variable (_itemDefinition) and can easily access any of its values.

    For example

    _pullSpeed = _itemDefinition.GetAttribute<Attribute<float>>(InventoryDatabaseNames.FishingRod.pullSpeed).GetValue();
Sign In or Register to comment.