StDoodle
Minion
Forgive the title, but I can't seem to think of a better description; though it may be fairly accurate.
Currently, my Daily Deeds script has separate functions for grabbing the default, max, and sometimes current use numbers on different settings. Ie def_REAGENT() checks to see if you have Advanced Saucecrafting, and returns 1 if you do, 0 otherwise (this number controls whether or not the script should report on reagent summoning). Then I have max_REAGENT() set to look for Way of the Sauce & the combination of being a Sauceror & having the nemesis item as well, and then report the maximum number of reagents one can summon based on those.
What I'd like is to have one place to put all of this information for each setting. I was hoping for a way to put this all in a record, and then users would normally only need to update the text file containing said data. However, I can't figure a way to define functions in a record. I'm not sure it's possible; it looks as if the best I can do is to use "call," but then the script would still need a separate function built-in.
Barring the above, it looks like my best bet is to have a "master function" for each setting, which takes a single string parameter. That string could then be used in a switch statement to control which number to report. However, seeing as I'd like to return different datatypes, this doesn't seem all that ideal; I'd have to have several functions to handle the overloading, and I'd end up with nearly as much "clutter" as my present implementation.
For reference, my goal is to refactor the script in such a way as to have all of the display logic be setting-agnostic. Not a huge deal now, but it will make a difference when I add in support for several new features via the relay browser. What I'd like is to be able to go to one chunk of code for each setting, not having to hunt all over and update in each place. It's looking like the best way to do that will simply be to organize all of the relevant functions by setting, but still ending up with multiple functions for each. This is workable, but I'd like to know if anyone has any thoughts on a better approach before I do a lot of re-writing of my code.
Thanks everyone for your help!
Currently, my Daily Deeds script has separate functions for grabbing the default, max, and sometimes current use numbers on different settings. Ie def_REAGENT() checks to see if you have Advanced Saucecrafting, and returns 1 if you do, 0 otherwise (this number controls whether or not the script should report on reagent summoning). Then I have max_REAGENT() set to look for Way of the Sauce & the combination of being a Sauceror & having the nemesis item as well, and then report the maximum number of reagents one can summon based on those.
What I'd like is to have one place to put all of this information for each setting. I was hoping for a way to put this all in a record, and then users would normally only need to update the text file containing said data. However, I can't figure a way to define functions in a record. I'm not sure it's possible; it looks as if the best I can do is to use "call," but then the script would still need a separate function built-in.
Barring the above, it looks like my best bet is to have a "master function" for each setting, which takes a single string parameter. That string could then be used in a switch statement to control which number to report. However, seeing as I'd like to return different datatypes, this doesn't seem all that ideal; I'd have to have several functions to handle the overloading, and I'd end up with nearly as much "clutter" as my present implementation.
For reference, my goal is to refactor the script in such a way as to have all of the display logic be setting-agnostic. Not a huge deal now, but it will make a difference when I add in support for several new features via the relay browser. What I'd like is to be able to go to one chunk of code for each setting, not having to hunt all over and update in each place. It's looking like the best way to do that will simply be to organize all of the relevant functions by setting, but still ending up with multiple functions for each. This is workable, but I'd like to know if anyone has any thoughts on a better approach before I do a lot of re-writing of my code.
Thanks everyone for your help!