I was playing around making a stock system but need to calculate when it will next reset but nothing I try works
script \ /

I was playing around making a stock system but need to calculate when it will next reset but nothing I try works
script \ /

You’re searching ShopResetTimes for a string when the array is comprised of numbers. Use tonumber on hour to solve that problem
yeah but I still am needing to calculate either what time is the next reset or how long until the next reset
easy:
if hour < 3 then
nextreset = 3
elseif hour > 3 and hour < 6 then
nextreset = 6
elseif hour > 6 and hour < 9 then
nextreset = 9
elseif hour > 9 and hour < 12 then
nextreset = 12
elseif hour > 12 and hour < 15 then
nextreset = 15
elseif hour > 15 and hour < 18 then
nextreset = 18
elseif hour > 18 and hour < 21 then
nextreset = 21
elseif hour > 21 and hour < 24 then
nextreset = 24
end
thanks, i always make it more complicated than necessary
bruh no nooo! that was a joke, if the time increment is 3, the remaining time should be 3 - (hour % 3)
local function getNextHour(hours: {number}, hour: number): number
for _, value in hours do
if value > hour then
return value
end
end
return hours[1] -- Circle back to the start of the array.
end
No complex calculation is required. As long as your array of numbers is in ascending order, you can find the next number by locating the first number to be greater than the current number
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.