spideswine Posted July 20, 2017 Share Posted July 20, 2017 (edited) So I've been trying to make a simple action allowing baby beefalos to be petted, it works fine on a regular server, but if I add caves it stops functioning(instead the option to pet them is replaced with examine which doesn't really examine them either). Help would be greatly appreciated. Here's the code: local TheNet = GLOBAL.TheNet AddPrefabPostInit("babybeefalo",function(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("beefactions") end end) AddPlayerPostInit(function(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("beefactions") inst:DoPeriodicTask(0.25,function() if inst.Transform and inst.Transform.GetRotation then inst.old_rotation = inst.Transform:GetRotation() end end) end end) AddAction("BEEFPET", "Pet", function(act) if act.doer ~= nil and act.target ~= nil and act.doer:HasTag('player') and act.target.components.beefactions and (act.target.components.health == nil or not act.target.components.health:IsDead()) and act.target.components.sleeper and not act.target.components.sleeper:IsAsleep() then act.doer.components.beefactions:BeefPet(act.target, act.doer) return true else return false end end) AddComponentAction("SCENE", "beefactions", function(inst, doer, actions, right) if right then if inst.prefab=="babybeefalo" and (inst.components.health == nil or not inst.components.health:IsDead()) and inst.components.sleeper then if not inst.components.sleeper:IsAsleep() then table.insert(actions, GLOBAL.ACTIONS.BEEFPET) end end end end) AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(GLOBAL.ACTIONS.BEEFPET, "dolongaction")) AddStategraphActionHandler("wilson_client", GLOBAL.ActionHandler(GLOBAL.ACTIONS.BEEFPET, "dolongaction")) and the contents of beefactions: local Beefactions = Class(function(self, inst) self.inst = inst end) function Beefactions:BeefPet(victim, afflicter) local x = math.random() if victim ~= nil then victim.sg:GoToState("pleased") return true end end return Beefactions Edit: apparently addcomponentactions doesn't play well with other components, used tags instead. Edited July 21, 2017 by spideswine Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now