From 07bb12acac8df1c294714d89f55d46eb55f076d1 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Thu, 4 Jan 2018 10:16:21 +0000 Subject: [PATCH] added selectionbox to mob definition (dev only for now) --- api.lua | 23 ++++++++++++++++++++++- api.txt | 1 + api_new.txt | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 4f3c1e9..ca75f9f 100644 --- a/api.lua +++ b/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, diff --git a/api.txt b/api.txt index 7f3959b..c42e5bb 100644 --- a/api.txt +++ b/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() diff --git a/api_new.txt b/api_new.txt index c2b0e56..f278aa5 100644 --- a/api_new.txt +++ b/api_new.txt @@ -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"} }