edited June 2017 in ORK Support
[IT'S PROBABLY A GOOD IDEA TO JUST SKIP TO THE LAST POST AND AVOID ALL MY BLETHER]


i'm using local combatant variables to generate and store extra information about each combatant

each combatant has "Use Object Variables" and "Local Variables" set true (although i've also tried using the "ObjectID" flavour too)

i don't actually define the variables themselves in the Ork Editor (although i have also tried that too), i do it from a bit of code that is attached to each combatant prefab and runs on Start

that bit of code first checks to see whether it's already generated details for the combatant during this particular play session. if it has done then it does nothing further; otherwise it goes off and does so, by executing a series of combatant.Variables.Set calls to randomly generate details for the combatant

that's all working fine. run the game and i can see that each combatant has an Object Variables Component, each of which contains their own set of randomly generated personal data

in the Save Game Menu Save Settings i've got Object Variables = Save, Spawned Combatants = Current (although i've also tried "All"), Game Variables = All with nothing excluded

so, i run the game. let's say that one of the characters gets a randomly generated actorName variable with a value of "John Doe"

i Save the game. close it. rerun it. now let's say his actorName has been generated this time as "Jack Sprat"

i Load the Saved game, and examine his Object Variables, and... his actorName is still showing as "Jack Sprat". in other words his actorName Object Variable hasn't been overwritten by the Saved actorName Object Variable containing "John Doe"
Post edited by HarryOminous on
  • this is the closest i've got to getting something to work (although obviously still no cigar):

    first, i removed my actor details generation script from the equation so that it didn't muddy up the waters any

    then, for each combatant i set "Use Object Variables" = true, and "Local Variables" = true

    i then manually added a string variable, in the ork editor, "actorName", set to, e.g. "A1", "A2" etc for each combatant

    run the game, save it

    go back into the editor, and manually change the value of each actorName to, e.g. "A1x", "A2x" etc

    run the game. load the saved game

    now clearly what i was expecting was that the values would all be reset to "A1", "A2" etc, and that does happen, but only for the player character. none of the other characters' data has been reset


    p.s. if i try the above exercise using the "ObjectID" form, then none of the data gets reloaded as expected, not even the player character's
  • I think that local variables aren't saved, actually. If you poke around the forums you'll probably find the discussion on it.
  • ok. that's a bit disappointing, but thanks for the info. i guess i'll just have to come up with some other way of storing that data
  • edited June 2017
    @Keldryn

    the solution i've eventually adopted is to not save the data at all

    for each new game i simply generate a unique random seed number (stored as an Ork global variable), and use that to create the random actor data, during each actor's Start function

    after a game reload, it will reload and use that seed number, and consequently regenerate the exact same set of local actor variable data again


    (well, that seems to work with my testing so far. although i'm sure there will be some gotcha that i've overlooked)



    (and, even as i typed that sentence i could see what that gotcha would be: some of the data i was generating was intended to be dynamically modified during gameplay, so the above technique isn't going to work for that type of data) (*sigh*)


    (BUT, as the data to be modded would just be booleans indicating whether or not a particular piece of information was known to the Player, i guess i could save that separately as a Combatant Status Effect, i.e. "Name Known" or whatever)


    (OR, i could just go off and write a mindless shoot-em-up, and be done with it...)
    Post edited by HarryOminous on
  • ugh

    and the OTHER gotcha is that the technique only works as long as it gets to process actors in the exact same order when saving as when reloading, and THAT, unfortunately, doesn't seem to be the case

    so, i either abandon the idea of generating random extra data for each combatant (which was going to be a core mechanic of the game), or i look into saving the data elsewhere, perhaps using Ork's Custom Save feature (which i've just now stumbled on)
  • sooooo... another post i've just stumbled on (from way back in 2014) discusses how to get, and set, Object Variables

    although i thought (but, i'm an old man, i think a lot of things that it turns out i hadn't actually thought) i'd tested that, i've tried again, and those DO seem to get saved per combatant. so, perhaps, that's the way to go?

    fingers crossed anyway...
  • ok. i think i'm back on track

    i'm using Object Variables, but not the Local kind. they're defined in Combatants/Object Variable Settings, using an ObjectID which i can reconstruct in the relevant bit of Actor Details Generation Code

    e.g. if the combatant is "Fred", their ObjectID would be "actorObjectVariable_Fred", and the relevant bits of code to get, or set, the variables would be something like this (where combatantOVKey would have been set to "actorObjectVariable_Fred", dataKeyId is something like "actorFirstName", and dataValue is the value to be set):

    ORK.Game.Scene.GetObjectVariables(combatantOVKey).GetString(dataKeyId);
    or
    ORK.Game.Scene.GetObjectVariables(combatantOVKey).Set(dataKeyId, dataValue);

    so far my tests have successfully saved, and then later retrieved, the generated combatant data. so, w00t! onwards and upwards!


    until the next setback
  • Actually, the variables are saved with the combatant data when using local object variables (regular object variables, i.e. with an object ID, are saved with the object variables).

    It might be that you just check or do whatever you do to soon ...
    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!
  • thanks gil, that's useful to know. i must admit i was a teeny bit surprised when keldryn suggested that local combatant variables weren't saved at all

    however if they are indeed saved then it's very likely that my problem was some kinda timing thing, like you said. i was (and indeed still am) processing the data in each spawned combatant's Start function. perhaps it would have been better to delay that until Update, or even done it by looping through the set of combatants in a separate script

    still, in any event, using the ObjectId as i'm using it now seems to work ok...
  • @gamingislove - Was there ever something about the Local object variables not getting saved? I could have sworn I read that in a post on here somewhere... something about having to specify an object ID and not check "Local."

    It did seem odd to me that they wouldn't get saved. ;-)

  • @Keldryn
    Yes, local object variables on combatants wheren't saved at the start, but it's been in there for quite some time already. But keep in mind that local object variables on other game objects will not be saved, only on combatants (with the combatant's other data).
    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.