原来的代码过于复杂
- if nHour == 0 or nHour == 2 or nHour == 4 or nHour == 6 or nHour == 8 or nHour == 10 or nHour == 12 or nHour == 14 or nHour == 16 or nHour == 18 or nHour == 20 or nHour == 22 then
- x900047_CreateMonster( sceneId )
- AddGlobalCountNews( sceneId, x900047_g_BossSysMsgByGroupID[27].Msg )
- end
复制代码 利用取余数运算,优化为:
- if sceneId==423 then --火焰山:魔王·共工
- if (nHour - floor(nHour/2)*2 )==0 then
- x900047_CreateMonster( sceneId )
- AddGlobalCountNews( sceneId, x900047_g_BossSysMsgByGroupID[28].Msg )
- end
- end
复制代码 天龙LUA4不支持%运算,a%b = a-floor(a/2)*2 )
方法二,用自带函数实现双数刷新:
local CurHourTime = GetQuarterTime()
--每双数点散落雪堆....
local QTime = mod(CurHourTime,100)
if mod(QTime,8) ~= 0 then
return
end
每半小时刷新一次:
(nMinute==15) or (nMinute==45)
每小时刷新
nMinute==45
|