Jump to content

How to check if "Eating" animation is playing?


Recommended Posts

So, I'm trying to create a mod where the player character will poop after eating.

 

What I'm trying to do here is check if the eating animation was played, if it's true then spawn a poop prefab in the player's location.

 

Here's what I got so far...

 

Apologies for my stupidity. This is the first time I've encountered this type of problem and I've never seen a single tutorial covering this subject. Also exhausted trying to find some answers in the web.
 

[codesyntax]function PoopAfterEating(player)

if (inst.AnimState:IsPlaying("eat") == true) then
local x, y, z = player.Transform:GetWorldPosition()
local poo = GLOBAL.SpawnPrefab("common/inventory/poop")
poo.Transform:SetPosition( x, y, z )
end
end
 

AddSimPostInit(PoopAfterEating)[/codesyntax] 

 

It always sends an error about a 'nil value'. I tried changing this code, turning it upside down, etc but nothing worked. I even tried to make this an entirely new EventHandler at one point.

 

So, yeah, any ideas on how to make this work? 

Link to comment
Share on other sites

Utterly unrelated to what you are asking (meaning doesnt check animations) but a good place to make your character poop due to eating, is to just set a listener for your hungerdelta.

 

I would prefer not to have a 3rd poop related mod on the workshop, but if you cant figure this out id be willing to just make a configurable mod to handle eating X amount of food to poop and upload it sometime this week. 

Link to comment
Share on other sites

there's a FAR more simple way to do this than running to look at the animations! buuuuut there's already my laxative mod... and seronis' scared poopless mod... I'm gunna have to agree with seronis about having a 3rd 'character pooping' mod o_o

Link to comment
Share on other sites

Why not just register a callback via Eater:SetOnEatFn?
 

Because only one of those can exist too.  So its not multiple hook friendly and i just personally hate using methods that dont play well with other mods.

 

I know how to circumvent the one hook limitation by storing the current registered callback,  registering your own, and calling the saved copy either before or after executing your own code.  But you cant promiss other mods will be as smart so its not reliable.  Best to avoid the "unreliable"

Link to comment
Share on other sites

@seronis I don't think the possibility of someone else's bad coding practices should prevent us from using simple and established methods to accomplish a task. It would help enforce better code if their mods caused incompatibilities and they had to fix it, rather than everyone else making it easy for them to get away with it. In the end, it's not your code that isn't reliable, it's theirs. Besides, someone could very well overwrite the Eat function itself and cause similar problems.

 

That being said, I think the oneatfn is intended for character-specific functionality. Listening for the oneat event sounds more reasonable for something like this either way.

Link to comment
Share on other sites

seronis Yeah, I saw the other "poop mods" in the workshop. I'm not gonna add this mod the Steam Workshop though. I'll never touch that unless I have something good (which is highly unlikely). The reason I'm checking animations for this mod is because I have something else in mind and I'm just using this mod as a test project. 

 

Corrosive Yeah, that's exactly what I was looking for. Can't figure out what keywords to use though. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...