PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: slick on 30 August, 2005, 01:33:04

Title: triv break in trivbot
Post by: slick on 30 August, 2005, 01:33:04
hello it's me again  :D ummm i'm running a trivbot Trivia Ex V 0.645 by chilla problem i'm having with it is it won't take a break when it should. If i set it to run for 2 mins it works i set it for over 2 it just keeps running



Max1 = 30         -- How many questions are loaded into Memory

Max7 = 10         -- Trivia Break Time in minutes
Max4 = 30         -- Time in minutes till Trivia Break

Trivbreak = 1         -- 1 = do a triviabreak between Max4 Minutes., 2 == no triviabreak

--------------------------------------------

Max2 = 15         -- Time between each hint in seconds

--------------------------------------------

Max3 = 100         -- The number of trivia scores shown
Max9 = 100         -- Number of top trivias shown

Max5 = 10         -- Time in minutes between each score and player saving
--------------------------------------------

Max6 = 1         -- Stands for how many chars are rvealed per hint.
Max8 = 20         -- Stands for how many Hints are displayed. This overruns Max6 (May not be totally accurate)
Max10 = 1         -- The Question will be solved when there are only Max10 hints left

------------------------------------------------------------------------

function OnTimer()
   foreachi(trivtimerset, function(i,_) trivtimerset = trivtimerset + 1 end)
   if (trivtimerset[2] == tTrivBreak) then
      trivtimerset[2] = 0
      if (Trivbreak == 1) and (curTriv.GetQues == 1) then
         curTriv.GetQues = 3
         tTrivBreak = Max7
         SendDataMP("Short Trivia break for "..(Max7/60).." min.")
      elseif (Trivbreak == 1) and (curTriv.GetQues == 3) then
         curTriv.GetQues = 1
         tTrivBreak = Max4
      end
   end
   if trivtimerset[1] == Max2 then
      trivtimerset[1] = 0
      if (curTriv.GetQues == 1) then
         if getn(tTrivQuestions) == 0 then

            GetQuestions(Max1)

         end

         curTriv.curNum = tTrivQuestions[1][4]

         curTriv.curCat = tTrivQuestions[1][1]

         curTriv.curQues = tTrivQuestions[1][2]

         curTriv.curAnswer = tTrivQuestions[1][3]
         curTriv.curAvailAnswers = getn(curTriv.curAnswer)

         tremove(tTrivQuestions,1)
         curTriv.Points = 0
         UnRevealed = {}
         curTriv.curHint = gsub(curTriv.curAnswer[1],"(%S)",function (w)  curTriv.Points = curTriv.Points + 1 return(RevealChar) end)
         if TriviaConfig.TrivShowHint == 2 then
            if ((curTriv.Points/Max8 - floor(curTriv.Points/Max8)) >= 0.5) then
               curTriv.RevealHowMany = floor(curTriv.Points/Max8) + 1
            elseif (floor(curTriv.Points/Max8) == 0) then
               curTriv.RevealHowMany = 1
            else
               curTriv.RevealHowMany = floor(curTriv.Points/Max8)
            end
         else
            curTriv.RevealHowMany = Max6
         end

         SendQuestion(curTriv.curCat,curTriv.curQues,curTriv.curHint,curTriv.Points,curTriv.curNum,curTriv.QuestionsTotal,curTriv.curAvailAnswers)
         curTriv.curstart = clock()

         curTriv.GetQues = 0
      elseif (curTriv.GetQues == 0) then
         curTriv.curHint = RevealChars(curTriv.curAnswer[1],curTriv.curHint)

         if curTriv.curAnswer[1] ~= curTriv.curHint then

            SendQuestion(curTriv.curCat,curTriv.curQues,curTriv.curHint,curTriv.Points,curTriv.curNum,curTriv.QuestionsTotal,curTriv.curAvailAnswers)

         else
            SendDataMP("The right answer was:  "..curTriv.curHint)
            if curTriv.curAvailAnswers > 1 then
               local msg = ""
               for i = 2,getn(curTriv.curAnswer) do
                  msg = msg..curTriv.curAnswer..", "
               end
               SendDataMP("Other answers were: "..msg)
            end
            curTriv.GetQues,curTriv.curAnswer = 1,nil
            if curTriv.curStreak.curStreak >= 3 then
               SendDataMP("There goes "..curTriv.curStreak.curNick.."'s streak of  "..curTriv.curStreak.curStreak)
            end
            curTriv.curStreak.curNick,curTriv.curStreak.curStreak,curTriv.curStreak.set = "",0,0

         end
      end
   end

   if trivtimerset[3] >= Max5 then

      trivtimerset[3] = 0

      WriteTable(Scores, "Scores", "Scores.txt")

   end

end






I believe these are the 2 sections that effect this hope somebody can help :)