edited July 2017 in ORK Support
I have two Global variables (as part of a Character Creation system):

Gender (bool)
Nation (float)

As I move through my CC event, I follow this path:

****beginning of event****
-> Destroy all of prefab 0 --test model
-> Destroy all of prefab 1 --test model
-> Destroy all of prefab 2 --Gender = False, Nation = 0
-> Destroy all of prefab 3 --Gender = True, Nation = 0
-> Destroy all of prefab 4 --Gender = False, Nation = 1
-> Destroy all of prefab 5 --Gender = True, Nation = 1
-> Destroy all of prefab 6 --Gender = False, Nation = 2
-> Destroy all of prefab 7 --Gender = True, Nation = 2
-> Destroy all of prefab 8 --Gender = False, Nation =3
-> Destroy all of prefab 9 --Gender = True, Nation = 3

Then:

Check if Nation = 0
-> if true, Check bool value of Gender
-> if true, spawn Prefab 3
-> if false, spawn Prefab 2
-> if false, go to the Nation check

Check if Nation = 1
-> if true, Check bool value of Gender
-> if true, spawn Prefab 5
-> if false, spawn Prefab 4
-> if false, go to the Nation check

Check if Nation = 0
-> if true, Check bool value of Gender
-> if true, spawn Prefab 7
-> if false, spawn Prefab 6
-> if false, go to the Nation check

Check if Nation = 0
-> if true, Check bool value of Gender
-> if true, spawn Prefab 9
-> if false, spawn Prefab 8

Then I have a dialogue that allows the player to do one of three things:

Change Gender ->
Check the value of the boolean ->
if successful (true) -> change to false
if failed (false) -> change to true
-> go back to the beginning of my event

Change Nation ->
Add 1 to the value of Nation ->
Check to see if this is equal to 4 ->
if successful (Nation = 4) -> change Nation to 0
-> go back to beginning of event
if failed (Nation != 4)
-> go back to beginning of event

Continue -> Go into the first scene of the game

NOW: for some reason, the Nation and the Gender are ALWAYS set to 0 and False, no matter what value I assign them in Game -> Game Settings -> Initial Game Variables, and are never changed by any of my logic.

To prove this out, I want a small dialogue on the side to display the values of the variables, but...

I can't seem to dope out how to include a variable's value in a dialogue string.

Any ideas? Also, do you see anything wrong with the above logic?

Any guidance or suggestions would be appreciated!!


Post edited by chainsawpenguin on
  • edited July 2017
    bool variables (e.g. for Gender): #varboolGender#
    float variables (e.g. for Nation): #varfloatNation#

    These (and all other) text codes can easily be added through the buttons above the text area, click on More and Data and select Game Variable to select different variable text codes.

    Make sure you're changing the variables on the correct origin and the variable keys match, e.g. gender and Gender are different keys.
    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!
  • Let me ask a follow up question:

    If I have a global variable (Gender) and I define it as true, then I change it within the event to be false, and I check it again, it should display as false, right? OR does it not commit the change to a global variable until the event ends? Would I be better off reading the global into a local, playing with the local in the event, and then updating the global variable at the end of the event?
  • Whatever global variables you change in the event will be updated automatically. If not, then well, I would be screw cause most of my events depend on that, and it's working fine here.
  • Hm.... then there's something fundamental i'm missing. I have a simple loop that should be incrementing a global float by 1 every loop, and it's always reporting that it's just zero.

    I have another where a bool should be alternating every loop, but it always evaluates to false.

    I MUST be missing something... Is there somewhere that I have to declare my variables, outside of the event, if they are global? I tried setting them up in Initial Game Variables in Game -> Game Settings, but that didn't seem to make any difference.

    Any ideas what I'm missing?
  • Okay, I'm completely stuck at this point. I've created a brand new blank game with only the latest Ork. I create a completely new event called float_test.

    Add->Value->Variable->Change Game Variables

    Inside CGV:

    Variable Origin: Global

    Add Game Variable

    Change Variable 0
    Value Type: Game Variable
    Value: TestFloat
    Remove: unchecked
    Type: Float
    Operator: Set

    Float Value
    Value Type: Value
    Value: 100

    Add->UI->Dialogue->Show Dialogue

    Dialogue Type: Message
    Wait: checked
    Use Speaker/Show Title/Output to Console: all unchecked
    Message: #varfloatTestFloat# is my value.

    Add->Value->Variable->Change Game Variables

    Inside CGV:

    Variable Origin: Global

    Add Game Variable

    Change Variable 0
    Value Type: Game Variable
    Value: TestFloat
    Remove: unchecked
    Type: Float
    Operator: Add

    Float Value
    Value Type: Value
    Value: 8

    This is then linked back to the Dialogue, so that it will show the current value of TestFloat incrementing: display value, increment it, display it again, etc., forever.

    And then when I run it, this ALWAYS reports a value of zero. I would expect it to start with 100 and then increment by 8 every time.

    This is as simple as I can get. I have no idea what I'm missing. Any ideas?
  • edited July 2017
    ahh I see now why it' not working for you. In the value type, change Game Variable to Value.
    Post edited by Shadow_Fire on
  • Oh, for goodness sake! That was it!!!

    I have no idea why I thought it needed to be a Game Variable. Maybe I got confused by the tooltip? What does it mean when it says:

    "Value Type: Select where the string value comes from:
    - Value: A defined value.
    - Game Variable: The value of a game variable (string).
    - Player Prefs: The value of a PlayerPrefs string variable.
    - Scene Name: The name of the current scene."

    What's the distinction between a Value and a Game Variable? I guess I thought the Game Variable was the value I wanted...

    In any event, I can now move forward! Thanks, all!
  • edited July 2017
    You are just one of the many people who had also made the same mistake :)
    GiL explained the difference in this thread.

    http://forum.orkframework.com/discussion/617/solved-game-variables-not-working
    Post edited by Shadow_Fire on
Sign In or Register to comment.