skittles sour Posted October 12, 2021 Share Posted October 12, 2021 Hi, so I'm trying to do a Hamlet caves mod, and one thing I'm trying to correct, is to make it hamlet seasons in the caves. I found out that I can use the SaveGameIndex:GetOriginOfTravel() == "porkland" to check whether the current cave is generated by a Hamlet world. But when I descend to the level of the ruins, the function returns simply "cave". Is there a way to determine the origin of the previous level, or would I have to save this data by a class post construct to the saveindex.lua or something? Link to comment https://forums.kleientertainment.com/forums/topic/134406-the-savegameindexgetoriginoftravel-function/ Share on other sites More sharing options...
skittles sour Posted October 27, 2021 Author Share Posted October 27, 2021 (edited) Okay so a really easy solution is to add a component to the player since the player's data is reloaded when you travel to a new world: local WORLDS = { porkland = true, shipwrecked = true, forest = true, } local World_Traveller = Class(function(self, inst) self.world = "forest" local prefab = GetWorld().prefab if WORLDS[prefab] then self.world = prefab end end) function World_Traveller:OnSave() local data = {world = self.world} local aporkalypse = GetWorld().prefab == "porkland" and GetWorld().components.aporkalypse if aporkalypse then print("saving aporkalypse data in the world traveller component") data.aporkalypse = aporkalypse:OnSave() for k, v in pairs(data.aporkalypse) do print(k, v) end end local manager = GetSeasonManager() if manager.seasonmode == "plateau" then print("saving porkland season data in world traveller component") data.porkland_season = GetSeasonManager():OnSave() for k, v in pairs(data.porkland_season) do print(k, v) end end return data end function World_Traveller:OnLoad(data) local prefab = GetWorld().prefab if WORLDS[prefab] then -- in a main world self.world = prefab elseif data and data.world then -- from a main world self.world = data.world end if self.world ~= "porkland" or WORLDS[prefab] then return end -- specific porkland fixes: local aporkalypse = GetWorld().components.aporkalypse if aporkalypse and data.aporkalypse then print("loading aporkalypse data from the world traveller component") for k, v in pairs(data.aporkalypse) do print(k, v) end aporkalypse:OnLoad(data.aporkalypse) end local manager = GetSeasonManager() if data.porkland_season and manager.Plateau then print("loading porkland season data from world traveller component") for k, v in pairs(data.porkland_season) do print(k, v) end manager:Plateau() manager:OnLoad(data.porkland_season) manager.OnLoad = function() end -- nullify this function after using it. end end return World_Traveller Edited November 3, 2021 by Bad Willow 1 Link to comment https://forums.kleientertainment.com/forums/topic/134406-the-savegameindexgetoriginoftravel-function/#findComment-1507973 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now