Jump to content

New component near finished, just need help with the replica


Recommended Posts

Alright I'm on the last steps of this before major testing. Below you will find two things, my component for tracking inspections and using those inspection to unlock recipes, and the replica for it.

inspectiontracker.luainspectiontracker_replica.lua

Feel free to keep/use these if you like them. It's not like I could stop you.

Unfortunatly, it doesn't work when the world is not mastersim, which is what I'm coming to you all for this time.

I have literally zero idea were to start turning this into a replica. Inside what I do have is this:

function InspectionTracker:RecipeUnlocked(recipe)
	if self.inst.components.inspectiontracker ~= nil then
		return self.inst.components.inspectiontracker:RecipeUnlocked(recipe)
	else
		return true
	end
end

Which by a run of logic says that if the player has the component redirct to that version of the function rather than using this one, and if it doesn't return true. It does the redirecting part when client is mastersim, as expected, but doesn't return true when client isn't mastersim. In fact it fails at this part of the modmain: "local knows_recipe = inspectiontracker:RecipeUnlocked(recipe.name)" where "local inspectiontracker =  self.owner.replica.inspectiontracker". It states that "inspectiontracker" is nil.

This will be my actual first time trying to make a replica of a component, so if anyone can give me a quick should/shouldn't do while I spend the next day or two reading the replica and networking tutorials again that would be sweet.

Thanks in advanced!

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...