Jump to content

LoadPostPass is not working


Recommended Posts

Hi everyone. I'm trying to make my own component so I'll be able to save prefab in some player. I used "LoadPostPass" for this

function BellOwner:LoadPostPass(newents, savedata)
	print("BellOwner:LoadPostPass")
    if savedata ~= nil and savedata.bells_guids ~= nil then
	
		for k,v in pairs(savedata.bells_guids) do
			local BellEnt = newents[savedata.bells_guids[v]]
			print(tostring("BellEnt = "..BellEnt.entity))
			
			if BellEnt then
				table.insert(self.all_bells, BellEnt.entity)
			end
		end
		
		if savedata.main_bell then
			local MainBell = newents[savedata.main_bell]
			
			print("MainBell = ".. tostring(MainBell.entity))
			
			if MainBell then
				self.main_bell = MainBell.entity
			end
		end
    end
end

It saves, and when the world is reloaded, self.all_bells and self.main_bell are nil.

I've added thi component using this 

AddPlayerPostInit(function(inst)
	inst:AddComponent("bell_owner")
end)

Any ideas how to fix this?

Edited by Cunning fox
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...