# Actor Management

Before using the Actor API, you need to create an Actor management object as follows:

local Actor = class.Actor.new()

The specific function name and description are as follows:

Serial number Function name Description
1 isPlayer(...) Detect if it's a player
2 isMob(...) Detect if it's a monster
3 getObjType(...) Get actor type: creature / player...)
4 isInAir(...) If it's in the air
5 getPosition(...) Get the location of actor
6 setPosition(...) Set the location of actor
7 jump(...) Jump
8 killSelf(...) Kill yourself
9 getCurPlaceDir(...) Get the current facing direction
10 tryMoveToActor(...) Moving to the target actor
11 tryMoveToPos(...) Move toward target actor
12 addBuff(...) Increase buff
13 hasBuff(...) Whether there is a buff
14 removeBuff(...) Remove buff
15 clearAllBuff(...) Clear all the buffs
16 clearAllBadBuff(...) Clear all the negative buffs
17 getBuffList(...) Get the buff list
18 getBuffLeftTick(...) Get the remaining itck of the current index corresponding buff
19 addHP(...) Increase current HP
20 getHP(...) Get the current HP
21 getMaxHP(...) Get the current maximum HP
22 addOxygen(...) Increase oxygen value
23 getOxygen(...) Obtain oxygen value
24 addEnchant(...) Increase the enchantment of related equipment
25 removeEnchant(...) Remove the enchantment of related equipment
26 findNearestBlock(...) Find blocks nearby
27 setFaceYaw(...) Set perspective lateral offset angle of actor
28 getFaceYaw(...) Get perspective lateral offset angle of actor
29 turnFaceYaw(...) Change the crosswise deviation angle of actor
30 setFacePitch(...) Set the upward angle of actor's view
31 getFacePitch(...) Get the upward angle of actor's view
32 turnFacePitch(...) Change the upward deviation angle of actor
33 playBodyEffect(...) Play the effects
34 stopBodyEffect(...) Stop the effects
35 playBodyEffectByFile(...) Play the file effects
36 stopBodyEffectByFile(...) Stop the file effects
37 playSound(...) Play sound
38 playSoundSpecial(...) Play sound(specific type:GSOUND_TYPE)
39 clearActorWithId(...) Clear the creature's id whose id is actorid
40 setAttackType(...) Set the damage type
41 setImmuneType(...) Set damage immunity type
42 mountActor(...) Get on, off the vehicle
43 setActionAttrState(...) Set the behavior, attribute and state of creature
44 getActionAttrState(...) Obtain status of creature special attribute
45 tryNavigationToPos(...) Find the way to target location
46 randomActorID(...) Create a creature randomly in the resource library
47 getRidingActorObjId(...) Get the Pferd's objid
48 playBodyEffectById(...) Play effect on specified players 1.2+
49 stopBodyEffectById(...) Stop effect on specified players 1.2+
50 setBodyEffectScale(...) Set up effect size on specified players 1.2+
51 playSoundEffectById(...) Play sound effect on specified Actor 1.3+
52 stopSoundEffectById(...) Stop sound effect on specified Actor 1.3+
53 appendSpeed(...) Attach a speed to the actor 1.3+
54 getFaceDirection(...) Get actor orientation 1.3+
55 calcDirectionByDirection(...) Calculate the absolute direction by local coordinate direction 1.3+
56 calcDirectionByAngle(...) The absolute direction is calculated by using local spherical coordinates 1.3+
57 calcDirectionByYawDirection(...) Calculate the absolute positive direction from the local coordinate direction (ignore the Angle of view) 1.3+
58 calcDirectionByYawAngle(...) Calculate the absolute positive direction from local spherical coordinates (ignore the Angle of view) 1.3+
59 getEyeHeight(...) Acquire the height of eyes 1.3+
60 getEyePosition(...) Acquire the location of eyes 1.3+
61 getBodySize(...) Acquire the body dimensions 1.3+
62 playAct(...) Play Expression 1.5+

# isPlayer

  • Parameters and types:objid
  • Return value and types:
  • The main role of this method: Detect if it's a player
  • The specific use cases are as follows:
