Page 1 of 6 1 2 3 ... LastLast
Results 1 to 10 of 53

Thread: Make your scripts automatically update their data files!

  1. #1
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,530

    Default Make your scripts automatically update their data files!

    When I recently discovered that file_to_map() works with URLs, I had this idea:

    "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 Mafia Map Manager!

    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 by zarqon; 01-23-2010 at 04:48 AM.

  2. #2
    Senior Member
    Join Date
    Sep 2008
    Posts
    795

    Default Re: Make your scripts automatically update their data files!

    WOW! This is incredibly awesome.
    My scripts: Ascend for automatic ascensions, Farm to make more money than castlefarming, EatDrink for the maximum number of turns each day, LevelUp to gain a level safely, and PullCrap to manage your pulls in ronin.

  3. #3
    Senior Member
    Join Date
    Nov 2007
    Posts
    225

    Default Re: Make your scripts automatically update their data files!

    Nice. This looks interesting.

  4. #4
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    I just wanted to say that I'm giving this resource a thumbs-up.

    It was awfully convenient to simply be able to update the map for my recovery script by just uploading the new version to the server as soon as mafia supported sugar shards. That isn't the big thing though. The really big thing is that the proper recovery range for sugar shards hadn't yet been fully spaded and that was not a reason to hold off on updating. I simply added the currently known data, even though it was doubtless incorrect. Then when the recovery range was correct, I just updated it again.

    Without this service I would have refrained from adding the sugar shard until the data was fully spaded because it would have been troublesome to have two updates. Using this service changed the way I updated the map to be more responsive to my users so they could use the new recovery item immediately.

    Thanks Zarqon.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  5. #5
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,530

    Default

    Cheers Bale! Warm fuzzies all around! Glad you found it useful.

    If only there were a way to write functions that take maps of any structure, this would definitely be in ZLib.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossnam | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  6. #6
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    If only there were a way to write functions that take maps of any structure, this would definitely be in ZLib.
    Originally Posted by zarqon View Post
    That's... ah. Yeah, there's no way to write the function without knowing how to define the map... If only you could pass the map's name as a string and then run map_to_file() on the map's name...

    To do that, we'd either need a version of map_to_file() and file_to_map() that accepted a string as the name of the map or else be able to call a variable name like, map_to_file(call mapname, "fname.txt")

    PS. for information on the obscure call command, see here. Obviously it doesn't work at all as we'd need it for this purpose.
    Last edited by Bale; 09-08-2009 at 08:47 PM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  7. #7

    Default

    This looks so cool!!! Can it do ash files as well? I really need to learn how to use txt files now lol.

  8. #8
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,530

    Default

    No, this is only for map files used by ASH scripts.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossnam | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  9. #9
    Senior Member
    Join Date
    Feb 2009
    Posts
    182

    Default

    I just uploaded a file (use_for_items.txt, designed to be a float [item] [item] map) of which a few lines have some quite small float values:

    In the updated-from-Map-Manager file, they look like this:
    tiny slimy cyst big bumboozer marble 4.8828125E-4
    tiny slimy cyst black catseye marble 9.765625E-4

    In the original file, they looked like this:
    tiny slimy cyst big bumboozer marble 0.00048828125
    tiny slimy cyst black catseye marble .0009765625

    The values are preserved, just translated into E notation.

    However, in using load_current_map() to load these, Mafia errors and prints a debug log (attached). The relevant portion seems to be:

    class java.lang.NumberFormatException: For input string: "4.8828125-4"
    java.lang.NumberFormatException: For input string: "4.8828125-4"
    at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1224)
    at java.lang.Float.parseFloat(Float.java:394)

    Something in file_to_map() doesn't like to see that notation.

    Is this a Mafia bug (file_to_map not accepting floats in scientific notation)? Or can I ask you to force the Map Manager not to change the representation of floats in files that it manages?
    Attached Files

  10. #10
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,530

    Default

    This is mafia's fault. (Also recently came up in the SmartStasis thread.) I'd say it's worthy of a bug report, since for very small floats this actually prevents you from using floats.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossnam | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

Similar Threads

  1. Replies: 0
    Last Post: 04-02-2015, 12:40 PM
  2. data files
    By bordemstirs in forum Scripting Discussion
    Replies: 6
    Last Post: 10-16-2011, 07:16 AM
  3. Bug - Fixed Data files not removed with "update clear"
    By lostcalpolydude in forum Bug Reports
    Replies: 1
    Last Post: 05-13-2011, 04:40 PM
  4. data files
    By martialis in forum Scripting Discussion
    Replies: 12
    Last Post: 05-09-2009, 07:00 AM
  5. Problem with .bat files calling scripts
    By Sako in forum Scripting Discussion
    Replies: 2
    Last Post: 08-01-2007, 07:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •