My game has been having saving issues and i can’t figure out what causes it.
In rare situations, the savedata won’t save and errors this.
What is a cyclic table?
My game has been having saving issues and i can’t figure out what causes it.
In rare situations, the savedata won’t save and errors this.
What is a cyclic table?
A table is referencing itself somewhere.
Basically, this will throw an error when encoded to JSON:
local tab = {}
tab.self = tab
A cyclic table is a table that has a reference to the said table; it can’t function properly. Here in a scriptinghelpers link similar to your issue: https://scriptinghelpers.org/questions/28410/what-does-the-error-tables-cannot-be-cyclic-mean-and-how-can-i-fix-it
Is there a way i can make this a noncyclic table?
local Craft = PlayerData["Slot"..tostring(SlotNum)].Craft
PlayerData["Backup" .. SlotNum] = Craft
PlayerData["Slot"..tostring(SlotNum)].Craft = PlayerData["Backup" .. SlotNum]
I’m not sure but this should be fine
Table.Main = {}
Table.Main.BackUp = Table.Main
Although I feel rather silly having a Back Up in the same table.
And assigning Tables like that is also very weird as it doesn’t achieve anything
(You don’t have to do tostring, Lua automatically does it for you)
Someone told me i had to use {unpack(table)} to make it noncyclic and it worked!
What’s even the point of this? As far as I know, unpack returns a tuple and you’re catching it right back into a table. Unpack doesn’t work with dictionaries either, so unpack is just returning a blank value (not a nil).
It returns the things that are inside of the table and if i put those in a new table, it will be a noncyclic table.
That’s strange behaviour, or at least something that I’ve never heard of. Do you have an array or a dictionary? If you’re unpacking a dictionary, you won’t get anything back. If it’s an array, oh how I wonder how you got a cyclic reference in an array.
The backup is the table and the table is the backup, if you revert the slot twice.
You’ve lost me and that doesn’t exactly answer any of my questions or help me understand how what you did resolved your issue.