butterfly improvements and '=' fix

master
D00Med 2017-01-17 06:40:25 +10:00
parent ac024f00e2
commit 8955af2ca2
7 changed files with 11 additions and 6 deletions

View File

@ -8,11 +8,11 @@ dofile(minetest.get_modpath("dmobs").."/api.lua")
-- Enable dragons (disable to remove tamed dragons and dragon bosses)
dmobs.dragons = minetest.setting_getbool("dmobs.dragons")
if dmobs.dragons = nil then
if dmobs.dragons == nil then
dmobs.dragons = true
end
dmobs.regulars = minetest.setting_getbool("dmobs.regulars")
if dmobs.regulars = nil then
if dmobs.regulars == nil then
dmobs.regulars = true
end

View File

@ -6,25 +6,30 @@ minetest.register_abm({
interval = 10.0,
chance = 10,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_entity({x=pos.x,y=pos.y,z=pos.z}, "dmobs:butterfly")
minetest.env:add_entity({x=pos.x,y=pos.y+0.3,z=pos.z}, "dmobs:butterfly")
end
})
minetest.register_entity("dmobs:butterfly", {
visual = "sprite",
visual = "mesh",
mesh = "butterfly.b3d",
physical = true,
textures = {"dmobs_butterfly.png",},
visual_size = {x=0.2, y=0.2},
visual_size = {x=0.3, y=0.3},
on_activate = function(self)
num = math.random(1,4)
self.object:set_properties({textures = {"dmobs_butterfly"..num..".png",},})
minetest.after(5, function()
self.object:set_animation({x=1, y=10}, 20, 0)
self.object:setyaw(math.pi+num)
minetest.after(10, function()
self.object:remove()
end)
end,
on_step = function(self)
local pos = self.object:getpos()
local vec = self.object:getvelocity()
local num = math.random(-math.pi, math.pi)
self.object:setyaw(math.pi+num)
self.object:setvelocity({x=-math.sin(12*pos.y), y=math.cos(12*pos.x), z=-math.sin(12*pos.y)})
self.object:setacceleration({x=-math.sin(6*vec.y), y=math.cos(6*vec.x), z=-math.sin(6*vec.y)})
end,

BIN
models/butterfly.b3d Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

After

Width:  |  Height:  |  Size: 454 B