Last active
August 29, 2015 14:15
-
-
Save Grumblesaur/95360b4660cc353e88c5 to your computer and use it in GitHub Desktop.
4d6 drop 1 script for d20 system character creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
math.randomseed(os.time()) | |
attributes = {} | |
for i = 0, 5, 1 do | |
--initialize array for current stat | |
stat = {}; | |
--roll 4d6 | |
for j = 0, 3, 1 do | |
stat[j] = math.random(1, 6) | |
end | |
--find lowest roll, drop it | |
lowIndex = 0; | |
for k = 1, 3, 1 do | |
if stat[k - 1] > stat[k] then | |
lowIndex = k; | |
end | |
end | |
stat[lowIndex] = 0; | |
--compound values | |
total = 0; | |
for l = 0, 3, 1 do | |
total = total + stat[l] | |
end | |
--append to list | |
attributes[i] = total | |
end | |
for m = 0, 5, 1 do | |
print(attributes[m]) | |
end | |
total = 0; | |
for n = 0, 5, 1 do | |
total = total + attributes[n] | |
end | |
print("Total: ", total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment