I was looking into cMonster API and I wanted an example for how you would assign properties to a created monster. I tried to look in essentials at the spawn mob command for an example but it just spawns the mob it doesn't try to apply properties.
If the example could contain: Setting the speed of the mob to zero it would be appreciated.
I wrote a example that spawns a sheep and set's the speed to zero.
Register the command handler in a plugin:
Code:
cPluginManager:BindCommand("/spawnmob", "spawnmob", CommandSpawnMob, "spawns a mob")
Code:
function CommandSpawnMob(a_Split, a_Player) -- I created a command handler, that will spawn a sheep and sets the speed to 0.
local mobID = a_Player:GetWorld():SpawnMob(a_Player:GetPosX(), a_Player:GetPosY(), a_Player:GetPosZ(), mtSheep) -- Spawns a sheep at player's position
assert(mobID ~= -1, "Mob spawn failed") -- This can happen, if for example a plugin denies the spawning of monsters
a_Player:GetWorld():DoWithEntityByID(mobID,
function(Entity)
Entity:SetRelativeWalkSpeed(0)
end)
a_Player:SendMessage("Spawned sheep.")
return true
end
Sources:
cMonster
SpawnMob
DoWithEntityByID
I just see that SpawnMob from cWorld has cMonster as a param type, that should be
eMonsterType.
The tolua.cast should not be needed, Cuberite should already provide the correct class to the callback.
Didn't know, will remove it.
Edit: Done
The only problem is they still can kinda move and be pushed. I'd want them to be stone.
EDIT: "stone" - unmoving.