N/A
So a common thing that I'm going to be doing in my game to change some defined paths that players may have differ to in their save file.
For example, in the first version of the game, I may have an atom like:
/obj/sword
where as in the next version, I might get smarter and create a new datum called:
/sword
is there a way before I call Read that the code can look at a save file and see if any paths in the file are still defined and if not, delete them. Usually, if you would do it with checking, you would get this error:
Warning: type read from file (/card/monster/MICH/the_phantom_knights_of_rugged_glove) is not defined Warning: type read from file (/card/monster/MICH/the_phantom_knights_of_rugged_glove) is not defined Warning: type read from file (/card/monster/MICH/the_phantom_knights_of_rugged_glove) is not defined Warning: type read from file (/card/monster/MICH/the_phantom_knights_of_rugged_glove) is not defined Warning: type read from file (/card/monster/MICH/the_phantom_knights_of_rugged_glove) is not defined runtime error: cannot append to list proc name: LoadFile (/mob/proc/LoadFile) source file: Saving and Loading.dm,13 usr: Dev (/mob) src: Dev (/mob) call stack: Dev (/mob): LoadFile() Dev (/mob): StartScreen(Dev (/mob)) Dev (/mob): enter()
Anyway to prevent this error and actually delete the undefined path?
What is being done here is that it pulls from the savefile certain variables. You can check things like so:
By checking the type and whether or not it exists, you can avoid incompatible data types. You can also just use istype() to check the type and make changes accordingly by typecasting it like so:
As long as StatsDatumNew holds all of the previous variables, procedures, and verbs as StatsDatum, it should run perfectly fine. Not even that, as long as you're only calling to this new variable for what it only has, it will work. Just don't check it for anything it doesn't have and don't call procedures it doesn't have.
Once you've made the new type cast, you can write to it again to overwrite the error.