API:CommandPet
From RoR Wiki
UI Lua API · Pet functions
Version: WAR 1.4.8
Sends a command (stance, attack, follow, release and so on) to the player's pet.
sent = CommandPet(command)
Arguments
- command
number– One of theGameData.PetCommandvalues, for exampleGameData.PetCommand.AGGRESSIVE,.DEFENSIVE,.PASSIVE,.ATTACK,.STAY,.FOLLOWor.RELEASE.
Returns
- sent
boolean–trueif the command was sent to the server,falseotherwise.
Details
- Nothing is sent, and
falseis returned, if the player has no pet or the player object does not exist yet. - While one of the player's state flags is set, only command
7is sent; all other commands returnfalse. trueonly means the request was sent. Whether the pet obeys is decided by the server; the stock pet window assumes a sent stance command works and updates its display at once.- The client does not check that
commandis a known value. It is cut to a value from 0 to 255. - Exactly one argument must be passed. With a wrong argument the function raises the Invalid Parameters message and still returns
false.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From default/ea_careerresourceswindow/source/petwindow.lua:
function PetStanceButton:OnLButtonUp (flags, x, y)
local commandSent = CommandPet(self.m_StanceId)
-- Pretend that a stance command will always work if it is sent
-- short circuit the update
local parentPetWindow = self:GetParent ()
if(parentPetWindow and commandSent) then
parentPetWindow:UpdatePetState (self.m_StanceId)
