Sub-directories and scripts

tebee

Member
Ive been trying to tidy up my scripts directory and moved groups of scripts into subdirectories. This has had the unfortunate side-effect of breaking quite a few of them.
The culprits seem mostly ones that use include, execute another script or use file to map.

What seems to be the way Mafia works is that everything is by default assumed to be relative to the scripts directory not the directory the script is executed from. So if you put include(subdir/myscript.ash) it will look for "mafiaroot/scripts/subdir/myscript.ash" no matter where you run the calling script from. There is a way around this though, if you use the unix notation for the current directory of "." you can write include(./subdir/myscript.ash) and it will look for "/subdir" reitive to you current directory. this also works for " cli_execute call " cli_execute("call ./sell.ash"); will execute "sell.ash in the current directory , cli_execute("call ./myscripts/buy.ash");
will run "buy.ash " in the myscripts subdirectory of the current one i.e.. the one you ran the calling script from.

Unix notation - including the forward slash seems to work under windows surprisingly enough!

What doesn't follow this convention is file_to_map. It seems for this you have to explicitly code the full path from the scripts directory e.g. file_to_map( ".\\mcguff\\custom_outfits.txt", custom_outfits)

It also seems you need to code the correct form of slash or backslash depending on whether you are running on Unix or Windows and remember to double up on the backslashes as they needs to be escaped. This of course means you can not run the same Ash code on unix/macs and windows.

Tom
 

Camber

Member
Following the unix-type directory syntax, i use the ../ notation to look in a different subdirectory. The "ScriptDataFiles" folder is at the same level as the scripts folder. They are both in the mafiaRoot directory. Like this:

file_to_map("../ScriptDataFiles/Map.txt", List);
 
Top