summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua84
1 files changed, 14 insertions, 70 deletions
diff --git a/api.lua b/api.lua
index 38efd6c..4bb268c 100644
--- a/api.lua
+++ b/api.lua
@@ -1,5 +1,5 @@
--- Mobs Api (5th March 2017)
+-- Mobs Api (6th March 2017)
mobs = {}
mobs.mod = "redo"
@@ -133,85 +133,29 @@ get_velocity = function(self)
end
-set_anim = function(self, anim_start, anim_end, anim_speed, anim_name)
-
- if not anim_start or not anim_end then
- return
- end
-
- self.object:set_animation(
- {x = anim_start, y = anim_end}, anim_speed or 15, 0)
-
- self.animation.current = anim_name
-end
+-- set defined animation
+set_animation = function(self, anim)
+ if not self.animation then return end
-set_animation = function(self, type)
+ self.animation.current = self.animation.current or ""
- if not self.animation then
+ if anim == self.animation.current
+ or not self.animation[anim .. "_start"]
+ or not self.animation[anim .. "_end"] then
return
end
- self.animation.current = self.animation.current or ""
-
- if type == "stand" and self.animation.current ~= "stand" then
-
- set_anim(self,
- self.animation.stand_start,
- self.animation.stand_end,
- self.animation.speed_stand, "stand")
-
- elseif type == "walk" and self.animation.current ~= "walk" then
-
- set_anim(self,
- self.animation.walk_start,
- self.animation.walk_end,
- self.animation.speed_walk, "walk")
+ self.animation.current = anim
- elseif type == "run" and self.animation.current ~= "run" then
+ self.object:set_animation({
+ x = self.animation[anim .. "_start"],
+ y = self.animation[anim .. "_end"]
+ }, self.animation[anim .. "_speed"] or self.animation.speed_normal or 15)
- set_anim(self,
- self.animation.run_start,
- self.animation.run_end,
- self.animation.speed_run, "run")
-
- elseif type == "punch" and self.animation.current ~= "punch" then
-
- set_anim(self,
- self.animation.punch_start,
- self.animation.punch_end,
- self.animation.speed_punch, "punch")
-
- elseif type == "punch2" and self.animation.current ~= "punch2" then
-
- set_anim(self,
- self.animation.punch2_start,
- self.animation.punch2_end,
- self.animation.speed_punch2, "punch2")
-
- elseif type == "shoot" and self.animation.current ~= "shoot" then
-
- set_anim(self,
- self.animation.shoot_start,
- self.animation.shoot_end,
- self.animation.speed_shoot, "shoot")
-
- elseif type == "die" and self.animation.current ~= "die" then
-
- set_anim(self,
- self.animation.die_start,
- self.animation.die_end,
- self.animation.speed_die, "die")
-
- elseif type == "fly" and self.animation.current ~= "fly" then
-
- set_anim(self,
- self.animation.fly_start,
- self.animation.fly_end,
- self.animation.speed_fly, "fly")
- end
end
+
-- get distance
local get_distance = function(a, b)