modular vs. singular

Fluxxdog

Active member
The way I design script for my own use is to have major portion broken up and then draw them in to one main script. For example, my between battle script imports 13 different scripts:
PHP:
import <assembled.ash>;//import global variables and functions
import <shoreinc.ash>;//Check for dinghy and 6th floor tower items
import <affliction.ash>;//check for certain ailments and buffs
import <conjuregoodies.ash>;//summon items
import <superdrinks.ash>;//create Superhuman drinks
import <roguecount.ash>;//special handling for the Rogue Program
import <mimicbag.ash>;//special handling for the Stocking Mimic
import <boulderray.ash>;//special handling for the He-boulder
import <stinkycheese.ash>;//special handling for the Stinky Cheese Ball
import <minihip.ash>;//special handling for the Mini-hipster
import <crownthrone.ash>;//wear the crown
import <semirare.ash>;//special checks for semirares
import <dessert.ash>;//end of day
Now, for most of those, except the first one, they're only used in the bBS. What I'm wondering is are there any major differences between a puzzle piece mentality like this as opposed to putting everything in just one script? Any advantages one has over the other in terms of performance?
 

fronobulax

Developer
Staff member
From a file and version management perspective I prefer the smallest number of files possible, provided that the portions that can (and do) get reused by other scripts (or writers) contain just what is needed but no more. I am hard pressed to construct a scenario where there would be a notable difference in performance. I think mafia reads the files once, parses them and then it doesn't matter how many files were used (unless multiple files triggers garbage collection in a performance effecting way) so if performance were an issue it would depend upon disk drive speed and fragmentation. Interesting question but I think the performance difference has to be negligible.
 

Theraze

Active member
Modular is beneficial if you're using stuff other people make and plugging it in. If everything is your own custom stuff and you don't plan on sharing parts of it (but not all), singular is probably easier...
 

Grotfang

Developer
Performance isn't an issue. Readability is.

The way imported functions are included in ASH means that it can be unclear as to which file they originated from. This makes it more of an effort to see easily what a script is doing, which means I am less likely to try that script out. For personal use however, I doubt that would be a concern. Import away!
 

tgetgel

Member
I think mafia reads the files once, parses them ...

This is true until you refresh the scripts or relaunch Mafia. If you launch Mafia, it runs with the scripts as existed when launched. I have modified scripts during a run, but the old ones executed until I reloaded the menu or restarted Mafia.
 

StDoodle

Minion
This is true until you refresh the scripts or relaunch Mafia. If you launch Mafia, it runs with the scripts as existed when launched. I have modified scripts during a run, but the old ones executed until I reloaded the menu or restarted Mafia.

Huh, I'm pretty sure I get different behavior (very sure in fact, as I've done a lot of script debugging without refreshing). OS dependent maybe?
 

Theraze

Active member
In Windows, scripts are loaded each run. At least, that's been my experience with rewriting them.
 

Veracity

Developer
Staff member
It looks up the "last modified" time in the file system and saves it when you execute a script. If you then execute the script again, it looks again at the file system. If the "last modified" time is the same as before, it doesn't bother to re-parse the script.

That works like a charm on the Mac. You seem to be saying that Windows does not modify the "last modified" time when you modify the file. That sure sounds like a bug. In Windows, or, at least, in Java on Windows...
 

Theraze

Active member
Don't think that tgetgel ever said which OS is being used. Could be anything from *nix on down...
 

zarqon

Well-known member
I have always been able to save files in my editor, at which point mafia always runs the freshly saved script. This in XP (both English and Korean), Eeebuntu, and Ubuntu Studio.

Any other OS's we've left out? :)

On the OP's topic, I'm almost sure that I will be rolling FTF, SS, and BatMan all together for the final release of BatMan. Combat components (such as special items, stasis, cleanup, and whether or not to auto-macrofy) will be toggle-able with settings. I guess that means that I prefer consolidation to modularity. At first I liked the separation of functions, but for shared scripts, consolidation is worth it to avoid updating hassle.
 
Last edited:

fronobulax

Developer
Staff member
I should have said mafia reads the file once per script invocation.

My recollection is that in a cycle of invoke, edit, mafia on Windows will reload the script provided that I have actually saved the changes from the editor ;-)
 

Theraze

Active member
Ah, sorry. I was saying that each execution of a changed script properly ran for me, not that I had problems. I was posting that as a counterpoint to tgetgel who has been the only one who claimed issues with this.
 

Fluxxdog

Active member
OK, from the OT responses I've seen, consideration is more sharing purpose than performance.

The list of scripts I provided I think could be useful to many a person, but I haven't shared any since they were mostly for practice and utility. For example, crownthrone.ash shuffles familiars around to meet various requirements, such as material for prismatic wads, speeding up stats to 200 for high power gear, etc.It's partly personal, since other characters i'm baby-sitting don't have a Crown. The ones for the Rogue Program and Sticking Mimic, however, have seen use between my main and the babysat ones.

My bBS is never gonna be shared, that's for sure, but the whole collection of other scripts I have that are imported in to it, people might find them useful. I may get around to sharing one day.
 
Top