--Whenever the player's attacks the hit object,determine whether the attacked object is the player
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--To determine whether an object is a player,the parameter is the id of the object in the archive
	local result=Actor:isPlayer(event.toobjid)
	if result==0 then--If it is a player
		--Show in chat box
		Chat:sendSystemMsg("objid is "..event.toobjid.." the object is a player")
	else--if not a player
		--Show in chat box
		Chat:sendSystemMsg("objid is "..event.toobjid.." the object is not a player")
	end
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# isMob

  • Parameters and types:objid
  • Return value and types:
  • The main role of this method: Detect if it's a monster
  • The specific use cases are as follows:
--Whenever the player's attacks the hit object,determine whether the attacked object is a monster
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--To determine whether an object is a monster,the parameter is the id of the object in the archive
	local result=Actor:isMob(event.toobjid)
	if result==0 then--If it is a monster
		--Show in chat box
		Chat:sendSystemMsg("objid is "..event.toobjid.." the object is a monster")
	else--if not a monster
		--Show in chat box
		Chat:sendSystemMsg("objid is "..event.toobjid.." the object is not a monster")
	end
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# getObjType

  • Parameters and types:objid
  • Return value and types:
  • The main role of this method: Get actor type: creature / player...)
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,the chat box shows the type of one of the objects within 10 squares around the host
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Get the coordinates of the homeowner
	local result,x,y,z=Player:getPosition(0)
	--Get the number and list of objects within 10 squares around the host
	local result2,num,objids=World:getActorsByBox(0,x-10,y-10,z-10,x+10,y+10,z+10)
	if num>0 then--if the object is obtained
		--Get the type of the first object in the object list,the parameter is the id of the object of the type to be obtained in the archive
		--The return value may be:1 player 2 creature 3 drop 4 throwing object
		local result3,objtype=Actor:getObjType(objids[1])
		--Show in chat box
		Chat:sendSystemMsg("Object found in 10 nearby blocks! One of the object types is(1 player 2 creature 3 drop 4 throwing object)"..objtype)
	else--if the acquisition fails
		--Show in chat box
		Chat:sendSystemMsg("No objects found in 10 nearby blocks!")
	end
end
--Register animation expression listener,execute the above function when the player makes animation expression
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# isInAir

  • Parameters and types:
  • Return value and types:
  • The main role of this method: If it's in the air
  • The specific use cases are as follows:
--Whenever the player hits an object,determine whether the object is in the air
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--To determine whether an object is in the air,the parameter is the id of the object in the archive
	local result=Actor:isInAir(event.toobjid)
	if result==0 then--if in the air
		--Show in chat box
		Chat:sendSystemMsg("The creature with objid "..event.toobjid.." is in the air")
	else--if not in the air
		--Show in chat box
		Chat:sendSystemMsg("The creature with objid "..event.toobjid.." is not in the air")
	end
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# getPosition

  • Parameters and types:objid
  • Return value and types:
  • The main role of this method: Get the location of actor
  • The specific use cases are as follows:
--When the player hits an object,get the coordinates of the object
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Get the coordinates of an object,the parameter is the id of the object in the archive
	local result,x,y,z=Actor:getPosition(event.toobjid)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.toobjid.." the coordinates of the creature are("..x..","..y..","..z..")")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# setPosition

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the location of actor
  • The specific use cases are as follows:
--When the player hits an object,set the object's position
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Set the coordinates of the specified object
	--The first parameter is the id of the object in the archive
	--The last three parameters are the coordinates to be set
	Actor:setPosition(event.toobjid,10,20,10)
	--Show in chat box
	Chat:sendSystemMsg("The creature with objid "..event.toobjid.." is set to the position of(10,10) height 20")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# jump

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Jump
  • The specific use cases are as follows:
--Whenever the player hits an object,let the object jump
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Let the specified object jump,the parameter is the id of the object in the archive
	Actor:jump(event.toobjid)
	--Show in chat box
	Chat:sendSystemMsg("Let the creature with objid "..event.toobjid.." jump once")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# killSelf

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Kill yourself
  • The specific use cases are as follows:
