forked from Mirrorlandia_minetest/mod-sneeker
Whitespace cleanup
This commit is contained in:
parent
a89eb699c9
commit
cc9cb71090
46
init.lua
46
init.lua
@ -14,7 +14,7 @@ local function jump(self,pos,direction)
|
|||||||
self.object:setvelocity({x=velocity.x,y=4,z=velocity.z})
|
self.object:setvelocity({x=velocity.x,y=4,z=velocity.z})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
||||||
local node = minetest.get_node_or_nil(spos)
|
local node = minetest.get_node_or_nil(spos)
|
||||||
spos.y = spos.y+1
|
spos.y = spos.y+1
|
||||||
@ -86,7 +86,7 @@ def.on_activate = function(self,staticdata)
|
|||||||
self.knockback = false
|
self.knockback = false
|
||||||
self.state = math.random(1,2)
|
self.state = math.random(1,2)
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
|
|
||||||
local data = minetest.deserialize(staticdata)
|
local data = minetest.deserialize(staticdata)
|
||||||
if data and type(data) == "table" then
|
if data and type(data) == "table" then
|
||||||
if data.powered == true then
|
if data.powered == true then
|
||||||
@ -105,10 +105,10 @@ def.on_step = function(self, dtime)
|
|||||||
if self.knockback then
|
if self.knockback then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local ANIM_STAND = 1
|
local ANIM_STAND = 1
|
||||||
local ANIM_WALK = 2
|
local ANIM_WALK = 2
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
local inside = minetest.get_objects_inside_radius(pos,10)
|
local inside = minetest.get_objects_inside_radius(pos,10)
|
||||||
@ -116,11 +116,11 @@ def.on_step = function(self, dtime)
|
|||||||
local animation = self.animation
|
local animation = self.animation
|
||||||
local anim_speed = self.animation_speed
|
local anim_speed = self.animation_speed
|
||||||
local velocity = self.object:getvelocity()
|
local velocity = self.object:getvelocity()
|
||||||
|
|
||||||
self.timer = self.timer+0.01
|
self.timer = self.timer+0.01
|
||||||
self.turn_timer = self.turn_timer+0.01
|
self.turn_timer = self.turn_timer+0.01
|
||||||
self.jump_timer = self.jump_timer+0.01
|
self.jump_timer = self.jump_timer+0.01
|
||||||
|
|
||||||
if not self.chase
|
if not self.chase
|
||||||
and self.timer > math.random(2,5) then
|
and self.timer > math.random(2,5) then
|
||||||
if math.random() > 0.8 then
|
if math.random() > 0.8 then
|
||||||
@ -138,7 +138,7 @@ def.on_step = function(self, dtime)
|
|||||||
self.yaw = self.yaw-self.turn_speed
|
self.yaw = self.yaw-self.turn_speed
|
||||||
self.object:setyaw(self.yaw)
|
self.object:setyaw(self.yaw)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.chase and self.visualx < 2 then
|
if self.chase and self.visualx < 2 then
|
||||||
if self.hiss == false then
|
if self.hiss == false then
|
||||||
minetest.sound_play("creeper_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
minetest.sound_play("creeper_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
||||||
@ -155,9 +155,9 @@ def.on_step = function(self, dtime)
|
|||||||
})
|
})
|
||||||
self.hiss = false
|
self.hiss = false
|
||||||
end
|
end
|
||||||
|
|
||||||
self.chase = false
|
self.chase = false
|
||||||
|
|
||||||
for _,object in ipairs(inside) do
|
for _,object in ipairs(inside) do
|
||||||
if object:is_player() then
|
if object:is_player() then
|
||||||
self.state = "chase"
|
self.state = "chase"
|
||||||
@ -169,9 +169,9 @@ def.on_step = function(self, dtime)
|
|||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
||||||
self.anim = ANIM_STAND
|
self.anim = ANIM_STAND
|
||||||
end
|
end
|
||||||
|
|
||||||
random_turn(self)
|
random_turn(self)
|
||||||
|
|
||||||
if velocity.x ~= 0
|
if velocity.x ~= 0
|
||||||
or velocity.z ~= 0 then
|
or velocity.z ~= 0 then
|
||||||
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
||||||
@ -183,16 +183,16 @@ def.on_step = function(self, dtime)
|
|||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
|
|
||||||
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
||||||
if self.direction then
|
if self.direction then
|
||||||
self.object:setvelocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
self.object:setvelocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
||||||
end
|
end
|
||||||
|
|
||||||
random_turn(self)
|
random_turn(self)
|
||||||
|
|
||||||
local velocity = self.object:getvelocity()
|
local velocity = self.object:getvelocity()
|
||||||
|
|
||||||
if self.turn_timer > 1 then
|
if self.turn_timer > 1 then
|
||||||
local direction = self.direction
|
local direction = self.direction
|
||||||
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
|
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
|
||||||
@ -208,23 +208,23 @@ def.on_step = function(self, dtime)
|
|||||||
self.turn_speed = 0.05*math.random()
|
self.turn_speed = 0.05*math.random()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Jump
|
-- Jump
|
||||||
if self.jump_timer > 0.2 then
|
if self.jump_timer > 0.2 then
|
||||||
jump(self,pos,self.direction)
|
jump(self,pos,self.direction)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "chase" then
|
if self.state == "chase" then
|
||||||
if self.anim ~= ANIM_WALK then
|
if self.anim ~= ANIM_WALK then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
|
|
||||||
self.turn = "straight"
|
self.turn = "straight"
|
||||||
|
|
||||||
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
||||||
|
|
||||||
-- Boom
|
-- Boom
|
||||||
if #inside_2 ~= 0 then
|
if #inside_2 ~= 0 then
|
||||||
for _,object in ipairs(inside_2) do
|
for _,object in ipairs(inside_2) do
|
||||||
@ -238,7 +238,7 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #inside ~= 0 then
|
if #inside ~= 0 then
|
||||||
for _,object in ipairs(inside) do
|
for _,object in ipairs(inside) do
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
@ -255,7 +255,7 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ppos = object:getpos()
|
local ppos = object:getpos()
|
||||||
self.vec = {x=ppos.x-pos.x,y=ppos.y-pos.y,z=ppos.z-pos.z}
|
self.vec = {x=ppos.x-pos.x,y=ppos.y-pos.y,z=ppos.z-pos.z}
|
||||||
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||||
@ -265,7 +265,7 @@ def.on_step = function(self, dtime)
|
|||||||
self.yaw = self.yaw-2
|
self.yaw = self.yaw-2
|
||||||
self.object:setyaw(self.yaw)
|
self.object:setyaw(self.yaw)
|
||||||
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
||||||
|
|
||||||
local direction = self.direction
|
local direction = self.direction
|
||||||
self.object:setvelocity({x=direction.x*2.5,y=velocity.y,z=direction.z*2.5})
|
self.object:setvelocity({x=direction.x*2.5,y=velocity.y,z=direction.z*2.5})
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ def.on_step = function(self, dtime)
|
|||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Swim
|
-- Swim
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(node.name,"water") ~= 0 then
|
if minetest.get_item_group(node.name,"water") ~= 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user