# MiniTimer Management

Before using the MiniTimer API, you need to create a MiniTimer API Management object as follows:

local MiniTimer = class.MiniTimer.new()

The specific function name and description are as follows:

Serial number Function name Description
2 isExist(...) Determine if Timer exists
3 createTimer(...) Add Timer
4 deleteTimer(...) Delete Timer
5 startBackwardTimer(...) Start Backward Timer
6 startForwardTimer(...) Start Forward Timer
7 pauseTimer(...) Pause Timer
8 resumeTimer(...) Resume Timer
9 stopTimer(...) Stop Timer
10 changeTimerTime(...) Change Timer Interval
11 getTimerTime(...) Get Timer Time

# isExist

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Determine if Timer exists
  • The specific use cases are as follows:
--Determine whether the timer with id 1 exists,parameter 1 is the timer id
local result=MiniTimer:isExist(1)
if result==0 then--if it exists
	--Show in chat box
	Chat:sendSystemMsg("A timer with id 1 exists!")
	--Let the timer with id 1 start to count down for 20 seconds
	MiniTimer:startBackwardTimer(1,20,false)
	--Display timing time on homeowner game interface
	MiniTimer:showTimerTips({0},1,"The timer with id 1 is:",true)
	--Show in chat box
	Chat:sendSystemMsg("Start a 20-second countdown!")
else--if it does not exist
	--Show in chat box
	Chat:sendSystemMsg("The timer with id 1 does not exist!")
	--Create a timer,named "timer"
	local result2,id=MiniTimer:createTimer("timer",nil,true)
	--Show in chat box
	Chat:sendSystemMsg("Create a new timer named "timer" and start a 20-second countdown! The timer id is "..id)
	--Let the newly created timer count down for 20 seconds
	MiniTimer:startBackwardTimer(id,20,false)
	--Display timing time on homeowner game interface
	MiniTimer:showTimerTips({0},id,"The timer with id 1 is:",true)
end

# createTimer

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add Timer
  • The specific use cases are as follows:
--Create a new timer,named "timer"
--The first parameter is the name of the timer created,the second parameter is the map id (unknown,not transmitted by default),and the third parameter is whether it is an archive private timer (change to false to share all archives)This timer. Not transmitted by default)
local result,id=MiniTimer:createTimer("timer",nil,true)
--Show in chat box
Chat:sendSystemMsg("New timer named "timer",id is "..id)

# deleteTimer

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Delete Timer
  • The specific use cases are as follows:
--Delete the timer with id 1.The parameter is the id of the timer to be deleted
MiniTimer:deleteTimer(1)
--Show in chat box
Chat:sendSystemMsg("The timer with id 1 has been deleted!")

# startBackwardTimer

  • Parameters and types:
    • id:intTimer index
    • interval:intBackward Timer Interval
    • repeated:boolWhether is repeated
  • Return value and types:
  • The main role of this method: Start Backward Timer
  • The specific use cases are as follows:
--Let the timer with id 1 start to count down for 20 seconds
--The first parameter is the timer id,the second parameter is the countdown time,and the third parameter is whether to repeat the execution (seems to be invalid)
MiniTimer:startBackwardTimer(1,20,false)
--Show in chat box
Chat:sendSystemMsg("I started a timer with id 1,count down 20 seconds!")
--Display the timing of the timer with id 1 on the homeowner game interface
MiniTimer:showTimerTips({0},1,"The timer with id 1 is:",true)

# startForwardTimer

  • Parameters and types:
    • id:intTimer index
  • Return value and types:
  • The main role of this method: Start Forward Timer
  • The specific use cases are as follows:
--Let the timer with id 1 count up,the parameter 1 is the timer id
MiniTimer:startForwardTimer(1)
--Show in chat box
Chat:sendSystemMsg("The timer with id 1 starts to count forward!")
--Display the timing of the timer with id 1 on the homeowner game interface
MiniTimer:showTimerTips({0},1,"The timer with id 1 is:",true)

# pauseTimer

  • Parameters and types:
    • id:intTimer index
  • Return value and types:
  • The main role of this method: Pause Timer
  • The specific use cases are as follows:
--Pause the timer with the id of 1,the parameter 1 is the id of the timer
MiniTimer:pauseTimer(1)
--Show in chat box
Chat:sendSystemMsg("Timer with id 1 paused!")

# resumeTimer

  • Parameters and types:
    • id:intTimer index
  • Return value and types:
  • The main role of this method: Resume Timer
  • The specific use cases are as follows:
--Resume the timer with the id of 1,the parameter 1 is the id of the timer
MiniTimer:resumeTimer(1)
--Show in chat box
Chat:sendSystemMsg("The timer with id 1 is restored!")
--Display the timing of the timer with id 1 on the homeowner game interface
MiniTimer:showTimerTips({0},1,"The timer with id 1 is:",true)

# stopTimer

  • Parameters and types:
    • id:intTimer index
  • Return value and types:
  • The main role of this method: Stop Timer
  • The specific use cases are as follows:
--Stop the timer with id 1,the parameter 1 is the id of the timer
MiniTimer:stopTimer(1)
--Show in chat box
Chat:sendSystemMsg("The timer with id 1 stopped!")

# changeTimerTime

  • Parameters and types:
    • id:intTimer index
    • time:int计时器计时
  • Return value and types:
  • The main role of this method: Change Timer Interval
  • The specific use cases are as follows:
local result = MiniTimer:changeTimerTime(id, curtime)

# getTimerTime

  • Parameters and types:
    • id:intTimer index
  • Return value and types:
  • The main role of this method: Get Timer Time
  • The specific use cases are as follows:
--Display a prompt in the chat box
Chat:sendSystemMsg("Every time you animate an emoticon,the count time of the timer with id 1 will be displayed!")
--When the animated expression is monitored,execute this function
local function showtime()
	--Get the timer time of the timer with id 1,parameter 1 is the id of the timer
	local result,second=MiniTimer:getTimerTime(1)
	--Show in chat box
	Chat:sendSystemMsg("The timer with the id of 1 is "..second)
end
--Register animation expression listener,execute showtime function
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],showtime)
Last Update: 6/11/2020, 9:30:46 PM