I've hunted around to see if I could find this anywhere else, but without any luck. Hopefully y'all can help me out -- I can't figure out how to reference a table external to a function from within that function. Here's what I mean:
I have a Defenses table set up, with sub-tables of defense names, and each of these subtables contains information like the text to set it and the balance that's required. For example:
Then I have another table, changed dynamically according to which defenses I want to set. So, for example, if I wanted to set my two test defenses, it would look like this:
And finally, I have a function that is designed to check to see if each defense is already set, and to set it if I have the appropriate balance. If not, then I make a one-shot trigger (incidentally, would it be better to have a static trigger that is enabled/disabled appropriately? I wasn't sure) to set the defense when I regain the balance. The problem is... I don't know how to reference the information contained in my external Defenses table. Here's how it looks:
I've tried every combination I can think of in place of the "Defenses.defname.balreq" code, but I can only get it to reference the deflist table, not the Defenses table. How do I reference that external table from within the function??
I have a Defenses table set up, with sub-tables of defense names, and each of these subtables contains information like the text to set it and the balance that's required. For example:
Defenses = {
secondsight = {
settext = {"psi super secondsight",},
balreq = {"sup_av",},
},
nightsight = {
settext = {"nightsight",},
balreq = {"base_av",},
},
}
Then I have another table, changed dynamically according to which defenses I want to set. So, for example, if I wanted to set my two test defenses, it would look like this:
deflist = {"nightsight","secondsight"}And finally, I have a function that is designed to check to see if each defense is already set, and to set it if I have the appropriate balance. If not, then I make a one-shot trigger (incidentally, would it be better to have a static trigger that is enabled/disabled appropriately? I wasn't sure) to set the defense when I regain the balance. The problem is... I don't know how to reference the information contained in my external Defenses table. Here's how it looks:
function defset (name,output,wildcards)
for index,defname in pairs (deflist) do
if GetVariable("def_" .. defname) == 1 then
Note ("Defense Set: " .. defname)
else if GetVariable(Defenses.defname.balreq) ~= nil then
Send (Defenses.defname.settext)
else
Note (defname)
-- Need Trigger Function!
return
end
end
end
endI've tried every combination I can think of in place of the "Defenses.defname.balreq" code, but I can only get it to reference the deflist table, not the Defenses table. How do I reference that external table from within the function??