Table of Contents

World:spawnCreature

 World:spawnCreature(x,y,z,creatureid,quantity) 

How to use

Where:

And returns:

Use example

When the player clicks the beehive block. 3 bees will be spawned and they will become the pets of the person who clicked.

local beehiveId = 134
local beeId = 3418
 
ScriptSupportEvent:registerEvent([=[Player.ClickBlock]=], function(e) 
 
    local playerid = e['eventobjid']
    local blockid = e['blockid']
    local x,y,z = e['x'], e['y'], e['z']
 
    local _, playernick = Player:getNickname(playerid)
 
    if blockid == beehiveId then
        local _, objids = World:spawnCreature(x,y,z, beeId, 3)
 
        for i, curObjid in ipairs(objids) do 
 
            Actor:setnickname(curObjid, playernick .. "'s bee")
            Actor:shownickname(curObjid, true)
 
        end
 
    end
end)