-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LUA Scripts do not stay after script "Save and Play" #13
Comments
I believe this has to do with every object being given the same GUID on creation:
the guid being My solution has been to generate a new GUID for each object, something akin to the following:
I'm not sure what implications this has for TTS - e.g. what if a duplicate GUID is generated? The chances of this are very low (there are 1.3537087e+16 combinations of 6 digit chars) - but I'm not sure how the GUIDs are generated internally, and whether re-seeding math.random is bad? I'm not a LUA scripter! |
Hey, thanks for the kind words and nice find, I did not expect TTS to mess with unrelated object fields because of duplicate GUIDs :) The But since it seems to be problematic, I'll add random GUID generation - this will mean it shouldn't clash with any other GUIDs, and won't be a guarantee... but like you said, it's going to be a very slim chance. By the way, an easier way of generating a random GUID is just rolling a random number in its range (16 chars in 6 spots, so 16^6 which is equal to 2^24) and converting it to hex string. Uppercase/lowercase should not make a difference there. function random_guid()
local value = math.random(0, 2^24)
return string.format('%x', value)
end Thanks for the report, I'll fix that and add a test for this case sometime next week as I'm out for the weekend :) |
Hey! First of all, thanks for the awesome library - I've been using it to load a card game on TTS and it is great so far!
When using Decker to create a deck of cards with a different LUA script on each card, upon doing any other scripting and using the "Save & Play" button in TTS, all objects then get the same script.
To reproduce, use the following script (including Decker at the top):
then, without doing anything else, save the game.
Now, reload the game and check the cards - they should have the correct variables in the lua scripts.
Now, reload the game up, and before doing anything, click "Save & Play" in the script editor.
Now check the cards, the Lua scripts will both read
card = "A"
It is expected that the cards would read
card = "A"
andcard = "B"
The text was updated successfully, but these errors were encountered: