Jump to content

Recommended Posts

Friend of Woodside here: We tried looking at the code for the Razor, since it seems to be exactly what we want in this tool, but the problem is it doesn't seem to HAVE any code. The chain of modules its scripts reference just ends in an ACTIONS.SHAVE.

Edited by Zoshiru

@Woodside235, the following code is from actions.lua.

 

ACTIONS.SHAVE.fn = function(act)        if act.invobject and act.invobject.components.shaver then        local shavee = act.target or act.doer        if shavee and shavee.components.beard then            return shavee.components.beard:Shave(act.doer, act.invobject)        end    end    end 

 

 

This code points to the beard component. Check out the beefalo and see if they have a beard component on them, we know Wilson does.

@Kzisor
 

Doesn't really answer my question. I want to make a new equipable tool and I want the only valid targets to be sleeping beefalo and other players. I haven't found much useful code tracing the razor stuff.

@Woodside235, actually the code I posted did in fact answer your question. The way the razor works is it uses the Shave action, which is used depending upon whether the shavee has the beard component.

 

From the beefalo.lua main function:

    inst:AddComponent("beard")    -- assume the beefalo has already grown its hair    inst.components.beard.bits = 3    inst.components.beard.daysgrowth = hair_growth_days + 1     inst.components.beard.onreset = OnResetBeard    inst.components.beard.canshavetest = CanShaveTest    inst.components.beard.prize = "beefalowool"    inst.components.beard:AddCallback(0, OnShaved)    inst.components.beard:AddCallback(hair_growth_days, OnHairGrowth) 

 

The CanShaveTest from the beefalo.lua is what determines if you are able to shave the beefalo during the day or only at night.

 

I don't understand how the given solution didn't answer your question.

@rezecib

 

Thanks. New question: Is there also a way to make an item destroy itself if it's dropped, and have a player spawn with it if they're revived?

 

EDIT: Nevermind, I changed my mind about how I want to handle this.

Edited by Woodside235

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