Sokomine wrote:And again: Another variant of sheep. I'd love to see goats!
trainwrecktony wrote:code borrowed from adventuretest for knockback effect
Achilles wrote:Is there an admin command that would spawn one of the mobs? Or an egg that can only be gained by admins?
local handle_drops = function(self)
if self.object:get_hp() <= 0 then
local p = self.object:getpos()
for _,drop in ipairs(self.drops) do
if math.random(1, drop.chance) == 1 then
local o = minetest.add_entity(p, "__builtin:item")
local s = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
o:get_luaentity():set_item(s:to_string())
o:setvelocity({x=math.random(0,4)-2, y=0, z=math.random(0,4)-2})
end
end
if self.bonus and math.random(1, 4) == 1 then
local o = minetest.add_entity(p, "__builtin:item")
local s = ItemStack(self.bonus[math.random(1, #self.bonus)])
o:get_luaentity():set_item(s:to_string())
o:setvelocity({x=math.random(0,4)-2, y=0, z=math.random(0,4)-2})
end
self.object:remove()
return
end
end
gsmanners wrote:Nice. I still don't care for the drops, though. I usually do a little something like this with mobs:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local handle_drops = function(self)
if self.object:get_hp() <= 0 then
local p = self.object:getpos()
for _,drop in ipairs(self.drops) do
if math.random(1, drop.chance) == 1 then
local o = minetest.add_entity(p, "__builtin:item")
local s = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
o:get_luaentity():set_item(s:to_string())
o:setvelocity({x=math.random(0,4)-2, y=0, z=math.random(0,4)-2})
end
end
if self.bonus and math.random(1, 4) == 1 then
local o = minetest.add_entity(p, "__builtin:item")
local s = ItemStack(self.bonus[math.random(1, #self.bonus)])
o:get_luaentity():set_item(s:to_string())
o:setvelocity({x=math.random(0,4)-2, y=0, z=math.random(0,4)-2})
end
self.object:remove()
return
end
end
Then call the above right before various remove()s.
Users browsing this forum: No registered users and 36 guests