diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/pets/animations.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua index 35ff5b8..e49883e 100644 --- a/lua/pets/animations.lua +++ b/lua/pets/animations.lua @@ -61,6 +61,7 @@ function M.Animation:next_frame() self.current_image:delete(0, { free = false }) end if self.frame_counter > #self.frames[self.current_action] then + M.Animation.set_next_action(self) self.frame_counter = 1 end local image = self.frames[self.current_action][self.frame_counter] @@ -69,6 +70,21 @@ function M.Animation:next_frame() self.current_image = image end +function M.Animation:set_next_action() + local next_actions = { + crouch = { "liedown", "sneak", "sit" }, + idle = { "idle_blink", "walk", "sit" }, + idle_blink = { "idle", "walk", "sit" }, + liedown = { "sneak", "crouch" }, + sit = { "idle", "idle_blink", "crouch", "liedown" }, + sneak = { "crouch", "walk", "liedown" }, + walk = { "idle", "idle_blink" }, + } + if math.random() < 0.5 then + self.current_action = next_actions[self.current_action][math.random(#next_actions[self.current_action])] + end +end + function M.Animation:set_next_col() if self.current_action == "walk" then if self.col < self.popup_width - 5 then |