Difference between revisions of "NCScriptsObjectEventHandling"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
<p style="color: #DDDD88;font-size: 22px;width:60%;margin: 0 auto">Event Handler By Type</p>
+
<p style="width:60%;margin: 0 auto">[[NewDawnHome|[Main]]] [[NDServerIndexScriptsMain|[Lua Examples]]]</p>
 
+
<p style="color: #DDDD88;font-size: 22px;width:60%;margin: 0 auto">Event Handler & Examples</p>
 
<center>
 
<center>
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">Arrived</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">Arrived</p>Params<br>bool - true if mobile arrives successfully at the end location || Fires on a mobile when he arrives or fails to arrive at his path or move end point.
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   function OnPatrolArrived(arriveSuccess)
 +
 
 +
      if( AI.StateMachine.CurState ~= "Patrol" ) then
 +
          -- ignore this message if we are no longer patrolling
 +
          return
 +
      end
 +
 
 +
      -- TODO: Handle the case where he fails to path properly
 +
      -- for now we just move on to the next point in the patrol
 +
      if not(arriveSuccess) then
 +
      end
 +
 
 +
      DoPatrol()
 +
  end
 +
  RegisterEventHandler(EventType.Arrived, "patrol", OnPatrolArrived)
 
</div>
 
</div>
  
Line 15: Line 29:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientObjectCommand</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CharacterListRequestResult</p>Params<br>eventid - event identifier passed to the character list request<br>Returns<br>table - list of character name and associated character id || This message fires when a character list request either succeeds or fails.
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   function CharacterListRequestResult(characterlist)
 +
      if(characterlist) then
 +
          for k,v in pairs(table_name) do
 +
        print(k,v)
 +
          end
 +
      end
 +
  end
 +
  RegisterEventHandler(EventType.CharacterListRequestResult, "request", CharacterListRequestResult)
 
</div>
 
</div>
  
Line 26: Line 47:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetAnyObjResponse</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientObjectCommand</p>Params<br>(...) If arguments are specified, they are sent in a parameterized list of strings
 +
|| Fires on an object specified by the client with the client supplied data. Object messages are ways to execute script directly on specified object from the client. See the client specific reference NEED REF to see which commands the client can send. EventIdentifier:.
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   RegisterEventHandler(EventType.ClientObjectCommand,"arena", function (user,commandName,...)
 +
      if(commandName ~= nil and arenaCommandHandlers[commandName] ~= nil) then
 +
          --DebugMessage("command found")
 +
          arenaCommandHandlers[commandName](user,...)
 +
      end
 +
  end)
 
</div>
 
</div>
  
Line 37: Line 64:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetGameObjResponse</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetAnyObjResponse</p>Params<br>EventId - specified when RequestClientTargetAnyObj(...) is called  || This is a response from the client from the RequestClientTargetAnyObj(...) function.<br>Gameobject - object user selected, nil if user cancelled
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   function HandleInteract(objRef,user)
 +
      print(objRef:GetName().. " was targeted by " .. user:GetName())
 +
  end
 +
 
 +
  RegisterEventHandler(EventType.ClientTargetAnyObjResponse, "targetObj", function (objRef,user)
 +
      HandleInteract(objRef,user)
 +
  end) 
 
</div>
 
</div>
  
Line 48: Line 81:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CreatedObject</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetGameObjResponse</p>Params<br>EventId - Specified when RequestClientTargetGameObj(...) is called<br>gameobject -  Object user selected. nil if user cancelled || This is a response from the client from the RequestClientTargetGameObj(...) function.
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   function HandleInteract(objRef,user)
 +
      print(objRef:GetName().. " was targeted by " .. user:GetName())
 +
  end
 +
 
 +
  RegisterEventHandler(EventType.ClientTargetGameObjResponse, "targetObj", function (objRef,user)
 +
      HandleInteract(objRef,user)
 +
  end) 
 
</div>
 
</div>
  
Line 59: Line 98:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CreatedObject</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ContextMenuResponse</p>Params<br>EventId - ResponseId specified when OpenCustomContextMenu() is called<br>gameobject - user the menu was sent too<br>menuid - menu option id ("" if canceled) || This is a response from the client from the OpenCustomContextMenu() function.
 
|}
 
|}
 
</center>
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
   CODE BLOCK
+
   function HandleInteract(objRef,menuId)
 +
      print(objRef:GetName().. " used their context menu option" .. menuId)
 +
  end
 +
 
 +
  RegisterEventHandler(EventType.ContextMenuResponse, "contextMenuUsed", function (objRef,menuId)
 +
      HandleInteract(objRef,menuId)
 +
  end)
 
</div>
 
</div>
  
Line 70: Line 115:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetLocResponse</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CreatedObject</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 81: Line 126:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ClientTargetAnyObjResponse</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">DestroyAllComplete</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 92: Line 137:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CreatedObject</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">DestroyedObject</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 103: Line 148:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">ContextMenuResponse</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">DynamicWindowResponse</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 114: Line 159:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">CreatedObject</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">EnterView</p> || .
|}
 
</center>
 
<p style="width: 60%;margin: 0 auto">Example</p>
 
<div style="width:60%;margin: 0 auto">
 
  CODE BLOCK
 
</div>
 
 
 
<center>
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">DestroyAllComplete</p> || .
 
 
|}
 
|}
 
</center>
 
</center>
Line 136: Line 170:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">DestroyedObject</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">GetBanListResult</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 147: Line 181:
 
{| class="wikitable" | style="width: 60%"
 
{| class="wikitable" | style="width: 60%"
 
|-
 
|-
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">EnterView</p> || .
+
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">GlobalVarUpdateResult</p> || .
 
|}
 
|}
 
