OTcreator
Well-Known Member
- Joined
- Feb 14, 2022
- Messages
- 482
- Solutions
- 1
- Reaction score
- 53
Hello!
Possible to optimize this talkaction scripts?
Possible to optimize this talkaction scripts?
LUA:
local function secondsToReadable(s)
local hours = math.floor(s / 3600)
local minutes = math.floor(math.fmod(s, 3600)/60)
local seconds = math.floor(math.fmod(s, 60))
return (hours > 0 and (hours .. ' hours ') or '') ..
(minutes > 0 and (minutes .. ' minutes ') or '') ..
(seconds > 0 and (seconds .. ' seconds ') or '')
end
local ImbuementTalk = TalkAction("!imbuements")
function ImbuementTalk.onSay(player, words, param, type)
local cur_time = os.time()
local strike_one = player:getStorageValue(12400)
local strike_two = player:getStorageValue(12401)
local strike_three = player:getStorageValue(12402)
local void_one = player:getStorageValue(12403)
local void_two = player:getStorageValue(12404)
local void_three = player:getStorageValue(12405)
local vamp_one = player:getStorageValue(12406)
local vamp_two = player:getStorageValue(12407)
local vamp_three = player:getStorageValue(12408)
if strike_one > cur_time then
player:sendChannelMessage("Imbuement Strike", "Time to end: " .. os.date('!%Hh %Mm %Ss', strike_one - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif strike_two > cur_time then
player:sendChannelMessage("Imbuement Strike", "Time to end: " .. os.date('!%Hh %Mm %Ss', strike_two - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif strike_three > cur_time then
player:sendChannelMessage("Imbuement Strike", "Time to end: " .. os.date('!%Hh %Mm %Ss', strike_three - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
end
if void_one > cur_time then
player:sendChannelMessage("Imbuement Void", "Time to end: " .. os.date('!%Hh %Mm %Ss', void_one - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif void_two > cur_time then
player:sendChannelMessage("Imbuement Void", "Time to end: " .. os.date('!%Hh %Mm %Ss', void_two - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif void_three > cur_time then
player:sendChannelMessage("Imbuement Void", "Time to end: " .. os.date('!%Hh %Mm %Ss', void_three - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
end
if vamp_one > cur_time then
player:sendChannelMessage("Imbuement Vampirism", "Time to end: " .. os.date('!%Hh %Mm %Ss', vamp_one - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif vamp_two > cur_time then
player:sendChannelMessage("Imbuement Vampirism", "Time to end: " .. os.date('!%Hh %Mm %Ss', vamp_two - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
elseif vamp_three > cur_time then
player:sendChannelMessage("Imbuement Vampirism", "Time to end: " .. os.date('!%Hh %Mm %Ss', vamp_three - cur_time) .. ".", TALKTYPE_CHANNEL_O, 15)
end
return false
end
ImbuementTalk:register()