zarqon
Well-known member
When I recently discovered that file_to_map() works with URLs, I had this idea:
Several hours and two scripts later, I am pleased to introduce the [size=+1]Mafia Map Manager[/size]!
Basically, the idea is a single location for map files to live, where they can be updated by script authors as well as contributors, and a method for scripts to access those files. When running a script, it checks to see if your data file is the current version. If not, it downloads the current version, replacing your old version.
Benefits:
I hear what you're saying. You're saying "Enough already! I want to convert my script to do this!!" So here you go.
How To Make Your Script Automatically Update Its Data Files
This must be top-level (recommend putting it at the top of your script, since it also makes numerous other handy functions available).
Enjoy this awesome new functionality!
~Z~
"It would be wicked cool if scripts could automatically keep their data files updated by accessing some kind of central repository of map files!" (I think in italics.)
Several hours and two scripts later, I am pleased to introduce the [size=+1]Mafia Map Manager[/size]!
Basically, the idea is a single location for map files to live, where they can be updated by script authors as well as contributors, and a method for scripts to access those files. When running a script, it checks to see if your data file is the current version. If not, it downloads the current version, replacing your old version.
Benefits:
- The obvious one: the user has no need to update data files! This translates to a lot less clicking and happier users.
- Fewer first-time downloads for the user. The user can just download the script and run it, without needing to download data libraries along with it.
- Central location means improvements made by users are more likely to be shared.
- Changes uploaded by one person will instantly propagate to all users. This has the benefit of providing instant bugfixes to everyone as soon as one user uploads a fixed data file. This would have come in handy when the location name for the Haunted Cellar changed from (Random) to (Automatic), and the bounty.txt file (used by bounty.ash) was causing the script to have errors.
- As a result of the above, fewer errors encounted by users.
I hear what you're saying. You're saying "Enough already! I want to convert my script to do this!!" So here you go.
How To Make Your Script Automatically Update Its Data Files
- First, upload the data file (xxxx.txt) used by your script here.
- Next, import ZLib in your script as follows:
Code:
import <zlib.ash>
This must be top-level (recommend putting it at the top of your script, since it also makes numerous other handy functions available).
- Then, instead of calling file_to_map() in your script, call load_current_map(). The first parameter is the name of the file without the extension (e.g. "checklist" not "checklist.txt"). The function will return true if the map loaded successfully.
- Remove the data file from this site. Users will no longer need to come here to download data file updates.
Enjoy this awesome new functionality!
~Z~
Last edited: