# Function Listener management API ListenParam

Before using the function listener API, you need to create a object of function listener management, the method is as follows: (Obsolete)

local ListenParam = class.ListenParam.new()

The specific function name and description are as follows:

Sequence Number Function Name Function Description
1 AddGraphicsListenParam(...) Add graphic information, Monitor trigger parameters, Refresh object id, parameter information, Callback method 1.8+

# AddGraphicsListenParam 1.8+

  • Parameters and Types:
    • graphid:[number](./global.md#lua Native data type)Created graphic information ID
    • funcs:[table](./global.md#lua Native data type)List of listener functions
    • param:[table](./global.md#lua Native data type)Parameters required by the listener function
  • Return value and type:
    • [ErrorCode](./global.md#Error codes info).OK
  • This function is mainly for:Add graphic information, Monitor trigger parameters, Refresh object id, parameter information, Callback method
  • The specific references are as follow:
-- Basic information of creating progress bar
local function func_3()
    local v1 = math.random(1,100) -- The current value of the progress bar
    local v2 = 100  -- Maximum value of the progress bar
    local v3 = 0xFFC107  --color code
    local v4 = 1  -- Number
    return Graphics:makeGraphicsProgress(v1, v2, v3, v4)
end
local function getdir(playerid)
    return {x =0 ,y =1,z = 0}
end
-- Trigger Time callback function
local function func_event(param)
    local playerid = CurEventParam.TriggerByPlayer
    if playerid then
        local offest = 100 -- Offset distance in direction
        local dir = getdir(playerid) -- Get directions
        local graphinfo = func_3() -- Get graphic information
        -- Create a progress bar message
        local result, grapid = Graphics:createGraphicsProgressByActor(playerid,graphinfo,dir,offest)
        if result == ErrorCode.OK then
            -- Get the current value of the progress bar
			local function getCurValue(params)
				local cur = Player:getAttr(params.TriggerByPlayer,PLAYERATTR.CUR_HP) -- Get current blood volume
				return cur + math.random(1,20)
			end
			-- Get the maximum value of the progress bar
			local function getMaxValue(params)
				local max = Player:getAttr(params.TriggerByPlayer,PLAYERATTR.MAX_HP) -- Get maximum health
				return max + math.random(50,100)
			end
			--List of Listener functions
			local funcs = {getCurValue,getMaxValue} 
			-- Add the successful progress bar to the automatic listener
            ListenParam:AddGraphicsListenParam(grapid,funcs,param) 
        end
    end
end
ScriptSupportEvent:registerEvent('Player.PlayAction', func_event)
Last Update: 2/19/2021, 9:36:24 AM