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
Add an OnSave() #28
Comments
This should be possible to add, with gamehook there is a problem because onload is called too early and sometimes it didn't hook or game overwrite hook. That's why playmaker is hell for modders.
|
I tried that and it does not solve my issue :/ The gamehook injects properly to saving but some objects like the ratchet set and car parts save too early i think. when i run my save function i can see all objects are teleported to the correct location at the player, but as soon as the game goes to main menu and i load my save, the objects are back at the wrong location. So i think what i need is an OnSave that runs before the game saves so that i can set the location before the game tries to save. |
I don't know if it is possible to hook before main save, by hooking you just add functions which save function call, but this call will always be after main function for saving. Best way is to use your own save file to store correct position and load this file back from onload, and less chance to corrupt main save accidentally |
The way msc saves items is very weird, so im not sure how i would make it work. I would have to make a copy of the gameobject variables and then delete from the world to prevent it saving in items.txt and then storing the whole gameobject in my own save data? Not sure if it's possible to do that. Right now I'm just moving objects out of map and removing physics so it stays in position, and when you save it sets the position back to player so that it saves to that location, but yeah some objects stay out of map and become lost :/ |
Only world position you need to save, (x y z) and then load position from file and while loading just transform objects to loaded values. I give some example tomorrow |
Not so easy i think because of the way msc saves items. If i want to load an item i need to restore all values of the gameobject, not just instantiate a new at the location, otherwise it will forget the values. Update: Ok I think objects that have (Clone) in the name are being handled differently in the game code, so they dont save to items.txt, so most of them must be saving location before my code runs first which is why only some objects dont save properly. |
Maybe do something like this, you transform them to specifed (x y z) coordinations? And that is saved instead of going back to previous position. So in onload search for any objects in this wrong position and then transform them back to normal position. http://answers.unity3d.com/questions/383671/find-gameobject-at-position.html |
Yeah exactly what I did, i normally have items at location (0,100000,0) and on save i move objects to player, but some objects save too early so they appear at (0,100000,0) after loading, so I just check for those objects and relocate to player :D |
Would be nice if we could have an OnSave() that runs before the game saves. I'm having problems with items not saving the correct location using the GameHook many mods use to save custom items, normal items seem to not always save properly. You know what i mean? :D
The text was updated successfully, but these errors were encountered: