Save game data

  • #30, by BarneyFriday, 16. January 2015, 23:32 10 years ago
    You know what, yeah, I guess fade transition is to blame. I left it at default value, and it's something like 600 ms, if my memory doesn't fail me. I should've figured it out sooner.

    Newbie

    42 Posts


  • #31, by afrlmeFriday, 16. January 2015, 23:42 10 years ago
    Ah you mean because it doesn't say you need to add an "s" to the end of it? Actually the tables used to have an extra column just for saying "Interfaces" but I thought it was a waste of space that could be better utilized for the description column. I could edit the header names & add the "s" to the versions that need it.

    Not all of them have "s" on the end though.

    game for instance does not have an "s" on the end & fields/tables in game are accessed like so...
    game:getLink(VGameCurrentCharacter) -- returns current character
    


    Interfaces
    Characters
    Objects
    Animations
    Actions
    ActiveAnimations
    etc all have an "s" on the end of them when accessing their fields/tables.

    I'll look into updating them the morrow, it's a bit late now for me to try renaming them off the top of my head.

    P.S: you should check out the scripting wiki page for more insight into scripting in Visionaire Studio, as it explains how it works as well as providing various examples. However we haven't written up any information yet in regards to the new shorthand method for accessing/updating data structure tables/fields.

    Imperator

    7278 Posts

  • #32, by minibigsSaturday, 17. January 2015, 00:53 10 years ago
    Hopefully last question for a while ....
    If I do:

    local itm = getObject("Interfaces[main]"):getLinks(VInterfaceValues) -- store items in a variable
    local t = "Help me"

    This correctly runs & shows an interface value linked to of "test" which has VauleInt, 3 X random values & ValueString.

    Then what would the code be to write "Help me" back to to the "test" variable?

    I've tried table.insert(itm, t) which shows a value of -1 for the ValueString & playing around with various permutations of itm:setValue( ,etc , but all fail.

    Newbie

    79 Posts

  • #33, by afrlmeSaturday, 17. January 2015, 01:02 10 years ago
    The part with -- some text is a comment, you don't need to include that. I tend to include comments on most things to help me remember what it is for/doing & to provide insight for other people when I write/share scripts.

    Sorry, I'm a bit confused as to what you are trying to do. Could you please provide me with a more clear & in-depth explanation & example of what you are wanting to achieve?

    Imperator

    7278 Posts

  • #34, by minibigsSaturday, 17. January 2015, 01:02 10 years ago
    Thanks, I am working my way through the wiki & just trying things at the moment ... I'm fine when I can get one example to work ... good at generalising from a specific example... it's just getting that first breakthrough.

    I'm using the Editor Explorer as that has to be accurate, I know the Data Structure et al must be nightmares to keep up to date, it was just all a bit confusing for me as a rookie.

    Give me something straight forward like IBM mainframe assembler, etc & I'm your man.... Not played with tables / structured stuff for a while so gotta get up to speed with it.

    Newbie

    79 Posts

  • #35, by minibigsSaturday, 17. January 2015, 01:04 10 years ago
    Sorry, let me attempt to clarify.

    I set up a value called "test" in the "main" inventory interface. I'm trying to modify that value by writing text to it via Lua, not for any particular reason, just as a learning path.

    Newbie

    79 Posts

  • #36, by afrlmeSaturday, 17. January 2015, 01:32 10 years ago
    Ah.. so you want to add a string to the value?

    Note: values can be accessed globally by both longhand & shorthand or via direct linking...
    Values["test"].String = "hello world" -- global (shorthand)
    

    getObject("Values[test]"):setValue(VValueString, "hello world") -- global (longhand)
    

    getObject("Interfaces[main].InterfaceValues[test]"):setValue(VValueString, "hello world") -- direct link (longhand)
    


    For some reason the string of a value can only be defined in editor when when you create a value. There is no option for updating the string via action parts; it has to be done by Lua script instead. String values can be quite useful though as you can include them into displayed text by including inside of a displayed text action part.

    P.S: when using global methods for accessing/updating data structure tables need to make sure that all objects in the editor have unique names, otherwise you might get clashing issues.

    Imperator

    7278 Posts

  • #37, by minibigsSaturday, 17. January 2015, 02:09 10 years ago
    Thanks...

    This works fine, if I set up a value "main_test" with the string "not changed" in it & run:

    Values["main_test"].String = "hello world"
    print (f)
    f = Values["main_test"].String
    Values["main_test"].String = "hello world"
    print (f)

    The first print(f) shows "not changed" & the second shows "hello world" as expected.

    But when the game ends the value reverts to "not changed" i.e. it seems to be updating a locally exported copy maybe? ... but not the main VED ?

    Newbie

    79 Posts

  • #38, by minibigsSaturday, 17. January 2015, 02:19 10 years ago
    Sorry, I coped the wrong script lines, should be:

    f = Values["main_test"].String
    print (f)
    Values["main_test"].String = "hello world"
    f = Values["main_test"].String
    print (f)

    Newbie

    79 Posts

  • #39, by minibigsSaturday, 17. January 2015, 02:26 10 years ago
    I would also love to know the magic formula for including string variables in a displayed text action part.

    Newbie

    79 Posts

  • #40, by afrlmeSaturday, 17. January 2015, 02:44 10 years ago
    1. you should not be declaring global variables unless you need them to be global. add local before variables to contain them to that particular script/function.

    2. I don't know why you declared it twice or why you bothered to create the variable to be honest as you ended up creating an additional 2 lines & variables for not much reason at all - well from my point of view as I tend to code compact. Less is more; or so some people say...
    print( Values["main_test"].String )
    Values["main_test"].String = "hello world"
    print( Values["main_test"].String )
    


    3. Why would it change in the .ved? The save files are what store changes made to the game, not the .ved or .vis file (in case of compiled game). Those files only contain the raw data which the engine uses to make the game work. So if you did that & saved the game, then quit the game & launched the game then loaded from that savegame or autosave (whichever you saved with) then tried printing the value of the string, it should return "hello world" but if you try printing the value from a new game then it would return "", nil or empty - or something along those lines.

    4. See this page, for more information on displayed texts.

    Imperator

    7278 Posts