--Every time a player attacks a creature,clear that creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Clear the specified creature,the parameter is the id of the creature in the archive
	Actor:killSelf(event.toobjid)
	--Show in chat box
	Chat:sendSystemMsg("Cleared creature with objid "..event.toobjid)
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# getCurPlaceDir

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current facing direction
  • The specific use cases are as follows:
--Whenever a player hits a creature,it gets the direction of that creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Get the orientation of the specified creature,the parameter is the id of the creature in the archive
	--The return value may be:0 West 1 East 2 South 3 North 4 Down 5 Up
	local result,dir=Actor:getCurPlaceDir(event.toobjid)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.toobjid.." The current orientation of the creature is(0 West 1 East 2 South 3 North 4 Down 5 Up)"..dir)
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# tryMoveToActor

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Moving to the target actor
  • The specific use cases are as follows:
--Whenever a player attacks a certain creature,the creature moves towards another creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Let the designated creature move to another creature
	--The first parameter is the id of the creature to be moved in the archive
	--The second parameter is the id of the moving target creature in the archive
	--The third parameter is the moving speed
	Actor:tryMoveToActor(event.toobjid,event.eventobjid,3)
	--Show in chat box
	Chat:sendSystemMsg("Let the creature with objid "..event.toobjid.." move to the creature with objid "..event.eventobjid.." at a speed of 3")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# tryMoveToPos

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Move toward target actor
  • The specific use cases are as follows:
--Whenever the player hits a certain creature,the creature moves to a certain position
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Let a creature move to a coordinate
	--The first parameter is the id of the creature to be moved in the archive
	--The middle three parameters 10,7,10 are the coordinates to move to
	--The last parameter is the moving speed
	Actor:tryMoveToPos(event.toobjid,10,7,10,3)
	--Show in chat box
	Chat:sendSystemMsg("Let the creature with objid "..event.toobjid.." move to(10,10) height 7 position,speed 3")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# addBuff

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase buff
  • The specific use cases are as follows:
--Add buff to the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second and third parameters are the buff to be added,which can be viewed in the "status (effect) table data" of "mini world ID query"
--The last parameter is the duration of the buff
Actor:addBuff(0,50,4,10000)
--Show in chat box
Chat:sendSystemMsg("The homeowner was added a buff of level 4 rapid life recovery for a duration of 10,000")

# hasBuff

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Whether there is a buff
  • The specific use cases are as follows:
--Determine whether a creature has a buff
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the buff to be judged,which can be viewed in the "status (effect) table data" of "mini world ID query"
local result=Actor:hasBuff(0,50)
if result==0 then--if there is
	--Show in chat box
	Chat:sendSystemMsg("The host currently has a fast life recovery buff")
else--if not
	--Show in chat box
	Chat:sendSystemMsg("The host does not currently have a buff for rapid life recovery")
end

# removeBuff

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove buff
  • The specific use cases are as follows:
--Remove the specified buff of the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the buff to be removed,which can be viewed in the "status (effect) table data" of "mini world ID query"
Actor:removeBuff(0,50)
--Show in chat box
Chat:sendSystemMsg("Removed the homeowner's buff of rapid life recovery")

# clearAllBuff

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear all the buffs
  • The specific use cases are as follows:
--Remove all buffs of a creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
Actor:clearAllBuff(0)
--Show in chat box
Chat:sendSystemMsg("Empty all buffs from the homeowner")

# clearAllBadBuff

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear all the negative buffs
  • The specific use cases are as follows:
--Remove all negative buffs of a creature,the parameter is the id of the creature in the archive,which can be the player's mini number,0 is the host
Actor:clearAllBadBuff(0)
--Show in chat box
Chat:sendSystemMsg("Empty all negative buffs from the homeowner")

# getBuffList

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the buff list
  • The specific use cases are as follows:
--Get a creature buff list,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,num,array=Actor:getBuffList(0)
if num>0 then--if there is a buff
	for i,a in ipairs(array) do
		--Show buff list in chat box
		Chat:sendSystemMsg("Homeowner's"..i.." The buff is:"..a)
	end
