added selectionbox to mob definition (dev only for now)

This commit is contained in:
TenPlus1 2018-01-04 10:16:21 +00:00
parent 9d653f894c
commit 07bb12acac
3 changed files with 26 additions and 3 deletions

23
api.lua
View File

@ -3,7 +3,7 @@
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
mobs.version = "20171230" mobs.version = "20180104"
-- Intllib -- Intllib
@ -831,6 +831,7 @@ local breed = function(self)
mesh = self.base_mesh, mesh = self.base_mesh,
visual_size = self.base_size, visual_size = self.base_size,
collisionbox = self.base_colbox, collisionbox = self.base_colbox,
selectionbox = self.base_selbox,
}) })
-- custom function when child grows up -- custom function when child grows up
@ -951,6 +952,14 @@ local breed = function(self)
self.base_colbox[5] * .5, self.base_colbox[5] * .5,
self.base_colbox[6] * .5, self.base_colbox[6] * .5,
}, },
selectionbox = {
self.base_selbox[1] * .5,
self.base_selbox[2] * .5,
self.base_selbox[3] * .5,
self.base_selbox[4] * .5,
self.base_selbox[5] * .5,
self.base_selbox[6] * .5,
},
}) })
-- tamed and owned by parents' owner -- tamed and owned by parents' owner
ent2.child = true ent2.child = true
@ -2426,6 +2435,7 @@ local mob_activate = function(self, staticdata, def, dtime)
self.base_mesh = def.mesh self.base_mesh = def.mesh
self.base_size = self.visual_size self.base_size = self.visual_size
self.base_colbox = self.collisionbox self.base_colbox = self.collisionbox
self.base_selbox = self.selectionbox
end end
-- set texture, model and size -- set texture, model and size
@ -2433,6 +2443,7 @@ local mob_activate = function(self, staticdata, def, dtime)
local mesh = self.base_mesh local mesh = self.base_mesh
local vis_size = self.base_size local vis_size = self.base_size
local colbox = self.base_colbox local colbox = self.base_colbox
local selbox = self.base_selbox
-- specific texture if gotten -- specific texture if gotten
if self.gotten == true if self.gotten == true
@ -2466,6 +2477,14 @@ local mob_activate = function(self, staticdata, def, dtime)
self.base_colbox[5] * .5, self.base_colbox[5] * .5,
self.base_colbox[6] * .5 self.base_colbox[6] * .5
} }
selbox = {
self.base_selbox[1] * .5,
self.base_selbox[2] * .5,
self.base_selbox[3] * .5,
self.base_selbox[4] * .5,
self.base_selbox[5] * .5,
self.base_selbox[6] * .5
}
end end
if self.health == 0 then if self.health == 0 then
@ -2488,6 +2507,7 @@ local mob_activate = function(self, staticdata, def, dtime)
self.textures = textures self.textures = textures
self.mesh = mesh self.mesh = mesh
self.collisionbox = colbox self.collisionbox = colbox
self.selectionbox = selbox
self.visual_size = vis_size self.visual_size = vis_size
self.standing_in = "" self.standing_in = ""
@ -2677,6 +2697,7 @@ minetest.register_entity(name, {
hp_max = max(1, (def.hp_max or 10) * difficulty), hp_max = max(1, (def.hp_max or 10) * difficulty),
physical = true, physical = true,
collisionbox = def.collisionbox, collisionbox = def.collisionbox,
selectionbox = def.selectionbox or def.collisionbox,
visual = def.visual, visual = def.visual,
visual_size = def.visual_size or {x = 1, y = 1}, visual_size = def.visual_size or {x = 1, y = 1},
mesh = def.mesh, mesh = def.mesh,

View File

@ -34,6 +34,7 @@ This functions registers a new mob as a Minetest entity.
'nametag' string containing name of mob to display above entity 'nametag' string containing name of mob to display above entity
'physical' same is in minetest.register_entity() 'physical' same is in minetest.register_entity()
'collisionbox' same is in minetest.register_entity() 'collisionbox' same is in minetest.register_entity()
'selectionbox' same is in minetest.register_entity()
'visual' same is in minetest.register_entity() 'visual' same is in minetest.register_entity()
'visual_size' same is in minetest.register_entity() 'visual_size' same is in minetest.register_entity()
'textures' same is in minetest.register_entity() 'textures' same is in minetest.register_entity()

View File

@ -140,8 +140,9 @@ functions needed for the mob to work properly which contains the following:
'wielditem' how it looks when player holds it in hand. 'wielditem' how it looks when player holds it in hand.
'mesh' uses separate object file to define mob. 'mesh' uses separate object file to define mob.
'visual_size' has the size of the mob, defaults to {x = 1, y = 1} 'visual_size' has the size of the mob, defaults to {x = 1, y = 1}
'collision_box' has the box in which mob can be interacted with e.g. 'collision_box' has the box in which mob can be interacted with the
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5} world e.g. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
'selection_box' has the box in which player can interact with mob
'textures' holds a table list of textures to be used for mob, or you 'textures' holds a table list of textures to be used for mob, or you
could use multiple lists inside another table for random could use multiple lists inside another table for random
selection e.g. { {"texture1.png"}, {"texture2.png"} } selection e.g. { {"texture1.png"}, {"texture2.png"} }