Jump to content

Optimize this script (scrollbar size)


Feche1320

Recommended Posts

Hello, I made this little (messy) script

  
-- Size for the scrollbar.. (very messy and inefficient I think) 
local mapsleft, groups, pos, run = #_mapcache, 0, 0, 0, true 
while run do 
    pos = pos + 1 
    if pos == 15 then 
        groups = groups + 1 
        mapsleft = mapsleft - 15 
        pos = 0 
    end 
    if mapsleft <= 15 then 
        groups = groups + 1 
        run = false 
    end 
end 
  

What this does it gives me the scrollbar height grouping maps by 15, I know there must be a better way.. thanks :mrgreen:

Link to comment
  • Moderators
outputChatBox(math.ceil(2.45645)) -- 3 
outputChatBox(math.floor(2.45645)) -- 2 
  
local groups = mapsleft/15  
  
--[[ example value 97 
  
97 / 15 = 6.4666666666667 
  
math.ceil(6.4666666666667) -- 7 
math.floor(6.4666666666667) -- 6 
]] 
  
local maxGroups = math.ceil(groups) -- groups rounded up. 
local minGroups = math.floor(groups) -- groups rounded down. 

 

  
local remainValue = mapsleft % 15  
  
--[[ example value 37 
37 % 15 = 7  
  
What does this do? 
37 - 15 = 22 
22 - 15 = 7 
7 remains.  
  
]] 

Does this help out?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...