summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2018-08-03 09:43:50 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2018-08-03 09:43:50 +0100
commit0482581f1893c706f6698238a7630a1f9c7f73c4 (patch)
tree70d45298d86dcf720defa0345d6fd014cb77c245
parent4badcec3187cb10a561bd68b126747600ac343d4 (diff)
Added ability for multiple animations per action
-rw-r--r--api.lua30
-rw-r--r--api.txt5
2 files changed, 28 insertions, 7 deletions
diff --git a/api.lua b/api.lua
index ccd3ee9..b22d410 100644
--- a/api.lua
+++ b/api.lua
@@ -3,7 +3,7 @@
mobs = {}
mobs.mod = "redo"
-mobs.version = "20180719"
+mobs.version = "20180803"
-- Intllib
@@ -182,6 +182,23 @@ local set_animation = function(self, anim)
self.animation.current = self.animation.current or ""
+ -- check for more than one animation
+ local num = 0
+
+ for n = 1, 4 do
+
+ if self.animation[anim .. n .. "_start"]
+ and self.animation[anim .. n .. "_end"] then
+ num = n
+ end
+ end
+
+ -- choose random animation from set
+ if num > 0 then
+ num = random(0, num)
+ anim = anim .. (num ~= 0 and num or "")
+ end
+
if anim == self.animation.current
or not self.animation[anim .. "_start"]
or not self.animation[anim .. "_end"] then
@@ -1190,6 +1207,7 @@ local smart_mobs = function(self, s, p, dist, dtime)
if self.fear_height ~= 0 then dropheight = self.fear_height end
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "Dijkstra")
+
--[[
-- show path using particles
if self.path.way and #self.path.way > 0 then
@@ -2121,12 +2139,12 @@ local do_states = function(self, dtime)
self.timer = 0
- if self.double_melee_attack
- and random(1, 2) == 1 then
- set_animation(self, "punch2")
- else
+-- if self.double_melee_attack
+-- and random(1, 2) == 1 then
+-- set_animation(self, "punch2")
+-- else
set_animation(self, "punch")
- end
+-- end
local p2 = p
local s2 = s
diff --git a/api.txt b/api.txt
index 74e99db..57e086c 100644
--- a/api.txt
+++ b/api.txt
@@ -172,7 +172,7 @@ functions needed for the mob to work properly which contains the following:
'rotate' custom model rotation, 0 = front, 90 = side, 180 = back,
270 = other side.
'double_melee_attack' when true has the api choose between 'punch' and
- 'punch2' animations.
+ 'punch2' animations. [DEPRECATED]
'animation' holds a table containing animation names and settings for use with mesh models:
'stand_start' start frame for when mob stands still.
@@ -207,6 +207,9 @@ functions needed for the mob to work properly which contains the following:
'speed_normal' is used for animation speed for compatibility with some
older mobs.
+ Note: Up to 5 different animations can be used per action e.g.
+ stand_start, stand_end, stand1_start, stand1_end .. up to stand4_start
+
Node Replacement
----------------