[SOLVED] Setting a values string via Lua throws an error

  • #1, by sebastianFriday, 13. May 2016, 21:28 8 years ago
    Hello Fellas. Im right here at coding my lua save menu and have difficulties to get dynamically setting a values string working.

    So i want to set the Value saveslot_X to a specific string where X is a number which is chosen before and saved to the value "selected_savestate".

    The script:
    local savestate = "saveslot_"..Values["selected_savestate"].Int
    print(savestate)
    Values[savestate].String = Values["key_input_text"].String
    


    the print gives the correct output into the console.
    The last line throws an error: Error: Unknown data-field "String".
    The issue seems to be in the part left from the "=" which is "Values[savestate].String"

    If i hardcode the savestate into saveslot_3 for example everything works...
    Values["saveslot_3"].String = Values["key_input_text"].String
    



    any ideas?

    Thread Captain

    2346 Posts


  • #2, by sebastianFriday, 13. May 2016, 21:56 8 years ago
    Ooouuhhh.. derping around today grin
    the selected_savestate int was set to 0 right before i executed the script.
    And saveslot_0 doesnt exist

    Thread Captain

    2346 Posts

  • #3, by afrlmeFriday, 13. May 2016, 22:14 8 years ago
    Nope save slot 0 only exists if you create a save in slot 0, but it's not recommended as I think you can only query from slot 1 via the if save exists in slot #? action part.

    Anyway... it happens to the best of us. I've been having fun myself the day as I can't get the editor to run on windows. I open up a ved & it crashes after I click a few times anywhere in the editor. Tried restarting my laptop, tried running anti-virus scan (was clean). Tried uninstalling the editor, re-downloading from here & re-installing & still no dice.

    Synced everything to my dropbox account & over onto my mac. Made sure I was running VS 4.2.5 & opened up ved in that & it's working fine. No idea why it's being an arse on my windows machine. I can work on it on the mac, but I don't like cross-polluting my ved files & would rather stick with windows until I need to debug / export a mac version, plus the mac version of the editor seems to have some weird bugs with the text / number input boxes.

    Imperator

    7278 Posts

  • #4, by sebastianFriday, 13. May 2016, 22:28 8 years ago
    Right now the script above just writes the string i entered via keyboard to a stringvalue depending on which slot value was set before entering the text.
    No autosave file (bookmarkXX.dat) included here in this part wink
    ------
    What i have sometimes is that I change a script, save it with cmd+s, (but it doesnt get saved). And i am sitting there hours and hours, changing lines from a script which dont get applied and run into errors and i dont know why it fails.
    After restarting VS and look into the script: nothing changed since the beginning...

    Thread Captain

    2346 Posts

  • #5, by afrlmeSaturday, 14. May 2016, 00:03 8 years ago
    Yeah. Write them in sublime text or github atom & copy / paste them in. wink

    Imperator

    7278 Posts