From 9afa2ec1fd4759d1be9b3cfeb66aa1fa593557b0 Mon Sep 17 00:00:00 2001 From: C Nelson Date: Fri, 7 Jun 2013 20:02:41 -0500 Subject: [PATCH 1/3] Add an option to disable jumping. --- api.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api.lua b/api.lua index d02fe63..210d5fd 100644 --- a/api.lua +++ b/api.lua @@ -28,6 +28,7 @@ function mobs:register_mob(name, def) sounds = def.sounds, animation = def.animation, follow = def.follow, + jump = def.jump or true, timer = 0, env_damage_timer = 0, -- only if state = "attack" @@ -305,7 +306,7 @@ function mobs:register_mob(name, def) if math.random(1, 100) <= 30 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi)) end - if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) From 4237bf2f9cc13d267756dec8b38aa6ab3edbc635 Mon Sep 17 00:00:00 2001 From: C Nelson Date: Sat, 8 Jun 2013 09:50:03 -0500 Subject: [PATCH 2/3] Also disable jumping in the other places they could jump --- api.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index 210d5fd..5d3a665 100644 --- a/api.lua +++ b/api.lua @@ -273,7 +273,7 @@ function mobs:register_mob(name, def) self.v_start = true self.set_velocity(self, self.walk_velocity) else - if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) @@ -352,7 +352,7 @@ function mobs:register_mob(name, def) self.v_start = true self.set_velocity(self, self.run_velocity) else - if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) From cd52408b9a7bf822f89c57727e011f5b1e04ce0c Mon Sep 17 00:00:00 2001 From: C Nelson Date: Sat, 8 Jun 2013 13:03:09 -0500 Subject: [PATCH 3/3] Remove useless "== true" bits. --- api.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 5d3a665..8fcd4e8 100644 --- a/api.lua +++ b/api.lua @@ -273,7 +273,7 @@ function mobs:register_mob(name, def) self.v_start = true self.set_velocity(self, self.walk_velocity) else - if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) @@ -306,7 +306,7 @@ function mobs:register_mob(name, def) if math.random(1, 100) <= 30 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi)) end - if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) @@ -352,7 +352,7 @@ function mobs:register_mob(name, def) self.v_start = true self.set_velocity(self, self.run_velocity) else - if self.jump == true and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then + if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v)