Jump to content

Recommended Posts

Quote

local function OnKill(victim,inst)
        if victim and victim.prefab then
            if victim.prefab == "catcoon" then
                inst.components.sanity:DoDelta(-300)
            end
        end
end
inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end )

I copied the code from Tutorial basic perks to make my character goes insane when they kill catcoons but got error: Variable 'inst' is not declared. :concern:

 

Also is "player.components.talker:Say("...")" is a correct code for DST? Since it doesn't appear in game.

Edited by Hiru315
Link to comment
https://forums.kleientertainment.com/forums/topic/143090-need-help-with-inst/
Share on other sites

Where is inst:ListenForEvent located with respect to your character code? You need to make sure inst actually refers to your character entity.

The talker code is fine as long as player is defined. You can use ThePlayer if you're doing console commands.

It (and the "onhitother" listener) go in your master_postinit function.

Also, you can shorten your code to just if victim and victim.prefab == "catcoon" then, since comparing nil to "catcoon" is okay.

Edited by Bumber64

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