Jump to content

Recommended Posts

So I'm trying to add a food type to my mod character. However, since the code used to do that differs between the normal game and Reign of Giants (for some reason), I can't have the code for one and have it work for the other.

 

So I try to do the code below, to make it check to see if RoG is enabled...

	if IsDLCEnabled(REIGN_OF_GIANTS) then		table.insert(self.preferseating, "NIGHTMARE")		table.insert(self.caneat, "NIGHTMARE")	else		table.insert(inst.components.eater.foodprefs, "NIGHTMARE")	end

...and it doesn't work. It acts like RoG isn't enabled, even if it is. I checked the dlcsupport_worldgen file, and that seems to be the variable it's asking for. Is there something I'm doing wrong?

@Patriarachnid, Long story short, RoG will be integrated into DST, it won't be DLC

 

so change

if IsDLCEnabled(REIGN_OF_GIANTS) then

to something like

if SEASONS.AUTUMN then--orif GLOBAL.SEASONS.AUTUMN then

you get the same result as what your looking for.

You can check if the feature exists.

if inst.components.eater.preferseating then --RoG version    table.insert(inst.components.eater.preferseating, "NIGHTMARE")    table.insert(inst.components.eater.caneat, "NIGHTMARE")else --non-RoG    table.insert(inst.components.eater.foodprefs, "NIGHTMARE")end

​I do so in other places of the code. For example:

	if inst.components.equippable.dapperness then --RoG version		inst.components.equippable.dapperness = TUNING.CRAZINESS_MED	else --non-Rog		inst:AddComponent("dapperness")		inst.components.dapperness.dapperness = TUNING.CRAZINESS_MED	end

​Another example: 

local Eater = require "components/eater"if Eater.TestFood then --RoG version	local old_TestFood = Eater.TestFood	function Eater:TestFood(food, testvalues,...)		if self.inst and self.inst:HasTag("stormcaller") and food.prefab and forbidden_foodset[food.prefab] then			return false		end		return old_TestFood(self,food,testvalues,...)	endelse --non-RoG	local old_TestFood = Eater.CanEat	function Eater:CanEat(food,...)		if self.inst and self.inst:HasTag("stormcaller") and food.prefab and forbidden_foodset[food.prefab] then			return nil		end		return old_TestFood(self,food,...)	endend

​etc

Edited by Maris

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