Jump to content

Recommended Posts

Hi! I've been trying to work on a test for a crockpot recipe mod for DST, using every online reasource I've found just to get it to try and function. However, I'm unable to load into a world with the mod and I don't know what my issue is. When the game crashes upon loading, I'm met with this screen:

image.png.09897515c61130487b7e494f10f58f09.png

This is the code for my modmain 

Spoiler

local monstermashpie =
	{
		name = "Monster Mash Pie",
		test = function(cooker, names, tags) return (names.monstermeat and names.monstermeat = 2) and (names.durian and names.durian = 2) end,
		priority = 20,
		foodtype = "MEAT",
		health = TUNING.HEALING_MEDLARGE,
		hunger = TUNING.CALORIES_HUGE,
		perishtime = TUNING.PERISH_FAST,
		sanity = TUNING.SANITY_MEDLARGE,
		cooktime = 3,
		tags = {"monstermeat"},
		floater = {"med", nil, 0.7},
	},

AddCookerRecipe("cookpot", monstermashpie)

 

And this is the code for my prefad, taken from the Cookpot Fix mod

Spoiler

local Assets =
{
	Asset("ANIM", "anim/monstermashpie.zip"),
    Asset("ATLAS", "images/inventoryimages/monstermashpie.xml"),
}

local function fn(Sim)
	local inst = CreateEntity()
	inst.entity:AddTransform()
	inst.entity:AddAnimState()

	MakeInventoryPhysics(inst)
	MakeSmallBurnable(inst)
	MakeSmallPropagator(inst)
	
	inst.AnimState:SetBank("monstermashpie")
	inst.AnimState:SetBuild("monstermashpie")
	inst.AnimState:PlayAnimation("idle", false)
	
	inst:AddTag("preparedfood")

	inst:AddComponent("edible")
	inst.components.edible.healthvalue = TUNING.HEALING_SMALL
	inst.components.edible.hungervalue = TUNING.CALORIES_SMALL
	inst.components.edible.foodtype = "GENERIC"
	inst.components.edible.sanityvalue = 0

	inst:AddComponent("inspectable")

	inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/monstermashpie.xml"

	inst:AddComponent("stackable")
	inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

	inst:AddComponent("perishable")
	inst.components.perishable:SetPerishTime(TUNING.PERISH_SLOW)
	inst.components.perishable:StartPerishing()
	inst.components.perishable.onperishreplacement = "spoiled_food"

	inst:AddComponent("bait")
	
	inst:AddComponent("tradable")
	
	return inst
end

STRINGS.NAMES.TESTFOOD = "Generic food"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.TESTFOOD = "Not that great."

return Prefab( "common/inventory/testfood", fn, Assets )

 

I'd love any help, and I'm sorry if this seems like an easy fix. I'm just really eager to make a nice mod for additional recipes for this game.

so at least in the prefab function there is the net part missing

 

inst.entity:SetPristine()

if not TheWorld.ismastersim then
	return inst
end

this must be placed BEFORE any component definition, in your case i would suggest after 

inst:AddTag("preparedfood")

not sure if tags added before or after, i have seen both.

 

but the error message sounds more like a syntax error, like if there is a bracket not closed. but i didn't find anything about that in your code. 

 

Edit: And I am not sure if a

AddCookerRecipe

function exist. maybe you should look inside some dst mods instead of the ds mods, they are a bit different.

Edited by krylincy

Okay I did a bit of research. The best recipe mod I found was the Waiter Crockpot mod. Really cool stuff, but I didn't know how much of the code would be necessary and how much I would need to change. Regardless, I changed my modmain and prefab to this.

 

Spoiler

PrefabFiles = 
{
	"monstermashpie"
}

local monstermashpie =
	{
		name = "Monster Mash Pie",
		test = function(cooker, names, tags) return (names.monstermeat and names.monstermeat = 2) and (names.durian and names.durian = 2) end,
		priority = 20,
		foodtype = "MEAT",
		health = TUNING.HEALING_MEDLARGE,
		hunger = TUNING.CALORIES_HUGE,
		perishtime = TUNING.PERISH_FAST,
		sanity = TUNING.SANITY_MEDLARGE,
		cooktime = 3,
		tags = {"monstermeat"},
		floater = {"med", nil, 0.7},
	},
AddCookerRecipe("cookpot", monstermashpie)

for k, v in pairs(monstermashpie) do
    v.name = k
    v.weight = v.weight or 1
    v.priority = v.priority or 0
end

local foodprefabs = {}
return monstermashpie

 

Spoiler

local Assets =
{
	Asset("ANIM", "anim/monstermashpie.zip"),
    Asset("ATLAS", "images/inventoryimages/monstermashpie.xml"),
}

local prefabs = 
{
	"spoiled_food",
}

local function fn(Sim)
	local inst = CreateEntity()
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	if TheSim:GetGameID() =="DST" then inst.entity:AddNetwork() end

	MakeInventoryPhysics(inst)
	MakeSmallBurnable(inst)
	MakeSmallPropagator(inst)
	
	inst.AnimState:SetBank("monstermashpie")
	inst.AnimState:SetBuild("monstermashpie")
	inst.AnimState:PlayAnimation("idle")

	inst:AddTag("preparedfood")
	
	inst.entity:SetPristine()

	if not TheWorld.ismastersim then
		return inst
	end

	inst:AddComponent("edible")
	inst.components.edible.foodtype = "MEAT"
	inst.components.edible.foodstate = "PREPARED"
	inst.components.edible.healthvalue = TUNING.HEALING_MEDLARGE
	inst.components.edible.hungervalue = TUNING.CALORIES_HUGE
	inst.components.edible.sanityvalue = TUNING.CALORIES_MEDLARGE

	inst:AddComponent("inspectable")

	inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/monstermashpie.xml"

	inst:AddComponent("stackable")
	inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

	inst:AddComponent("perishable")
	inst.components.perishable:SetPerishTime(TUNING.PERISH_SLOW)
	inst.components.perishable:StartPerishing()
	inst.components.perishable.onperishreplacement = "spoiled_food"

	inst:AddComponent("bait")
	inst:AddComponent("tradable")
		inst.components.tradable.goldvalue = 1
	
	if TheSim:GetGameID()=="DST" then
		MakeHauntableLaunchAndPerish(inst)
	else end
	
	return inst
