Jump to content

Recommended Posts

How do you edit existing animations without changing them for everyone?

Say I have a character named "custom" and want to replace idle_loop, idle_inaction, etc. with custom_idle_loop, custom_idle_inaction, or chop_loop with custom_chop_loop. Any animation really.

local makewrap = function(self, k)
  local fn = self._AnimState[k]
  local function fn_wrap(_, ...) return fn(self._AnimState, ...) end
  self[k] = fn_wrap
  return fn_wrap
end
local function HookAnimState(inst)
  local as = inst.AnimState
  inst.AnimState = setmetatable({
    _AnimState = as,
    PlayAnimation = function(self, anim, loop)
      anim = anim:gsub("monkey", "wokey")
      return self._AnimState.PlayAnimation(self._AnimState, anim, loop)
    end,
    PushAnimation = function(self, anim, loop)
      anim = anim:gsub("monkey", "wokey")
      return self._AnimState.PushAnimation(self._AnimState, anim, loop)
    end
  }, {__index = makewrap})
end

Here is a simplified solution that only hooks PlayAnimation and PushAnimation. Full solution needs to hook more.

Edited by Rickzzs
  • Like 1
1 hour ago, Rickzzs said:
local makewrap = function(self, k)
  local fn = self._AnimState[k]
  local function fn_wrap(_, ...) return fn(self._AnimState, ...) end
  self[k] = fn_wrap
  return fn_wrap
end
local function HookAnimState(inst)
  local as = inst.AnimState
  inst.AnimState = setmetatable({
    _AnimState = as,
    PlayAnimation = function(self, anim, loop)
      anim = anim:gsub("monkey", "wokey")
      return self._AnimState.PlayAnimation(self._AnimState, anim, loop)
    end,
    PushAnimation = function(self, anim, loop)
      anim = anim:gsub("monkey", "wokey")
      return self._AnimState.PushAnimation(self._AnimState, anim, loop)
    end
  }, {__index = makewrap})
end

Here is a simplified solution that only hooks PlayAnimation and PushAnimation. Full solution needs to hook more.

I was looking at stategraphs and wasn't able to come up with a solution. I'll have a look at this, thank you!

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