else--if there is no buff
	--Show in chat box
	Chat:sendSystemMsg("The host does not currently have a buff")
end

# getBuffLeftTick

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the remaining itck of the current index corresponding buff
  • The specific use cases are as follows:
--Get the remaining time of a creature's designated buff
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the buff to get the remaining time,which can be viewed in the "status (effect) table data" of "mini world ID query"
local result,ticks=Actor:getBuffLeftTick(0,50)
--Show in chat box
Chat:sendSystemMsg("The homeowner's current rapid life recovery buff remaining time is:"..ticks)

# addHP

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase current HP
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,increase the player's health
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Increase the health of the specified creature
	--The first parameter is the id of the creature in the archive,which can be the player's mini number
	--The second parameter is the health value to be increased
	Actor:addHP(event.eventobjid,10)
	--Show in chat box
	Chat:sendSystemMsg("Add 10 health points to creatures with objid "..event.eventobjid)
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# getHP

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current HP
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,get the player's current health
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Get the current health value of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
	local result,value=getHP(event.eventobjid)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid.." creature's current health value is:"..value)
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# getMaxHP

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current maximum HP
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,get the player's maximum health
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Get the maximum life value of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
	local result,value=getMaxHP(event.eventobjid)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid.." creature maximum life value:"..value)
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# addOxygen

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase oxygen value
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,increase the player's oxygen value
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Increase the oxygen value of the specified organism
	--The first parameter is the id of the creature in the archive,which can be the player's mini number
	--The second parameter is the value to be added
	Actor:addOxygen(event.eventobjid,10)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid.." biological oxygen value increased by 10")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# getOxygen

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain oxygen value
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,get the player's current oxygen value
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Get the current oxygen value of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
	local result,value=getOxygen(event.eventobjid)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid.." The current oxygen value of the organism is:"..value)
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# addEnchant

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase the enchantment of related equipment
  • The specific use cases are as follows:
--Whenever a player makes an animated expression,add an enchant to the player's equipment
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Add enchantment to the equipment of the specified player
	--The first parameter is the id of the creature in the archive,which can be the player's mini number
	--The second parameter is the id of the equipment column:0 headdress 1 breastplate 2 pants 3 shoes 4 cloak 5 items in his hand
	--The last two parameters are enchantment and enchantment level,which can be viewed in "Enchantment Table Data" of "Mini World ID Query"
	Actor:addEnchant(event.eventobjid,5,10,5)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid.." items in the hands of creatures have been enchanted with the enchantment 5")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# removeEnchant

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove the enchantment of related equipment
  • The specific use cases are as follows:
--Whenever the player makes an animated expression,remove the enchantment of the specified equipment
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Remove the designated enchantment of the designated equipment of the designated creature
	--The first parameter is the id of the creature in the archive,which can be the player's mini number
	--The second parameter is the id of the equipment column:0 headdress 1 breastplate 2 pants 3 shoes 4 cloak 5 items in his hand
	--The third parameter is the enchantment to be removed,which can be viewed in "Enchanting Table Data" of "Mini World ID Query"
	Actor:removeEnchant(event.eventobjid,5,10)
	--Show in chat box
	Chat:sendSystemMsg("Remove the ignition enchantment of creature holding items with objid "..event.eventobjid)
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# findNearestBlock

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Find blocks nearby
  • The specific use cases are as follows:
local result = Actor:findNearestBlock(objid, blockid, blockRange)

# setFaceYaw

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set perspective lateral offset angle of actor
  • The specific use cases are as follows:
--Whenever the player attacks the hit creature,set the orientation of the hit creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Set the orientation of the specified player
	--The first parameter is the id of the creature in the archive
	--The second parameter is the offset angle to be set,0 is south,and the angle increases from south to west
	Actor:setFaceYaw(event.toobjid,0)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.toobjid.." the creature orientation is set to the south")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# getFaceYaw

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get perspective lateral offset angle of actor
  • The specific use cases are as follows:
--Get the orientation and deflection angle of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,yaw=Actor:getFaceYaw(0)
--Show in chat box
Chat:sendSystemMsg("The homeowner's orientation deflection angle is "..yaw)

