Jump to content

[Scripting - Tools] only usable on certain creatures?

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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