Countdown - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Countdown (/thread-1314.html) |
RE: Countdown - daniel0916 - 01-16-2014 RE: Countdown - NiLSPACE - 01-16-2014 Not sure if this is the best method (or if it works) but: function CountDown(Param) cRoot:Get():BroadcastChat(Param[1]) end) for I=1, 10 do -- Countdown. AddSchedule(CountDown, {I}, I * 20)) -- 20 ticks is one second right? then 1 * 20 is 20 ticks is one second etc. end RE: Countdown - daniel0916 - 01-16-2014 it works but it is not 9 8 7 it is: 1 2 3 And it comes this error: Code: [17:25:11] Stack trace: The line is: if ScheduleTable[I][3] < 0 then RE: Countdown - NiLSPACE - 01-16-2014 (01-16-2014, 02:26 AM)daniel0916 Wrote: it works but it is notThen change for I=1, 10 do -- Countdown. AddSchedule(CountDown, {I}, I * 20)) -- 20 ticks is one second right? then 1 * 20 is 20 ticks is one second etc. endto local COUNT_TO = 10 for I=COUNT_TO, 1, -1 do -- Countdown AddSchedule(CountDown, {I}, (COUNT_TO - I) * 20)) end Quote:And it comes this error: When do you get the error? When it has finished counting down? RE: Countdown - daniel0916 - 01-16-2014 (01-16-2014, 02:30 AM)STR_Warrior Wrote: When do you get the error? When it has finished counting down? Every second and after 10 seconds the error stops. RE: Countdown - NiLSPACE - 01-16-2014 And you do still get the countdown message(9, 8, 7 etc)? Do you have anything else in the function that gets called? RE: Countdown - daniel0916 - 01-16-2014 (01-16-2014, 02:38 AM)STR_Warrior Wrote: And you do still get the countdown message(9, 8, 7 etc)? Do you have anything else in the function that gets called? Yes, the message come. No, i haven't anything else in this function. RE: Countdown - NiLSPACE - 01-16-2014 Could you post all your code somewhere? or send it to me using an PM. Ofcourse if you don't want to just don't do it, but I don't think I can see what's going on without seeing the code around everything. EDIT: Wait!! I've might found the problem. I'll have to rewrite the ScheduleTicking though. Just a sec. RE: Countdown - daniel0916 - 01-16-2014 (01-16-2014, 02:45 AM)STR_Warrior Wrote: Could you post all your code somewhere? or send it to me using an PM. Ofcourse if you don't want to just don't do it, but I don't think I can see what's going on without seeing the code around everything. (Do you know a git page where i can upload my code private? It should be safe.) Okey, thanks. RE: Countdown - NiLSPACE - 01-16-2014 Use this code for the OnScheduleTick function: function OnScheduleTick(Time) for Idx, ScheduleTask in pairs(ScheduleTable) do ScheduleTable[Idx][3] = ScheduleTable[Idx][3] - 1 -- Countdown if ScheduleTask[3] < 1 then ScheduleTask[1](ScheduleTask[2]) ScheduleTable[Idx] = nil end end end If you want to post it on github privately you have to pay for it. |