Cookbook Recipe Viewer v1.3.1

Discussion in 'Bukkit Tools' started by Celtic Minstrel, Apr 11, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Celtic Minstrel

    This is a Python script which translates Cookbook recipe files into an HTML view of the recipes they define. Full details in the README.txt included with the package.

    To use this, you need Python 2.x installed; it was tested on 2.7 but will likely work on 2.6 as well. Python 3.x will not work. If you're not on Windows, you probably have it already. If you are, you can download it here. Make sure to download version 2.7 and not 3.1 or anything like that!

    In order to parse CustomCrafting recipes, you will also need to install PyYAML, which you can get from here.

    Download here.


    A sample output file can be viewed here.



    Version 1.3 of this utility has been confirmed to work on Python 2.6. I can't guarantee that this will remain true for further versions, since I'm working with Python 2.7, but it's likely that it will unless I completely overhaul the design.

    Note: There is a bug in the included JavaScript file that will prevent animations from working. The sample copy on the website has been fixed, so if you want animations to work you will need to download that.
     
    mushroomhostage and Sleaker like this.
  2. Offline

    Eggplant!

    Hey! Thanks for this!

    Here's a quick change so that 'X' will work for repair type recipes. This won't work for things other than armor, tools, and weapons.

    In v 1.1 around line 464:
    Code:
    in_pat = re.compile(r"\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*;\s*([X\d]+)\s*,\s*([X\d]+)\s*,\s*([X\d]+)\s*,\s*")
     
  3. Offline

    Celtic Minstrel

    Thanks for helping, but I've actually already implemented that in my copy. :) (I used \d+|X instead of [X\d]+ though.) I just need to update the readme and such and compile the zip file and upload it. It may not happen today, but it should happen soon.
     
  4. Offline

    Celtic Minstrel

    Version 1.2 uploaded; you can find it at the same place. It includes support for the X option in the Cookbook config as well as images and support for the new items in 1.4/1.5. Furnace inputs and slots with X as the data will be animated with Javascript to enumerate the possible values; this includes an animated health bar for tools. Speaking of which, health bars will be displayed on tools if a damage other than 0 is specified.

    Hopefully Cookbook itself will soon be updated for 1.5 as well.
     
  5. Offline

    DerEchteNexus

    Nice one ;)
    Celtic, do you know if its possible to execute a python scropt in Java?
     
  6. Offline

    Celtic Minstrel

    If you mean what I think you mean (running this script from your recipe editor), what you would need to do is fork, exec, and pipe. The Runtime.exec methods will handle fork and exec, and piping is handled by writing to and reading from the streams on the Process object that it returns.
     
  7. Offline

    BulletSix

    and again here: THanks for doing this, its much apprechiated :)
     
  8. Offline

    Sphax

    @Celtic Minstrel : Would it be possible to change CSS and img folder (and your script) to use "terrain.png" and "items.png" as ressource pictures ? Thanks to that we would be able to easily generate a file with our own textures pack. :p
     
  9. Offline

    Celtic Minstrel

    It would be possible, but I'm not going to do it because the images in those files have no real organization by number, and the ones in terrain.png aren't even the item graphics actually used by the game. Anyway, you can already generate files with your texture pack simply by replacing the images in the img folder.
     
  10. Offline

    KuroSnow

    This is very awesome. However, can I point out that it doesn't call the tree sapling images properly? All three sapling types point to 6.png, while the normal sapling is 6.0.png, the spruce is 6.1.png, and the birch is 6.2.png. Other than that, amazing! Thank you very much for this plugin. =)
     
  11. Offline

    Celtic Minstrel

    Huh, really? Odd. I'll fix that asap and probably silently upload the fix (but you'll see the version bump up when I do that).
     
  12. Offline

    Celtic Minstrel

    Alright, I've been very slow at this, but version 1.3 is finally uploaded and available, with support for the new items in 1.6 and 1.7 as well as CustomCrafting recipe files. Note though that for CustomCrafting you will need to install an extra Python module; see the README or the opening post for details.
     
  13. Offline

    Sleaker

    @Celtic Minstrel -
    Getting this error with CustomCrafting recipes:
    Code:
    Traceback (most recent call last):
      File "cookbook-viewer.py", line 923, in <module>
        inserts.append("<h3>" + recipe_name + "</h3>")
    TypeError: cannot concatenate 'str' and 'int' objects
    Recipes were generated with the GUI recipe creator and work fully in game

    Also the recipes generated with the gui apparently use a different Comment name format. (I was able to export them to CookBook recipes instead of the yml to generate the html. but it complains about them)

    Update: My recipes have Numerals in them.
     
  14. Offline

    Celtic Minstrel

    That wouldn't be hard to fix, but in the meantime you can eliminate the issue by adding "DisplayName: false" to the recipes causing the problem (or if you don't want to hide the name, "DisplayName: 'numeric name here'").
     
  15. Offline

    Sleaker

  16. Offline

    Celtic Minstrel

    You shouldn't really be using unpowered torches, so I don't really see much of a reason to fix that... still, I'm curious what the errors are and why only that item would produce them.

    By the way, I think your recipes for chain mail make it pointless to make (unless you like the look), since chainmail gives less protection than iron armour.
     
  17. Offline

    Sleaker

    ooh it got changed? it used to be as good as gold but more durable - hmm. thanks for the tip. Also it was that the GUI was incorrectly adding unpowered torches to the recipe, I think he's fixing it on his side.

    The id 75 error I think was because it's not parsed by the script? nor do you have an unpowered torch graphic.
     
  18. Offline

    Celtic Minstrel

    Um, gold is less durable than iron and gives less protection...

    Might be because my map of item names omits it.
     
  19. Offline

    cyberdude

    @Celtic Minstrel
    I found a bug, if the result is 30 of an item, it will say 31 in the html generated. 29 works, and 31 is okay. But exactly 30 renders as 31.
    I don't know if there are more.

    Edit:
    The left style for the second character is calculated to be "--16". Notice the --. It should be -144.

    Edit2:
    More bug, the -s and -S and -sS args does't work either.

    I've looked in the pythom code (I don't know the correct notations of python, and can't be bother testing right now) and I found the two bugs. Bug 1 should occur for any numbers divable by 10, because of a flaw in the code.

    Bug 1: Numbers (Line 641 + 643 calls get_digit line 648)
    get_digit is:
    Code:
    def get_digit(n):
    	return 16 * (n - 1)
    
    The number returned here is appended with a minus (turning it into negative) and used as left position for the style of number image.
    The first digit is parsed to this function by doing integer division.
    The second digit is parsed by moding the number. Thus 30 will be 0.
    The numbers in the number image folllow this pattern "1 2 3 4 5 6 7 8 9 0" with 16px difference between them.
    This is a table of the number/positions
    1: 0
    2: 16
    3: 32
    4: 48
    5: 64
    6: 80
    7: 96
    8: 112
    9: 128
    0: 144

    This is flawed.
    when 0 is parsed the get_digit will return
    16 * (0 - 1) = -16
    It shoulnd't. It should return 144.
    The fix would either be to move around the order in the image (0 - 9, instead of 1-9-0) or
    something like:
    Code:
    if n == 0:
    return 144
    else:
    return 16 * (n - 1)
    
    Bug 2: Hide shaped/shapeless (line 645 + 646)
    Code:
    if shaped: format_dict['shaped'] = messages['shaped_insert'] if show_shaped else ""
    else: format_dict['shaped'] = messages['shapeless_insert'] if show_shapeless else ""
    
    It seems that the message[xxxx] is inserted no matter what show_shaped and show_shapeless is.
    Basically it test if shaped is true, if it is it inserts the shaped_insert, afterwards it tests if show_shaped is true, but doesn't do anything if it is, and doesn't really do anything if it's not.
    I don't know the correct notation of ANDING, but I supposed it's & or &&.
    Code:
    if shaped && show_shaped: format_dict['shaped'] = messages['shaped_insert']
    else if show_shapeless: format_dict['shaped'] = messages['shapeless_insert']
    
    Shouldn't this fix the bug? If the notation is correct.


    I hope this helps a bit, and that you would take the time to fix these two issues.

    Edit3:
    So I decided to go ahead and fix it myself. And so I did. The thing I wrote before about Bug 2 didn't hold up. I found that bug occured since the variables show_shapeless and show_shaped was not in scope of parse_args. So I added them to the global declarations in line 450 and it worked as it should. I also fixed the Bug 1.
    I have attached the fixed .py file in zip (the zip only contains the fixed the python file, nothing else)
     

    Attached Files:

  20. Offline

    Celtic Minstrel

    Uploaded version 1.3.1 which fixes the recipe name issue @Sleaker reported as well as the bugs that @cyberdude fixed.
     
  21. Offline

    Sleaker

  22. Offline

    Adrenaline

  23. Offline

    sam501

    This is gonna be useful


    UMG YOU TROLL MAC ONLY?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  24. Offline

    Celtic Minstrel

    ...uh, no? Did you even read the opening post? Though the utility is a bit out-of-date now...
     
Thread Status:
Not open for further replies.

Share This Page