# turnFaceYaw

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Change the crosswise deviation angle of actor
  • The specific use cases are as follows:
--The player selects the object to be rotated by attacking the hit creature,and then each time the animated expression is made,the creature will rotate 90 degrees
local objid--variable storing biological id
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Assign the hit biological id to the above variable
	objid=event.toobjid
	--Show in chat box
	Chat:sendSystemMsg("checked"..event.toobjid..",now the creature will rotate 90 degrees every time you animate the emoji")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Rotate the specified creature at an angle
	--The first parameter is the id of the creature in the archive
	--The second parameter is the angle to be rotated
	Actor:turnFaceYaw(objid,90)
	--Show in chat box
	Chat:sendSystemMsg("creature"..objid.."was rotated 90 degrees")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# setFacePitch

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the upward angle of actor's view
  • The specific use cases are as follows:
--Whenever the player attacks the hit creature,set the vertical orientation of the hit creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Set the vertical orientation of the specified player
	--The first parameter is the id of the creature in the archive
	--The second parameter is the offset angle to be set,0 is positive forward,elevation is considered positive,and top view is negative
	Actor:setFacePitch(event.toobjid,0)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.toobjid.." the vertical orientation of the creature is set to the front")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# getFacePitch

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the upward angle of actor's view
  • The specific use cases are as follows:
--Get the vertical deflection angle of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,pitch=Actor:getFacePitch(0)
--Show in chat box
Chat:sendSystemMsg("The homeowner's vertical deflection angle is ".. pitch)

# turnFacePitch

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Change the upward deviation angle of actor
  • The specific use cases are as follows:
--The player selects the object to be rotated by attacking the hit creature,and then each time the animated expression is made,the vertical orientation of the creature will rotate 90 degrees
local objid--variable storing biological id
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Assign the hit biological id to the above variable
	objid=event.toobjid
	--Show in chat box
	Chat:sendSystemMsg("checked"..event.toobjid..",now the creature will rotate 90 degrees every time the animated face is animated")
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Rotate the specified creature's vertical orientation to a certain angle
	--The first parameter is the id of the creature in the archive
	--The second parameter is the angle to be rotated
	Actor:turnFacePitch(objid,90)
	--Show in chat box
	Chat:sendSystemMsg("creature"..objid.."The vertical orientation is rotated 90 degrees")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# playBodyEffect

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play the effects
  • The specific use cases are as follows:
--Add special effects to specified creatures
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the id of the special effect to be added,which generally starts from 1000
Actor:playBodyEffect(0,1027)
--Show in chat box
Chat:sendSystemMsg("The host has been added special effects 1027")

# stopBodyEffect

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Stop the effects
  • The specific use cases are as follows:
--Cancel the special effects of the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the id of the special effect to be cancelled,roughly starting from 1000
Actor:stopBodyEffect(0,1027)
--Show in chat box
Chat:sendSystemMsg("The host has been canceled special effects 1027")

# playBodyEffectByFile

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play the file effects
  • The specific use cases are as follows:
local result = Actor:playBodyEffectByFile(objid, filename, sync)

# stopBodyEffectByFile

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Stop the file effects
  • The specific use cases are as follows:
local result = Actor:stopBodyEffectByFile(objid, filename)

# playSound

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play sound
  • The specific use cases are as follows:
local result = Actor:playSound(objid, name, volume, pitch, flag)

# playSoundSpecial

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play sound(specific type:GSOUND_TYPE)
  • The specific use cases are as follows:
local result = Actor:playSoundSpecial(objid, name, type)

# clearActorWithId

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear the creature's id whose id is actorid
  • The specific use cases are as follows:
--Clear the specified creature
--The first parameter is the biological id to be cleared,3402 is a pig,which can be viewed in the "biological table data" of "mini world ID query"
--The second parameter is whether to display the death effect:true display false disappears directly
Actor:clearActorWithId(3402,false)
--Show in chat box
Chat:sendSystemMsg("Clear all pigs in the archive")

# setAttackType

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the damage type
  • The specific use cases are as follows:
