Feature Add option to define path to script folder

jwylot

Member
I have a number of multis which do various jobs such as a clan buffbot, clan leader as well as the characters who adventure. I keep them in separate folders to avoid issues with global prefs but whenever a script is updated, I have to update each copy in their respective script folders.

I was wondering if it would be possible to add an option to specify a path to the script folder in mafia's options. This would make an already awesome programme even more awesome.

Thank you.
 

Bale

Minion
Which global preferences are the problem? Perhaps that is the issue to address so that you don't need to have multiple installations.
 

jwylot

Member
Oh, breakfast options, login/logout scripts mainly. And yes, I know I can use a script and avoid the built-in mafia options but this seems a bit clunky when dealing with five characters. I'm not sure if such a feature is feasible, how difficult it would be to implement or if it would help other users.

Just thought I'd ask before rolling up my sleeves and writing that monster login script :)
 

Bale

Minion
Combining your login scripts isn't tricky. For minimal effort just use a switch(my_name()) {} and copy/paste each individual login script into their own section.

Obviously the breakfast options are a little trickier since you'd need to write new code to take over their functionality in the login script. If you have any trouble, please ask for help here and I for one will be glad to assist you.
 

Ethelred

Member
You don't say which OS you're using, but on Mac OS X, it would be very easy to replace the individual script folders with aliases to a master script folder. On linux, that would be links, but I'm not sure what (if any) the Windows counterpart would be. This might be an easy way to solve your problem without any mafia mods or complicated scripting.
 

Ethelred

Member
Wikipedia seems to say that mklink found in recent versions of Windows provides this capabilty. But then I don't know jack about Windows, so it's possible I'm completely misunderstanding it.
 

fronobulax

Developer
Staff member
Also for the record, if my memory is not totally shot, the fact that mafia will only access files in certain directories is a deliberate security decision. An overactive imagination can construct all sorts of malicious behavior if a user can specify where scripts can be found and then executed.

I also use some kind of test on the character name in both the login and log out scripts. I reset global preferences for one character - the fact that it is in a clan that does not allow it to access the stash conflicts with autoSatisfyWithStash being true, as I would like for other characters - but I have to be careful that both login and logout scripts get updated and if I ever manage to abort mafia in such a way that the scripts don't run then I have to manually clean up the mess so that things work as expected again.

I suspect that the core issue is that there are global preferences that might be per character preferences if they were newly implemented today, but changing them potentially breaks a lot of scripts.
 

Theraze

Active member
I think, but am not completely sure, what you want to do is from the Comment Prompt use mklink something like this, with the following assumptions:
that one copy of mafia (the main one) is in your program files,
you have a copy on your desktop that wants to use the same script files,
you have already removed the Scripts folder from your desktop version,
and your user account name is jwylot:
mklink /d "C:\Users\jwylot\Desktop\KoLmafia\Scripts" "C:\Program Files\KoLmafia\Scripts"
 

Grotfang

Developer
I suspect that the core issue is that there are global preferences that might be per character preferences if they were newly implemented today, but changing them potentially breaks a lot of scripts.

As far as scripts are concerned, what's the difference between a global and a per-character setting? Or is it the fact that changing a global setting to a per-character one would reset it to its default setting? If there are settings that should be applied on a per-character basis that are currently global, I think we should probably change the setting. In the long run, it will work out better that way.
 

fronobulax

Developer
Staff member
I admit I am parroting others a bit when I repeat the claim about breaking scripts but it is a claim that makes enough sense that I am willing to believe without investigation. That said, get_property and set_property are unaware of whether the property is global or "local" so if the name or "data types" of the property don't change then a script that is explicitly using properties should not notice. I know some properties have to be global because they are used before a character logs in. Making any one of them local would break something although it might not be a script. Internally mafia does does distinguish and so getting the code will require some thought. All that said, though, the only script that I can think of that would break if globals were collapsed into locals would be ones that a) relied on global properties to share information across characters or b) relied on global properties to run when no character was logged in. I stand corrected because it does seem as if I overstated the case.

Off the top of my head the properties I have had "problems" with as global are: the state of the breakfast checkbox on the login screen; the name of the login script; the name of the logout script; autoSatisfy* in general, autoSatifyWithStash in particular and settings dealing with Tomes and Librams.

Note that I have workarounds for all of these and the breakfast checkbox may actually be the symptom I recall for a different problem (since there are global preferences of the form getBreakfast.username).

I'd also love to see the underscore convention enforced for variables that reset daily but that would involve renaming and/or code that helped with the transition and is really not relavent in this discussion.
 
Top