Tim

Member
Hello I was wondering if someone could explain what the versioning at the end of a script means excatley.
And what would be so important about it? Why would you have to increase this for . I have read if you modifiy the file you would increase this ? Thanks for any answers guys just trying to understand this clearly.
 
There is no versioning at the end of a script.
A script is just a class, nothing more or less.

I assume you mean the Serialise and Deserialize methods for saving and loading data about a script.

You dont have to, but people store a version here so that an old version of the data can be loaded then saved in the new format.
if you read thru the code you will notice Deserialize does lots of if (version > X) load this etc.

If you dont store a version, then you cant add any new fields or properties to be saved without wiping first.
 
If you dont store a version, then you cant add any new fields or properties to be saved without wiping first.

This is partially true. There is a way, but some might wonder why go through even more trouble.

Well, let's say you have a script like PlayerMobile that has been hacked and slashed and glued together so that it looks like a mess and goes all over the place with the serialization. You might be daunted to try and add anything to it, for fear you will break it. However, there is one method that will preserve saves, AND let you completely rewrite the serialization, but it's a multi-step process.

1. First, you start with a working script. You have Serialization that writes all the values in the current script, and Deserialization that reads everything back. As long as it works, it will do for our purposes.

2. Next, you add your code, and rewrite the ENTIRE Serialization code ONLY. Very important that you do NOT change the Deserialization yet. What you want to do is load the original values in the exact current order that they were last saved.

3. Now, at the VERY BOTTOM of the Deserialization, you INITIALIZE the new variables. Just put first default values in. This will NOT be the final version of this script.

4. Next, start the server. It should load exactly what was saved, plus initialize the new variables.

5. Now, SAVE and SHUT DOWN the server. Do NOT restart, or everything will crash. What you are doing now is saving the new variables using the Serialization script you wrote. The saves will now have the new code.

6. Next, rewrite your Deserialization code to match the Serialization steps in the exact order they were saved.

7. Last, load the server up, and it should work fine. Save, Restart, Reboot, etc. should all work fine.

Let me know if there are any questions on this process, as it takes most people a while to grasp it all.
 
This is partially true. There is a way, but some might wonder why go through even more trouble.

Well, let's say you have a script like PlayerMobile that has been hacked and slashed and glued together so that it looks like a mess and goes all over the place with the serialization. You might be daunted to try and add anything to it, for fear you will break it. However, there is one method that will preserve saves, AND let you completely rewrite the serialization, but it's a multi-step process.

1. First, you start with a working script. You have Serialization that writes all the values in the current script, and Deserialization that reads everything back. As long as it works, it will do for our purposes.

2. Next, you add your code, and rewrite the ENTIRE Serialization code ONLY. Very important that you do NOT change the Deserialization yet. What you want to do is load the original values in the exact current order that they were last saved.

3. Now, at the VERY BOTTOM of the Deserialization, you INITIALIZE the new variables. Just put first default values in. This will NOT be the final version of this script.

4. Next, start the server. It should load exactly what was saved, plus initialize the new variables.

5. Now, SAVE and SHUT DOWN the server. Do NOT restart, or everything will crash. What you are doing now is saving the new variables using the Serialization script you wrote. The saves will now have the new code.

6. Next, rewrite your Deserialization code to match the Serialization steps in the exact order they were saved.

7. Last, load the server up, and it should work fine. Save, Restart, Reboot, etc. should all work fine.

Let me know if there are any questions on this process, as it takes most people a while to grasp it all.
Thank you both for the response very helpful
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back