local result = Actor:setAttackType(objid, attacktype)

# setImmuneType

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set damage immunity type
  • The specific use cases are as follows:
local result = Actor:setImmuneType(objid, immunetype, isadd)

# mountActor

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get on, off the vehicle
  • The specific use cases are as follows:
--Whenever the player attacks the hit creature,the player rides the hit creature
--This function will be executed when the player hits the attack
local function Player_AttackHit(event)
	--Let the designated creature ride another creature
	--The first parameter is the id of the riding creature in the archive,which can be the player's mini number
	--The second parameter is the id of the riding creature in the archive
	--The third parameter is the riding position
	Actor:mountActor(event.eventobjid,event.toobjid,0)
	--Show in chat box
	Chat:sendSystemMsg("objid is "..event.eventobjid..",the creature riding ride objid is "..event.toobjid)
end
--Register the listener,execute Player_AttackHit function when the player hits the attack
ScriptSupportEvent:registerEvent([=[Player.AttackHit]=],Player_AttackHit)

# setActionAttrState

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the behavior, attribute and state of creature
  • The specific use cases are as follows:
--Set the attributes of the creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the attribute to be set,1 is mobile,you can check it in the "creature attribute setting" of "game data type"
--The third parameter is set:true can be false not
Actor:setActionAttrState(0,1,false)
--Show in chat box
Chat:sendSystemMsg("Homeowner is set to be immovable")

# getActionAttrState

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain status of creature special attribute
  • The specific use cases are as follows:
--Get the attributes of the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the attribute to be obtained,1 is mobile,you can view it in the "creature attribute setting" of "game data type"
local result=Actor:getActionAttrState(0,1)
if result==0 then--if you can
	--Show in chat box
	Chat:sendSystemMsg("Homeowner is currently mobile")
else--if not
	--Show in chat box
	Chat:sendSystemMsg("Homeowner is currently immovable")
end

# tryNavigationToPos

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Find the way to target location
  • The specific use cases are as follows:
local result = Actor:tryNavigationToPos(objid, x, y, z, cancontrol)

# randomActorID

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: Create a creature randomly in the resource library
  • The specific use cases are as follows:
--Randomly generate a biological id,the return value can be viewed in the "biological table data" of "mini world ID query"
local result,id=Actor:randomActorID()
--Show in chat box
Chat:sendSystemMsg("randomly selected a creature id"..id)

# getRidingActorObjId

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the Pferd's objid
  • The specific use cases are as follows:
--Get the id of the specified creature's ride in the archive
--The parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,objid=Actor:getRidingActorObjId(0)
if objid==0 then--if there is no mount
	--Show in chat box
	Chat:sendSystemMsg("The host does not currently ride a ride")
else--If you are riding a ride
	--Show in chat box
	Chat:sendSystemMsg("The objid of the mount currently mounted by the owner in the archive is:"..objid)
end

# playBodyEffectById 1.2+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play effect on specified players
  • The specific use cases are as follows:
--Add special effects to specified creatures
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the id of the special effect to be added,which generally starts from 1000
--The third parameter is the scaling of the special effect
Actor:playBodyEffectById(0,1029,1)
--Show in chat box
Chat:sendSystemMsg("Add 1029 special effects to the homeowner,the scale is 1")

# stopBodyEffectById 1.2+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Stop effect on specified players
  • The specific use cases are as follows:
--Stop a special effect of the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the id of the special effect to be stopped,roughly starting from 1000
Actor:stopBodyEffectById(0,1029)
--Show in chat box
Chat:sendSystemMsg("Stop the host's 1029 special effects")

# setBodyEffectScale 1.2+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set up effect size on specified players
  • The specific use cases are as follows:
--Add special effects to the homeowner
Actor:playBodyEffectById(0,1029,1)
--Show in chat box
Chat:sendSystemMsg("Add 1029 special effects to the homeowner,the scale is 1")
--Set the scaling of the specified effects of the creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the id of the special effect to be scaled,starting from about 1000
--The third parameter is the scaling
Actor:setBodyEffectScale(0,1029,2)
--Show in chat box
Chat:sendSystemMsg("double the homeowner's 1029 special effects")

