Tidied code
This commit is contained in:
parent
c390fb0fe5
commit
7ed926a4c5
36
api.lua
36
api.lua
@ -1,4 +1,4 @@
|
||||
-- Mobs Api (1st July 2015)
|
||||
-- Mobs Api (3rd July 2015)
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
|
||||
@ -114,7 +114,6 @@ function mobs:register_mob(name, def)
|
||||
local ps = math.sqrt(pos.x ^ 2 + pos.z ^ 2)
|
||||
local d = { x = vx / ds, z = vz / ds }
|
||||
local p = { x = pos.x / ps, z = pos.z / ps }
|
||||
|
||||
local an = ( d.x * p.x ) + ( d.z * p.z )
|
||||
|
||||
a = math.deg( math.acos( an ) )
|
||||
@ -141,20 +140,20 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
elseif type == "walk" and self.animation.current ~= "walk" then
|
||||
if self.animation.walk_start and self.animation.walk_end and self.animation.speed_normal then
|
||||
self.object:set_animation({x=self.animation.walk_start,y=self.animation.walk_end},
|
||||
self.animation.speed_normal, 0)
|
||||
self.object:set_animation({x = self.animation.walk_start,
|
||||
y = self.animation.walk_end}, self.animation.speed_normal, 0)
|
||||
self.animation.current = "walk"
|
||||
end
|
||||
elseif type == "run" and self.animation.current ~= "run" then
|
||||
if self.animation.run_start and self.animation.run_end and self.animation.speed_run then
|
||||
self.object:set_animation({x=self.animation.run_start,y=self.animation.run_end},
|
||||
self.animation.speed_run, 0)
|
||||
self.object:set_animation({x = self.animation.run_start,
|
||||
y = self.animation.run_end}, self.animation.speed_run, 0)
|
||||
self.animation.current = "run"
|
||||
end
|
||||
elseif type == "punch" and self.animation.current ~= "punch" then
|
||||
if self.animation.punch_start and self.animation.punch_end and self.animation.speed_normal then
|
||||
self.object:set_animation({x=self.animation.punch_start,y=self.animation.punch_end},
|
||||
self.animation.speed_normal, 0)
|
||||
self.object:set_animation({x = self.animation.punch_start,
|
||||
y = self.animation.punch_end}, self.animation.speed_normal, 0)
|
||||
self.animation.current = "punch"
|
||||
end
|
||||
end
|
||||
@ -300,7 +299,11 @@ function mobs:register_mob(name, def)
|
||||
or minetest.registered_nodes[nod.name].walkable == false then return end
|
||||
if self.direction then
|
||||
pos.y = pos.y + 0.5
|
||||
local nod = minetest.get_node_or_nil({x=pos.x + self.direction.x,y=pos.y,z=pos.z + self.direction.z})
|
||||
local nod = minetest.get_node_or_nil({
|
||||
x = pos.x + self.direction.x,
|
||||
y = pos.y,
|
||||
z = pos.z + self.direction.z
|
||||
})
|
||||
--print ("in front:", nod.name, pos.y)
|
||||
if nod and nod.name and (nod.name ~= "air" or self.walk_chance == 0) then
|
||||
local def = minetest.registered_items[nod.name]
|
||||
@ -451,8 +454,10 @@ function mobs:register_mob(name, def)
|
||||
mob:set_properties({
|
||||
textures = textures,
|
||||
visual_size = {x = self.visual_size.x / 2, y = self.visual_size.y / 2},
|
||||
collisionbox = {self.collisionbox[1]/2, self.collisionbox[2]/2, self.collisionbox[3]/2,
|
||||
self.collisionbox[4]/2, self.collisionbox[5]/2, self.collisionbox[6]/2},
|
||||
collisionbox = {
|
||||
self.collisionbox[1] / 2, self.collisionbox[2] / 2, self.collisionbox[3] / 2,
|
||||
self.collisionbox[4] / 2, self.collisionbox[5] / 2, self.collisionbox[6] / 2
|
||||
},
|
||||
})
|
||||
ent2.child = true
|
||||
ent2.tamed = true
|
||||
@ -942,8 +947,10 @@ end
|
||||
if def.child_texture then
|
||||
textures = def.child_texture[1]
|
||||
end
|
||||
colbox = {self.collisionbox[1]/2, self.collisionbox[2]/2, self.collisionbox[3]/2,
|
||||
self.collisionbox[4]/2, self.collisionbox[5]/2, self.collisionbox[6]/2}
|
||||
colbox = {
|
||||
self.collisionbox[1] / 2, self.collisionbox[2] / 2, self.collisionbox[3] / 2,
|
||||
self.collisionbox[4] / 2, self.collisionbox[5] / 2, self.collisionbox[6] / 2
|
||||
}
|
||||
end
|
||||
-- remember settings
|
||||
local tmp = {
|
||||
@ -1263,7 +1270,8 @@ function mobs:register_arrow(name, def)
|
||||
if self.hit_node and node and minetest.registered_nodes[node] and minetest.registered_nodes[node].walkable then
|
||||
self.hit_node(self, pos, node)
|
||||
if self.drop == true then
|
||||
pos.y = pos.y + 1 ; self.lastpos = (self.lastpos or pos)
|
||||
pos.y = pos.y + 1
|
||||
self.lastpos = (self.lastpos or pos)
|
||||
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
|
||||
end
|
||||
self.object:remove()
|
||||
|
Loading…
x
Reference in New Issue
Block a user