edited December 2023 in ORK Scripting
hello,
sorry if this is a noob question, but i coudlnt seem to find an answer
i would like to chagne object variable's variable "isActive" from true to false when i pressed Esc Key (including closing UI and resuming the game) but i couldnt figure which library to use.

so far im using https://forum.orkframework.com/discussion/532/object-variable-control-via-code which is a very old thread as reference but i notice the library has changed a lot. i couldnt get the parameters and functions used there

using GamingIsLove.Makinom.Components;
and i put ObjectVariablesComponent objectVariable; in the editor, but i couldnt find a way to change the variable.
i tried these but they dont work
objectVariable.settings.GetHandler().Set(_OBJVARIABLENAME, false);

objectVariable.Handler.Set(_OBJVARIABLENAME, false);

VariableHandler handler = ComponentHelper.ToVariableHandler(objectVariable);
handler.Set(_OBJVARIABLENAME, false);
can you help me with this?

thank you!
Post edited by rmagn on
  • objectVariable.Handler.Set(_OBJVARIABLENAME, false);
    That should work, the Handler property of the component gives you access to the VariableHandler holding the variables.

    VariableHandler handler = ComponentHelper.ToVariableHandler(objectVariable);
    handler.Set(_OBJVARIABLENAME, false);

    Should also work on pretty much anything that can have variables (game object, combatants, abilities, etc.).

    Is _OBJVARIABLENAME set to the correct variable key?
    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!
  • edited December 2023
    hello,
    it works now , thank you !

    btw which one is more efficient or flexible?

    if i want to change variable of specific object ID like in schematic, is there specific function for that?
    for example like a function that has 3 parameters
    string object id, string key, bool value
    or i should declare the object first into objectVariable?
    Post edited by rmagn on
  • You can directly get the VariableHandler for an object ID like this:
    VariableHandler handler = Maki.Game.GetObjectVariables("objectID");
    You can first make a check if they exist, as otherwise getting the variables will create a new handler in any case:
    if(Maki.Game.ObjectVariablesExist("objectID"))
    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!
Sign In or Register to comment.