PDA

View Full Version : Reset() after Loading



RaoXy
10-01-2017, 09:09 AM
Hi,
actually I don't know if it's a real bug.
I use reset() function to bring all the cards back into decks. However if I take some cards, then save and load the game, reset() will bring back only those cards taken after last loading, leaving the others on the table.
Should I save something in onSave() function?

To workaround this, I use the onObjectLeaveContainer() to save a deck->card map (using two tables), then on reset I loop over one table to detect those cards 'mapped' to the source deck and move them to the deck position. Finally I use onObjectDestroy() to detect cards that will be deleted, and remove their reference from the two tables. Seems working but I don't know if it's a stable workaround.
(I use the onSave()\onLoad() to keep these two tables)

Is this a bug or am I missing something?

Flolania
10-01-2017, 01:11 PM
think about it.. after your save your game and load it, the cards that were out were its own deck (maybe you want to reset to this new deck instead, how does it know). Reset only works during the session for those decks that you make. You'll have to save the cards and reset them via scripting like you're doing.

RaoXy
10-01-2017, 03:40 PM
I thought the card-deck link would stay over loading by default, because I don't know where game stores these references. (Anyway I lock every card dropped to the table, to prevent them to create another deck)
So I could use just my method instead of reset().
Guess I'm in the wrong section then...thanks!