</center>
 
</center>
Line 302: Line 336:
 
|-
 
|-
 
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">Use</p> || .
 
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">Use</p> || .
 +
|}
 +
</center>
 +
<p style="width: 60%;margin: 0 auto">Example</p>
 +
<div style="width:60%;margin: 0 auto">
 +
  CODE BLOCK
 +
</div>
 +
 +
<center>
 +
{| class="wikitable" | style="width: 60%"
 +
|-
 +
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">UserLogin</p> || .
 +
|}
 +
</center>
 +
<p style="width: 60%;margin: 0 auto">Example</p>
 +
<div style="width:60%;margin: 0 auto">
 +
  CODE BLOCK
 +
</div>
 +
 +
<center>
 +
{| class="wikitable" | style="width: 60%"
 +
|-
 +
|style="width: 40%"| <p style="color: #DDDD88;font-size: 18px">UserLogout</p> || .
 
|}
 
|}
 
</center>
 
</center>

Latest revision as of 20:19, 25 November 2019

[Main] [Lua Examples]

Event Handler & Examples

Arrived

Params
bool - true if mobile arrives successfully at the end location
Fires on a mobile when he arrives or fails to arrive at his path or move end point.

Example

 function OnPatrolArrived(arriveSuccess)
 
     if( AI.StateMachine.CurState ~= "Patrol" ) then
         -- ignore this message if we are no longer patrolling
         return
     end
 
     -- TODO: Handle the case where he fails to path properly
     -- for now we just move on to the next point in the patrol
     if not(arriveSuccess) then
     end
 
     DoPatrol()
 end
 RegisterEventHandler(EventType.Arrived, "patrol", OnPatrolArrived)

CharacterListRequestResult

Params
eventid - event identifier passed to the character list request
Returns
table - list of character name and associated character id
This message fires when a character list request either succeeds or fails.

Example

 function CharacterListRequestResult(characterlist)
     if(characterlist) then
         for k,v in pairs(table_name) do
 	      print(k,v)
         end
     end
 end
 RegisterEventHandler(EventType.CharacterListRequestResult, "request", CharacterListRequestResult)

ClientObjectCommand

Params
(...) If arguments are specified, they are sent in a parameterized list of strings
Fires on an object specified by the client with the client supplied data. Object messages are ways to execute script directly on specified object from the client. See the client specific reference NEED REF to see which commands the client can send. EventIdentifier:.

Example

 RegisterEventHandler(EventType.ClientObjectCommand,"arena", function (user,commandName,...)		
     if(commandName ~= nil and arenaCommandHandlers[commandName] ~= nil) then			
         --DebugMessage("command found")
         arenaCommandHandlers[commandName](user,...)
     end
 end)

ClientTargetAnyObjResponse

Params
EventId - specified when RequestClientTargetAnyObj(...) is called
This is a response from the client from the RequestClientTargetAnyObj(...) function.
Gameobject - object user selected, nil if user cancelled

Example

 function HandleInteract(objRef,user)
     print(objRef:GetName().. " was targeted by " .. user:GetName())
 end
 
 RegisterEventHandler(EventType.ClientTargetAnyObjResponse, "targetObj", function (objRef,user)
     HandleInteract(objRef,user)
 end)  

ClientTargetGameObjResponse

Params
EventId - Specified when RequestClientTargetGameObj(...) is called
gameobject - Object user selected. nil if user cancelled
This is a response from the client from the RequestClientTargetGameObj(...) function.

Example

 function HandleInteract(objRef,user)
     print(objRef:GetName().. " was targeted by " .. user:GetName())
 end
 
 RegisterEventHandler(EventType.ClientTargetGameObjResponse, "targetObj", function (objRef,user)
     HandleInteract(objRef,user)
 end)  

ContextMenuResponse

Params
EventId - ResponseId specified when OpenCustomContextMenu() is called
gameobject - user the menu was sent too
menuid - menu option id ("" if canceled)
This is a response from the client from the OpenCustomContextMenu() function.

Example

 function HandleInteract(objRef,menuId)
     print(objRef:GetName().. " used their context menu option" .. menuId)
 end
 
 RegisterEventHandler(EventType.ContextMenuResponse, "contextMenuUsed", function (objRef,menuId)
     HandleInteract(objRef,menuId)
 end) 

CreatedObject

.

Example

 CODE BLOCK

DestroyAllComplete

.

Example

 CODE BLOCK

DestroyedObject

.

Example

 CODE BLOCK

DynamicWindowResponse

.

Example

 CODE BLOCK

EnterView

.

Example

 CODE BLOCK

GetBanListResult

.

Example

 CODE BLOCK

GlobalVarUpdateResult

.

Example

 CODE BLOCK

ItemEquipped

.

Example

 CODE BLOCK

ItemUnEquipped

.

Example

 CODE BLOCK

LoadedFromBackup

.

Example

 CODE BLOCK

LeaveView

.

Example

 CODE BLOCK

CreatedObject

.

Example

 CODE BLOCK

ModuleAttached

.

Example

 CODE BLOCK

PathingInterrupted

.

Example

 CODE BLOCK

PlayerSpeech

.

Example

 CODE BLOCK

RequestEquip

.

Example

 CODE BLOCK

RequestPickUp

.

Example

 CODE BLOCK

StartMoving

.

Example

 CODE BLOCK

StopMoving

.

Example

 CODE BLOCK

Timer

.

Example

 CODE BLOCK

Use

.

Example

 CODE BLOCK

UserLogin

.

Example

 CODE BLOCK

UserLogout

.

Example

 CODE BLOCK