# playSoundEffectById 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play sound effect on specified Actor
  • The specific use cases are as follows:
--Play music to specified creatures
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter 10713 is the sound effect id to be played,which can be viewed in the "Sound Effect Table Data" of "Mini World ID Query"
--The last three parameters are:volume,pitch,whether to loop playback
Actor:playSoundEffectById(0,10713,100,1,false)
--Show in chat box
Chat:sendSystemMsg("playing music to the host")

# stopSoundEffectById 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Stop sound effect on specified Actor
  • The specific use cases are as follows:
--Play music to the host
Actor:playSoundEffectById(0,10713,100,1,false)
--Display a prompt in the chat box
Chat:sendSystemMsg("Playing music to the host,stop the playback with animated expressions")
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Stop playing music 10713 to the host
	--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
	--The second parameter is the music id to stop playing,which can be viewed in the "Sound Effect Table Data" of "Mini World ID Query"
	Actor:stopSoundEffectById(0,10713)
	--Show in chat box
	Chat:sendSystemMsg("Stop playing music 10713 to the host")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# appendSpeed 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Attach a speed to the actor
  • The specific use cases are as follows:
--Add a speed to the specified creature
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The last three parameters are the partial velocity in the east,up and north directions,which can be negative
Actor:appendSpeed(0,5,6,7)
--Show in chat box
Chat:sendSystemMsg("The homeowner was ejected,and the speeds to the east,up,and north were 5,6,7")

# getFaceDirection 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get actor orientation
  • The specific use cases are as follows:
--Get the orientation of the specified creature in all directions,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,dirx,diry,dirz=Actor:getFaceDirection(0)
--Show in chat box
Chat:sendSystemMsg("Homeowner is currently offset in the east-west direction"..dirx..",offset in the up-down direction "..diry..",offset in the north-south direction"..dirz)

# calcDirectionByDirection 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Calculate the absolute direction by local coordinate direction
  • The specific use cases are as follows:
local result = Actor:calcDirectionByDirection(objid, vx, vy, vz)

# calcDirectionByAngle 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: The absolute direction is calculated by using local spherical coordinates
  • The specific use cases are as follows:
local result = Actor:calcDirectionByAngle(objid, yaw, pitch)

# calcDirectionByYawDirection 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Calculate the absolute positive direction from the local coordinate direction (ignore the Angle of view)
  • The specific use cases are as follows:
local result = Actor:calcDirectionByYawDirection(objid, vx, vy, vz)

# calcDirectionByYawAngle 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Calculate the absolute positive direction from local spherical coordinates (ignore the Angle of view)
  • The specific use cases are as follows:
local result = Actor:calcDirectionByYawAngle(objid, yaw, pitch)

# getEyeHeight 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Acquire the height of eyes
  • The specific use cases are as follows:
--Get the eye height of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,height=Actor:getEyeHeight(0)
--Show in chat box
Chat:sendSystemMsg("The homeowner's eye height is"..height)

# getEyePosition 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Acquire the location of eyes
  • The specific use cases are as follows:
--Get the eye coordinates of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the host
local result,x,y,z=Actor:getEyePosition(0)
--Show in chat box
Chat:sendSystemMsg("The homeowner's eye coordinates are:("..x..","..y..","..z..")")

# getBodySize 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Acquire the body dimensions
  • The specific use cases are as follows:
--Get the size of the specified creature,the parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the owner
local result,w,h=Actor:getBodySize(0)
--Show in chat box
Chat:sendSystemMsg("Homeowner's body width:"..w..",height:"..h)

# playAct 1.5+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play Expression
  • The specific use cases are as follows:
--Let the specified creature play an animated expression
--The first parameter is the id of the creature in the archive,which can be the player's mini number,and 0 is the homeowner
--The second parameter is the action expression id,which can be queried in "Action Table Data" of "Mini World ID Query"
Actor:playAct(0,1)
--Show in chat box
Chat:sendSystemMsg("Let the homeowner play a greeting gesture")
Last Update: 6/11/2020, 9:30:46 PM