--<tell lua you're creating a function> <the function name> <the parameters, separated by columns)function AddNums (number1, number2)--<perform function logic inside the function body>sum = number1+number2--<return a value for the function>return sum--<specify the end of your function>end
function AddNums(number1, number2) sum = number1+number2 return sum end--use this function in another function or another part of the coderesult = AddNums(987654321,123456789)print(result)
function prettyprint(bal, profit, bets, wins) if bets%1000==0 then --every 1000 bets print('Your Balance:'.bal) print('You\'ve made '.profit.' Profit so far') print('You\'ve made a total of '.bets.' bets') print('Of which you have won '.wins) print('And have lost '.(bets-wins)) endend
In computing, the modulo operation finds the remainder after division of one number by another. Given two positive numbers, a and n, a modulo n is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor.
5/2 = 2 with 1 remainder ((2*2)+[u]1[/u]=5)Thus 5%2 = 115/6 = 2 with 3 remainder (6*2)+[u]3[/u]=15)15%6 = 3100/20 = 5 with 0 remainder.100%20 = 0
if currentstreak%3==0 and win then--this will execute after EVERY 3 winning bets in a row, so after 3 in a row, 6 in a row, 9 in a row etcendif currentstreak==3 then--this will execute after exactly 3 wins in a rowendif wins%3==0 and win then --after every 3 wins, regardless of whether they are in a streak or notendif wins == 3 then--after you've won exactly 3 bets and then never againend