end

STRINGS.NAMES.MONSTERMASHPIE = "Monster Mash Pie"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.MONSTERMASHPIE = "Not that great."

return Prefab( "common/inventory/monstermashpie", fn, Assets )

 

Now I can successfully load into the world for about twenty seconds before it crashes again. I tried spawning in my recipe using the console and it didn't show, so something's probably wrong with the prefab. I just don't know what.

I appreciate your help though, I'm super confused about what could be wrong. I bet it's something trivial.

okay great.

i do not understand what that snippet in your modmain should do

AddCookerRecipe("cookpot", monstermashpie)

for k, v in pairs(monstermashpie) do
    v.name = k
    v.weight = v.weight or 1
    v.priority = v.priority or 0
end

local foodprefabs = {}
return monstermashpie

The "AddCookerRecipe" function is okay i think, i found the on in the utils. but what it this for loop for? you already added monstermashpie to the cooker recipe. same question for the foodbrefabs {} (i think that line is not nessasary at all) and the last line, the return ... why this one. afaik the modmain is not returning anything.

so to sum up: put your addCookerRecipe function at the end, when all stuff whithin "monstermashpie" is done. delete the last 2 lines as they have no usage/function.

 

if that is still not helping, can you look up the log file for more information? are you testing with caves (als client) or without as host? 

Ah sure thing! Most of what was added was stuff I tried to copy and paste from other files I found. I've done a bit of a cleanup of the files, found here.

Spoiler

PrefabFiles = 
{
	"monstermashpie"
}

local monstermashpie =
	{
		name = "Monster Mash Pie",
		test = function(cooker, names, tags) return (names.monstermeat and names.monstermeat = 2) and (names.durian and names.durian = 2) end,
		priority = 20,
		foodtype = "MEAT",
		health = TUNING.HEALING_MEDLARGE,
		hunger = TUNING.CALORIES_HUGE,
		perishtime = TUNING.PERISH_FAST,
		sanity = TUNING.SANITY_MEDLARGE,
		cooktime = 3,
		tags = {"monstermeat"},
		floater = {"med", nil, 0.7},
	},

AddCookerRecipe("cookpot", monstermashpie)

 

Spoiler

 


local Assets =
{
	Asset("ANIM", "anim/monstermashpie.zip"),
    Asset("ATLAS", "images/inventoryimages/monstermashpie.xml"),
}

local prefabs = 
{
	"spoiled_food",
}

local function fn(Sim)
	local inst = CreateEntity()
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	if TheSim:GetGameID() =="DST" then inst.entity:AddNetwork() end

	MakeInventoryPhysics(inst)
	MakeSmallBurnable(inst)
	MakeSmallPropagator(inst)
	
	inst.AnimState:SetBank("monstermashpie")
	inst.AnimState:SetBuild("monstermashpie")
	inst.AnimState:PlayAnimation("idle")

	inst:AddTag("preparedfood")
	
	inst.entity:SetPristine()

	if not TheWorld.ismastersim then
		return inst
	end

	inst:AddComponent("edible")
	inst.components.edible.foodtype = "MEAT"
	inst.components.edible.foodstate = "PREPARED"
	inst.components.edible.healthvalue = TUNING.HEALING_MEDLARGE
	inst.components.edible.hungervalue = TUNING.CALORIES_HUGE
	inst.components.edible.sanityvalue = TUNING.CALORIES_MEDLARGE

	inst:AddComponent("inspectable")

	inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/monstermashpie.xml"

	inst:AddComponent("stackable")
	inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

	inst:AddComponent("perishable")
	inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST)
	inst.components.perishable:StartPerishing()
	inst.components.perishable.onperishreplacement = "spoiled_food"

	inst:AddComponent("bait")
	inst:AddComponent("tradable")
		inst.components.tradable.goldvalue = 1
	
	if TheSim:GetGameID()=="DST" then
		MakeHauntableLaunchAndPerish(inst)
	else end
	
	return inst
end

STRINGS.NAMES.MONSTERMASHPIE = "Monster Mash Pie"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.MONSTERMASHPIE = "Not that great."

return Prefab( "common/inventory/monstermashpie", fn, Assets )

 

I'm trying to run the game without mods, in addition here's the client_log. Is there any other files?

I can load into a world without much issue before the game crashes (I still can't spawn in my recipe or make it via crockpot), and I also can't generate a new world with the mod on at all.

client_log.txt

It doesn't seem to have worked, and now I'm having issues where I can't spawn into the world. The game crashes right before loading with what seems to be the same error codes.

Edit: I should mention I think the world itself breaks. I managed to spawn into a world and the result was the seasons constantly changing between winter and autumn and time freezing so it never became afternoon or night.

Edited by Zepavil

I actually got a friend of mine on a discord server to take a look at the whole folder and found some errors in the coding too, and not just in the modmain or prefabs. They've already taken care of it, and we're working through the kinks to try and get it to work. But yeah, thanks so much for the help! I'll post any updates with any further issues if we have any.

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