Jump to content

Recommended Posts

I created a new prefab and put in all the customary functions, heavily inspired by the crockpot code (which changed midway due to Forgotten Knowledge adding the new weird crockpot)

The game consistently crashes when I save it, either at each end of day or manually, if there is one of my custom prefabs present in the "done" state that is very analogous to the crock pot state.

I took a peek at the error logs but they are incredibly unhelpful; only thing I know is that my custom onSave function gets called and then the game crashes on the dumper file. The problematic call seems to be due to a DynamicShadow entry, but I didn't define nor use one throughout the whole prefab file. Can anyone give me some tips? Also, how do I read the dumper crash log?

I've attached the zipped mod and the latest crash log. This one was manually triggered by using c_save(). The relevant prefab is marblecounter, and the onSave function is inside its prepstation component.

 

server_log.txt Masterchef.zip

Edited by AndRay

Entities have shadows, and the DynamicShadow userdata is responsible for that. DataDumper cannot process userdatas.

Make sure that in your save functions, you aren't trying to get the game to save any entities. Such as in your prepstation.lua

You can read the dumper crash log just like the other ones, except you'll probably want to google what a tail call is in Lua. 

Edited by penguin0616
  • Like 1

Thanks for the info! I read a bit about tail calls but I didn't get it that well. Do you mean my save function is somehow level-recurrent and it crashes the stack?

Does that mean I can't save a container info with OnSave? If so, how do containers such as chests save their data? Because the code in the container component iterates and passes items as well. Or is it another call?

@AndRay 

30 minutes ago, AndRay said:

Do you mean my save function is somehow level-recurrent and it crashes the stack?

Nope. Just explains why you see "tail call" everywhere for the DataDumper crash.

30 minutes ago, AndRay said:

Does that mean I can't save a container info with OnSave? If so, how do containers such as chests save their data? Because the code in the container component iterates and passes items as well. Or is it another call?

You can. You just can't save entities. I suggest you take a look at :OnSave() for an example.

Edited by penguin0616
  • Like 1

Oh, I took a good look at the dumper and found what I was saving. I wanted to pass the last chef who used the crockpot (to test for dynamic recipes, something I want to do in the long future) This explains the call from the dumper. So thanks a lot for helping me; I would never have guessed this would be an issue.

On a related note, does a player's ID vary between connections and playthroughs?

17 minutes ago, penguin0616 said:

You can. You just can't save entities. I suggest you take a look at :OnSave() for an example.

 

Just now, AndRay said:

Oh, I took a good look at the dumper and found what I was saving. I wanted to pass the last chef who used the crockpot (to test for dynamic recipes, something I want to do in the long future) This explains the call from the dumper. So thanks a lot for helping me; I would never have guessed this would be an issue.

You can save entities, but it's a little bit different.

 

local function OnSave(inst, data)
	local references = {}
	
	if inst._plant ~= nil then
		data._plant = inst._plant.GUID
		table.insert(references, inst._plant.GUID)
	end
	
	return references
end

local function OnLoad(inst, data, newents)
	if data ~= nil then
		local plant = newents[data._plant] and newents[data._plant].entity
		if plant ~= nil then
			inst._plant = plant
		end
	end
end

You can take a look here at how I was able to do it.

  • Like 1

@Hornete You can't save the entity instance, which is what AndRay was attempting. You can save their GUID, which is what you have demonstrated. 
 

@AndRay Player ID does not change. 

Edited by penguin0616
  • Like 1

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
×
  • Create New...