Jump to content

Recommended Posts

@SomeoneStrange Ok so one thing I noticed that might cause unintended behavior is you have your function set up on an if/elseif check. I would keep them as separate if checks so that they can both be run in the same action (so the instant the threshold is reached, it will trigger the CheckEdibleGems function).

-- REPLACE

local function RedGemfn(self)
	if self.inst.components.temperature.inherentinsulation < 100 then
		self.inst.components.temperature.inherentinsulation = self.inst.components.temperature.inherentinsulation + 20
	elseif self.inst.components.temperature.inherentinsulation >= 100 then
		self.edible_gems.redgem.bool = false
		self:CheckEdibleGems()
	end
end

-- WITH

local function RedGemfn(self)
	if self.inst.components.temperature.inherentinsulation < 100 then
		self.inst.components.temperature.inherentinsulation = self.inst.components.temperature.inherentinsulation + 20
	end
	if self.inst.components.temperature.inherentinsulation >= 100 then
		self.edible_gems.redgem.bool = false
		self:CheckEdibleGems()
	end
end

I also noticed that in your PurpleGemfn function, you have it set to turn the bluegem.bool to false instead of purplegem.bool. So I don't know if you tried the purple gem and it wasn't toggling off, that would be the reason (also could be that you were trying to tie it through the oneat function instead of the EaterCompPostInit I provided)

It could also even be the nature of how the inherentinsulation variable works, I'm not really to familiar with the temperature component so I don't know if there's an extra step you need to take to assign that properly. Do me a favor and just try the sanity code snippet I posted earlier and just see if that works for you and we can go from there.

Link to comment
Share on other sites

1 hour ago, w00tyd00d said:

local function RedGemfn(self) if self.inst.components.sanity then self.inst.components.sanity:DoDelta(-25) if self.inst.components.sanity:GetPercent() <= 0.5 then self.edible_gems.redgem.bool = false self:CheckEdibleGems() end end end

ya nothing happened with this code.
I am assuming it was suppose to drain my sanity
 

maybe there is a conflict between the modmain eat and the character prefab eat function

 

Edited by SomeoneStrange
Link to comment
Share on other sites

@SomeoneStrange Nope, found the problem lol

You're not calling your prefab by the prefab name :p you're trying to call it by the tag "DOLL" that you added. On line 147 in your modmain:

-- Replace

if self.inst.prefab == "DOLL" then

-- With

if self.inst.prefab == "scruffy" then

OR

if self:HasTag("DOLL") then

 

Edited by w00tyd00d
Link to comment
Share on other sites

2 minutes ago, SomeoneStrange said:

OMG thank you so much!
my bad.

Hey, it happens lol lemme know if you run in to any more trouble bud.

I do still recommend making the gem functions local to the EaterCompPostInit function tho, because otherwise it wont remove the _eater tag from your character immediately once the threshold is hit. You want to make sure the change happens before the check or else it'll take an extra gem for it to toggle off (since the oneat function happens after CheckEdibleGems function in this case).

Link to comment
Share on other sites

they are local to EaterCompPostInit?
 

function EaterCompPostInit(comp)
	local function RedGemfn(self)
		if self.inst.components.temperature.inherentinsulation < 100 then
			self.inst.components.temperature.inherentinsulation = self.inst.components.temperature.inherentinsulation + 20
		end
		if self.inst.components.temperature.inherentinsulation >= 100 then
			self.edible_gems.redgem.bool = false
			self:CheckEdibleGems()
		end
	end

But the player just needs to hover off the sixth gem and they wont be able to eat it.

Link to comment
Share on other sites

10 minutes ago, SomeoneStrange said:

they are local to EaterCompPostInit?

Haha well I meant the whole function be local to the EaterCompPostInit function. Only because I noticed you were using the "oneat" callback function in your character's prefab to increment the stats and by doing it there, that makes the increment happens after the CheckEdibleGems function.

So that means on the eat action that would fill your threshold, it checks first to see if its at the threshold (when it isn't yet) and doesn't set the bool variable to false. Then the oneat callback happens and it increments the arbitrary stat to the threshold, but your char will still have the _eater tag for that gem because the check's already run and didn't remove it, hence you'll need to eat another gem to update it. You know what I'm saying?

EDIT: Basically "oneat" happens too late :p and the reason I had to put the CheckEdibleGems call before anything else is because I used a wrapper for the original "Eat" function in eater (labeled as old_Eat above the function) so that it doesn't interfere with the inner workings of the original "Eat" function's code (makes your mod play a lot more friendly with other mods that append the same function). Which means you can either append things before or after the original code and if we were to try to do it after, the item's already been eaten lol.

Edited by w00tyd00d
Link to comment
Share on other sites

7 hours ago, w00tyd00d said:

Hey, it happens lol lemme know if you run in to any more trouble bud.

Hey one last problem when I load up the game it takes awhile for the animations to build.
And then one the mod selection tab (when creating a world/server) it says the mod crashed.
any thoughts?
it is on the steam workshop as Scruffy the Doll

 

Link to comment
Share on other sites

14 minutes ago, SomeoneStrange said:

Hey one last problem when I load up the game it takes awhile for the animations to build.

Err I'm gunna be totally honest, I don't really know too much as far how custom animations and the like work, I'm more of just a code guy myself :\ I can try to take a look at it for you but I can't promise anything as I've never dealt with the anim code myself

14 minutes ago, SomeoneStrange said:

And then one the mod selection tab (when creating a world/server) it says the mod crashed.

I assume this happens when you try to load your character on a world? If/when it happens again, can you post your server_log.txt from that world as well as your client_log.txt? I can try to take a look at them for you and see if they're coming up with anything in regards to errors involving your mod.

Edited by w00tyd00d
Link to comment
Share on other sites

3 minutes ago, w00tyd00d said:

post your server_log.txt from that world as well as your client_log.txt

The server log has not be modified for months btw.
I do not get a crash report it's just when I enable the mod I can load in a world and the mod is automatically disabled. And I have tried it on new worlds.
In the mods list it says all the others are disabled in grey yet my mod reads CRASHED! in red

client_log.txt

server_log.txt

Link to comment
Share on other sites

6 minutes ago, SomeoneStrange said:

how would you make a character have a science level of 2?

As far as I can tell you only need to add the following line to your character prefab and it should work:

inst.components.builder.science_bonus = 2

-- These options also exist

inst.components.builder.magic_bonus = <num 0-2>
inst.components.builder.ancient_bonus = <num 0-2>
inst.components.builder.shadow_bonus = <num 0-2>	-- the shadow tab is Maxwell exclusive

And hey, don't be afraid to give a pal a shoutout for the help ;) 

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