P.P.P.S: just remembered... definition scripts are loaded on game launch, so after loading from a save, you may need to reload the script. try setting it as an execution script & calling it after game load or as needed. if you plan on doing that then it might be a good idea to set your tables up as temporary tables.
Ok, doing this does solve the problem. But using command scripts isn't functional when I want to pass arguments to my functions. (or at least I haven't thought of a way to do that now
)
I've done some further poking and I think I've found what the issue is. I am however unsure whether this is a bug or by design.
Ok, so here’s what’s happening --
I’ve got these variable definitions at the start of one of my definition scripts:
booksol = "12345678910"
feedback = getObject("Values[PuzzleFeedback]")
allin = getObject("Conditions[B10Inserted]")
tblOuts = {}
tblOuts["one"] = getObject("Conditions[B1Out]") -- indices for testing, table has multiple entries
tblOuts[1] = getObject("Conditions[B1Out]")
testvar1 = getObject("Conditions[B1Out]")
I set my logging level to ‘Info’ and ran the game. Now using the tab-console I print the following to the log file:
Console command: EXEC print(booksol, feedback, allin, tblOuts[1], tblOuts[“one”], testvar1, tblOuts)
I did this at different times:
Test1. In the main menu, directly after pressing F9 in VS.
Test2. Directly after starting a new game from the main menu (first scene).
Test3. Directly after loading a game (note the results are the same whether I load from the main menu, or load after starting a new game)
Here’s the results:
Test1 -- 01:15:08: 12345678910 PuzzleFeedback (20,1) B10Inserted (10,33) B1Out (10,44) B1Out (10,44) B1Out (10,44) table: 128CC8E8
Test2 -- 01:15:53: 12345678910 PuzzleFeedback (20,1) B10Inserted (10,33) B1Out (10,44) B1Out (10,44) B1Out (10,44) table: 128CC8E8
Test3 -- 01:16:35: 12345678910 PuzzleFeedback (20,1) B10Inserted (10,33) nil nil B1Out (10,44) table: 128CE170
Right. So I’m guessing that one of two things is happening here; either the tables are cleared and not populated again after loading or the info in tables isn’t being properly saved. Maybe someone with better VS knowledge can explain this behaviour to me. For all I know I’m the one responsible.