# 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:
--判断id为1的计时器是否存在,参数1就是计时器id
local result=MiniTimer:isExist(1)
if result==0 then--如果存在
	--在聊天框显示
	Chat:sendSystemMsg("id为1的计时器存在!")
	--让id为1的计时器开始20秒倒计时
	MiniTimer:startBackwardTimer(1,20,false)
	--在房主游戏界面显示计时时间
	MiniTimer:showTimerTips({0},1,"id为1的计时器的计时为:",true)
	--在聊天框显示
	Chat:sendSystemMsg("开始20秒倒计时!")
else--如果不存在
	--在聊天框显示
	Chat:sendSystemMsg("id为1的计时器不存在!")
	--创建一个计时器,命名为“timer”
	local result2,id=MiniTimer:createTimer("timer",nil,true)
	--在聊天框显示
	Chat:sendSystemMsg("创建了一个名为“timer”的新计时器并开始20秒倒计时!计时器id为"..id)
	--让新创建的这个计时器开始20秒倒计时
	MiniTimer:startBackwardTimer(id,20,false)
	--在房主游戏界面显示计时时间
	MiniTimer:showTimerTips({0},id,"id为1的计时器的计时为:",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:
--创建一个新计时器,命名为“timer”
--第一个参数就是创建的计时器的名字,第二个参数是Map ID(作用不明,Un-filled by dafult),第三个参数是是否为存档私有计时器(改为false则所有存档可共用此计时器。Un-filled by dafult)
local result,id=MiniTimer:createTimer("timer",nil,true)
--在聊天框显示
Chat:sendSystemMsg("新建了名为“timer”的计时器,id为"..id)

# deleteTimer

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Delete Timer
  • The specific use cases are as follows:
--删除id为1的计时器。参数为要删除的计时器的id
MiniTimer:deleteTimer(1)
--在聊天框显示
Chat:sendSystemMsg("删除了id为1的计时器!")

# 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:
--让id为1的计时器开始20秒倒计时
--第一个参数为计时器id,第二个参数为倒计时时间,第三个参数为Whether is repeated(貌似无效)
MiniTimer:startBackwardTimer(1,20,false)
--在聊天框显示
Chat:sendSystemMsg("启动了id为1的计时器,倒计时20秒!")
--在房主游戏界面显示id为1的计时器的计时
MiniTimer:showTimerTips({0},1,"id为1的计时器的计时为:",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:
--让id为1的计时器递增计时,参数1就是计时器id
MiniTimer:startForwardTimer(1)
--在聊天框显示
Chat:sendSystemMsg("id为1的计时器开始正向计时!")
--在房主游戏界面显示id为1的计时器的计时
MiniTimer:showTimerTips({0},1,"id为1的计时器的计时为:",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:
--暂停id为1的计时器的计时,参数1就是计时器的id
MiniTimer:pauseTimer(1)
--在聊天框显示
Chat:sendSystemMsg("暂停了id为1的计时器!")

# 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:
--恢复id为1的计时器的计时,参数1就是计时器的id
MiniTimer:resumeTimer(1)
--在聊天框显示
Chat:sendSystemMsg("恢复了id为1的计时器!")
--在房主游戏界面显示id为1的计时器的计时
MiniTimer:showTimerTips({0},1,"id为1的计时器的计时为:",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:
--停止id为1的计时器的计时,参数1就是计时器的id
MiniTimer:stopTimer(1)
--在聊天框显示
Chat:sendSystemMsg("停止了id为1的计时器!")

# 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:
--在聊天框显示提示
Chat:sendSystemMsg("每次做动画表情都会显示id为1的计时器的计时时间!")
--当监听到动画表情时,执行此函数
local function showtime()
	--获取id为1的计时器的计时时间,参数1就是计时器的id
	local result,second=MiniTimer:getTimerTime(1)
	--在聊天框显示
	Chat:sendSystemMsg("id为1的计时器的计时时间为"..second)
end
--注册动画表情监听器,执行showtime函数
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],showtime)
Last Update: 6/11/2020, 9:30:46 PM