I am trying to use for loops, to generate a large(ish) table with 65 odd values.
I will also need to make stat.dex, stat.con, and so on, but that should be easy enough if i can get this to work at all.
Plan B is to just brute force the list manually.
ie
stat.str_1 = 0
stat.str_2 = 0
and so on for all 65 odd variables.
Why i am doing this is simple, i would like to make some statistics related to how often stats reroll.
(The reroller script i have works quite well so no, I'm not asking for a reroller :P just trying to learn lua and make a interesting feature in the process)
These are the 2 triggers i have to count how often stats appear, as well as how many rerolls there have been total.
Using "tprint (stat)" it appears to be working.
But eventually i will need to put it into a chart format, and crunch the numbers a bit, and nil values could be problematic. I would prefer to start everything out at 0 instead of doing (stat or 0) everywhere in my triggers.
<aliases>
<alias
match="Generate_Table"
enabled="y"
send_to="12"
sequence="100"
>
<send>for i=9,18 do
("stat.str_" .. i)=0
end</send>
</alias>
</aliases>
I will also need to make stat.dex, stat.con, and so on, but that should be easy enough if i can get this to work at all.
Plan B is to just brute force the list manually.
ie
stat.str_1 = 0
stat.str_2 = 0
and so on for all 65 odd variables.
Why i am doing this is simple, i would like to make some statistics related to how often stats reroll.
(The reroller script i have works quite well so no, I'm not asking for a reroller :P just trying to learn lua and make a interesting feature in the process)
reroll output
Your character's base stats have been rerolled...
New Previous
Strength 15 14
Dexterity 14 15
Intelligence 18 13
Wisdom 11 12
Charisma 11 9
Constitution 13 16
Luck 13 16
<triggers>
<trigger
keep_evaluating="y"
match="^(Strength|Dexterity|Intelligence|Wisdom|Charisma|Constitution|Luck)[ ]+([\d]+)[ ]+([\d]+)"
name="Stats"
regexp="y"
send_to="12"
sequence="100"
>
<send>stat = (stat or {})
if "%1" == "Strength" then
stat.str_%2 = (stat.str_%2 or 0) + 1
elseif "%1" == "Dexterity" then
stat.dex_%2 = (stat.dex_%2 or 0) + 1
elseif "%1" == "Intelligence" then
stat.int_%2 = (stat.int_%2 or 0) + 1
elseif "%1" == "Wisdom" then
stat.wis_%2 = (stat.wis_%2 or 0) + 1
elseif "%1" == "Charisma" then
stat.cha_%2 = (stat.cha_%2 or 0) + 1
elseif "%1" == "Constitution" then
stat.con_%2 = (stat.con_%2 or 0) + 1
elseif "%1" == "Luck" then
stat.lck_%2 = (stat.lck_%2 or 0) + 1
EnableTrigger("Stats", false)
end</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
match="Your character\'s base stats have been rerolled\.\.\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>rolls = (rolls or 0) + 1
Note ("I have rerolled ", rolls, " times.")
EnableTrigger("Stats", true)</send>
</trigger>
</triggers>
These are the 2 triggers i have to count how often stats appear, as well as how many rerolls there have been total.
Using "tprint (stat)" it appears to be working.
But eventually i will need to put it into a chart format, and crunch the numbers a bit, and nil values could be problematic. I would prefer to start everything out at 0 instead of doing (stat or 0) everywhere in my triggers.