generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Easiest way to find the largest value of intvalues..

Previous Thread :: Next Thread 
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 03:26 AM
Say i have 16 number values.

how can i find the largest value of those 16 numbervalues?

Report Abuse
Zachiah is not online. Zachiah
Joined: 27 Oct 2013
Total Posts: 1401
09 Nov 2013 03:32 AM
math.max

print(math.max(5,7,35,1,19,22,56,13,99,10,145,25,90,44,78,7))
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 03:32 AM
print(math.max(1,40,2,42,124))
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 03:33 AM
Ninja'd

I found out about math.max after writing a function that did the same thing as it
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 03:49 AM
How do i find out which value it is?

say

Value_One = 1
Value_Two = 3
Value_Three = 4
Value_Four = 5

etc.

local maxvalue = game.Workspace.Value_Four

in this case, how do i find the highest value?
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 03:56 AM
print(math.max(value_1, value_2, value_3))
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 05:01 AM
wait, so will that print the number, or the value name?
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 05:07 AM
The number
I'll make you a function that returns the value name if you want
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 05:25 AM
Yus please :D
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 05:36 AM
Unless I misunderstood the question


function Most(...)
MostTab = {...}
Current = MostTab[1].Value
for Index, Number in pairs(MostTab) do
if Number.Value > Current then
Current = Number.Value
Answer = Number
end
end
return Answer
end
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 05:08 PM
What do i replace ... at function Most() ?
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 05:30 PM
You don't replace it
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 05:37 PM
what about '...' at MostTab
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
09 Nov 2013 05:40 PM
... means it receives tuple arguments of infinite value.


Example


function lol(...)
print(...)
end

lol(1,2,3,4,5)
lol(1,2,math.huge,'lol')
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 05:40 PM
You don't need to change anything about the function
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 05:49 PM
but then how do i put in my 16 values i want to check for the highest number?
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
09 Nov 2013 05:50 PM
Most(Value_1, Value_2, Value_3 so on... Value_16)
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
09 Nov 2013 06:26 PM
ohhhhhhhhh,
finally understand now!
Ill try this and let you know if there are any errors
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
14 Nov 2013 02:39 AM
Ok, so now how do i access 'Answer', outside of the function?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
14 Nov 2013 02:56 AM
answer = Most(Value_1,Value_2,Value_3)
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
15 Nov 2013 03:41 AM
answer = Most(LapsDoneL1, LapsDoneL2, LapsDoneL3, LapsDoneL4, LapsDoneL5)
wait(3)
Message.Parent = game.Workspace
Message.Text = "The winner of this round is... "
wait(3)
Message.Text = answer.Name .. "! If you are in " .. answer.Name .. ", then you get 5000 points!"
print 'doesnt yet give points'
wait(4)
Message.Parent = nil

All variables are defined.
Not working?
THe part where it says answer.Name
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
15 Nov 2013 06:54 PM
bump
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
16 Nov 2013 11:02 PM
bump

please help!
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
16 Nov 2013 11:04 PM
Just do this
Values={}

print(math.max(unpack(Values)))
Report Abuse
diddims4 is not online. diddims4
Joined: 18 Feb 2010
Total Posts: 884
16 Nov 2013 11:06 PM
Mind telling me what unpack does?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image