View Full Version : Can someone giv me some really quick Lua advice?
quixote
November 8th, 2007, 10:11 AM
I'm whipping up a little script to keep track of scrabble scores and I'd like to know how to compare three variables, set the largest number of them as a variable in a table and then find the second least of the three and subtract it from the greatest to find the number of points that the person that is winning is leading by.
Thanks!
Rob H
November 9th, 2007, 11:52 AM
You could keep the variables in a table and sort it using table.sort() - it probably does an ascending sort by default. e.g. assuming that the scores are in variables score1, score2 and score3
local mytable = {score1, score2, score3}
table.sort(mytable)
highest = table[3]
margin = highest - table[2]
quixote
November 10th, 2007, 02:03 PM
Thanks! I'll try that out next time I have the chance to play some scrabble.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.