mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-24 01:30:22 +01:00
added selectionbox to mob definition (dev only for now)
This commit is contained in:
parent
9d653f894c
commit
07bb12acac
23
api.lua
23
api.lua
@ -3,7 +3,7 @@
|
||||
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
mobs.version = "20171230"
|
||||
mobs.version = "20180104"
|
||||
|
||||
|
||||
-- Intllib
|
||||
@ -831,6 +831,7 @@ local breed = function(self)
|
||||
mesh = self.base_mesh,
|
||||
visual_size = self.base_size,
|
||||
collisionbox = self.base_colbox,
|
||||
selectionbox = self.base_selbox,
|
||||
})
|
||||
|
||||
-- custom function when child grows up
|
||||
@ -951,6 +952,14 @@ local breed = function(self)
|
||||
self.base_colbox[5] * .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
|
||||
ent2.child = true
|
||||
@ -2426,6 +2435,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||
self.base_mesh = def.mesh
|
||||
self.base_size = self.visual_size
|
||||
self.base_colbox = self.collisionbox
|
||||
self.base_selbox = self.selectionbox
|
||||
end
|
||||
|
||||
-- set texture, model and size
|
||||
@ -2433,6 +2443,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||
local mesh = self.base_mesh
|
||||
local vis_size = self.base_size
|
||||
local colbox = self.base_colbox
|
||||
local selbox = self.base_selbox
|
||||
|
||||
-- specific texture if gotten
|
||||
if self.gotten == true
|
||||
@ -2466,6 +2477,14 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||
self.base_colbox[5] * .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
|
||||
|
||||
if self.health == 0 then
|
||||
@ -2488,6 +2507,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||
self.textures = textures
|
||||
self.mesh = mesh
|
||||
self.collisionbox = colbox
|
||||
self.selectionbox = selbox
|
||||
self.visual_size = vis_size
|
||||
self.standing_in = ""
|
||||
|
||||
@ -2677,6 +2697,7 @@ minetest.register_entity(name, {
|
||||
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
selectionbox = def.selectionbox or def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size or {x = 1, y = 1},
|
||||
mesh = def.mesh,
|
||||
|
1
api.txt
1
api.txt
@ -34,6 +34,7 @@ This functions registers a new mob as a Minetest entity.
|
||||
'nametag' string containing name of mob to display above entity
|
||||
'physical' 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_size' same is in minetest.register_entity()
|
||||
'textures' same is in minetest.register_entity()
|
||||
|
@ -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.
|
||||
'mesh' uses separate object file to define mob.
|
||||
'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.
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
'collision_box' has the box in which mob can be interacted with the
|
||||
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
|
||||
could use multiple lists inside another table for random
|
||||
selection e.g. { {"texture1.png"}, {"texture2.png"} }
|
||||
|
Loading…
Reference in New Issue
Block a user