Code tidy and tweak
This commit is contained in:
parent
4c48bd6ab3
commit
cdcec52c3d
18
api.lua
18
api.lua
@ -1,4 +1,4 @@
|
|||||||
-- Mobs Api (4th December 2015)
|
-- Mobs Api (6th December 2015)
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ set_velocity = function(self, v)
|
|||||||
local z = 0
|
local z = 0
|
||||||
|
|
||||||
if v and v ~= 0 then
|
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
|
x = math.sin(yaw) * -v
|
||||||
z = math.cos(yaw) * v
|
z = math.cos(yaw) * v
|
||||||
end
|
end
|
||||||
@ -1320,6 +1320,7 @@ minetest.register_entity(name, {
|
|||||||
|
|
||||||
set_velocity(self, self.run_velocity)
|
set_velocity(self, self.run_velocity)
|
||||||
set_animation(self, "run")
|
set_animation(self, "run")
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
@ -1524,7 +1525,7 @@ minetest.register_entity(name, {
|
|||||||
self.following = nil
|
self.following = nil
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
|
|
||||||
-- used to rotate for older mob definitions
|
-- used to rotate older mobs
|
||||||
if self.drawtype
|
if self.drawtype
|
||||||
and self.drawtype == "side" then
|
and self.drawtype == "side" then
|
||||||
self.rotate = math.rad(90)
|
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
|
-- spawn mob half block higher than ground
|
||||||
pos.y = pos.y - 0.5
|
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
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user