Jump to content

My Pets Mod - Change a Component Action

Recommended Posts

Hi Everyone =D,

So after the last update (Walter and Woby) a lot of things starter to crash in the mod I help maintain (My Pet) since Woby shares a lot of things with the critters code.
One of the changes implemented by Klei was how the game shows the Abandon action when near the Rock Den.
In order to avoid people abandoning Woby they made a check that if the pet is a container the abandon action will never show only the Pet Action.
klei files componentactions.lua

crittertraits = function(inst, doer, actions, right)
            if inst.replica.follower ~= nil and inst.replica.follower:GetLeader() == doer then
                if right then
                    if inst.replica.container then -- Added for wobysmall
                        table.insert(actions, ACTIONS.PET)
                    elseif doer.replica.builder ~= nil 
                       and doer.replica.builder:GetTechTrees().ORPHANAGE > 0 
                       and not inst:HasTag("noabandon") then
                        table.insert(actions, ACTIONS.ABANDON)
                elseif inst.replica.container == nil then
                    --V2C: @Scott: Should this always be available???
                    table.insert(actions, ACTIONS.PET)

This is a big issue since My Pet mod transforms the critters in a container by default (like Woby).
So my issue here is that I can't create a way to go around the check Klei implemented so the Abandon option never appears because as soon as the game detects the Pet as a container it will not show the Abandon.

What I thought I could do was to create a new Component Action in order to divert the check Klei did to the new one I create, the issue here is that I don't know how to create a new Component Action, and the tentative of copying one never worked. 
I tried to add the file componentactions.lua to the My Pet files, but I can't make the mod access that one instead of the one in klei files (I'm aware this might not be the best way to code a mod, but I was desperate xD ).

Any help with this will be very appreciated =D

My Pet Mod

Let me know if you need anything else in order to help me =)

Link to comment
Share on other sites

Thank you for the suggestion @rawii22 =D. 
At the moment we are trying to create a button that will appear bellow the adoption button when you adopt a pet near the Rock Den. Works great without caves, but is all broken when we add caves to the world =(. 
We are trying to figure out how can we make it work when we have caves enabled, but we are still a bit lost =(. 

Again thank you, we will take your advice into consideration =D

Link to comment
Share on other sites

Yeah, about caves, I noticed that a lot of aspects of mods don't work when they are enabled. I have a mod that uses a key up handler but it doesn't work with caves on. Doesn't make any sense to me; maybe it's some sort of ismastersim issue... no idea

Link to comment
Share on other sites

Hi again,
I'm still going around the issue in making the abandon button work when caves are enabled =(. 

I have attached the modmain file where the code is (The part of the code regarding this are lines #24 and  #25 and also from line #552 to #631).
As mention, it works well when caves are not enabled, but it doesn't work at all if the world have caves.

Some direction to what to look for would be very appreciated =) 
Thank you very much!

(I have also attached all the files of the mod in case something else is needed)

modmain.lua My Pet V2.95.8.7z

Link to comment
Share on other sites

Ok, well here's what I'm thinking. Recently, I've been working on a mod with my brother and when we got to the cave implementation, we learned a lot about how the game treats players when they are enabled. Any time caves are enabled, the host is treated as a client, meaning that the code will run on the server and may not affect any players... This changes how we use the ThePlayer since the game might not know who to refer to (I'm pretty sure the admin since they have console access). I don't remember an extreme amount of detail right now, but it's an interesting (and very very annoying) consideration when making server mods.

Edited by rawii22
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

  • Create New...