Code tidy and tweak

This commit is contained in:
TenPlus1 2015-12-06 21:43:46 +00:00
parent 4c48bd6ab3
commit cdcec52c3d

18
api.lua
View File

@ -1,4 +1,4 @@
-- Mobs Api (4th December 2015)
-- Mobs Api (6th December 2015)
mobs = {}
mobs.mod = "redo"
@ -37,7 +37,7 @@ set_velocity = function(self, v)
local z = 0
if v and v ~= 0 then
local yaw = self.object:getyaw() + self.rotate
local yaw = (self.object:getyaw() + self.rotate) or 0
x = math.sin(yaw) * -v
z = math.cos(yaw) * v
end
@ -1320,6 +1320,7 @@ minetest.register_entity(name, {
set_velocity(self, self.run_velocity)
set_animation(self, "run")
else
set_velocity(self, 0)
@ -1524,7 +1525,7 @@ minetest.register_entity(name, {
self.following = nil
self.state = "stand"
-- used to rotate for older mob definitions
-- used to rotate older mobs
if self.drawtype
and self.drawtype == "side" then
self.rotate = math.rad(90)
@ -1711,8 +1712,15 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
-- spawn mob half block higher than ground
pos.y = pos.y - 0.5
minetest.add_entity(pos, name)
--print ("Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
local mob = minetest.add_entity(pos, name)
--local ent = mob:get_luaentity()
if mob then
print ("Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
else
print (name.." failed to spawn at "..minetest.pos_to_string(pos))
end
end
})