Page 2 of 2 First 12
  1. #11

  2. #12
    That's probably because that example script is the one I'm using for my Princes of Apocalypse campaign. Please change the campaign init to use a campaign you have saved.

  3. #13
    So what if I'm in multiple campaigns and playing multiple characters? How would I have it look through every campaign in the ./campaigns folder and backup every character?


    run.py
    Code:
    from phantasy import datahelper
    import pprint
    import os
    
    def main():
        x = datahelper.DataHelper()
        princes = None
        print(__file__)
        for campaign in x.campaigns:
            if campaign.startswith('Princes'):
                princes = x.getCampaign(campaign)
                break
        outdir = os.path.join(os.path.dirname(__file__), 'render')
        pprint.pprint(princes.getAttribute('charsheet', {'name': 'Krug'}))
        pprint.pprint(princes.getAttribute('feat', {'name': 'Great Weapon Master'}))
        #princes.rD(princes.getAttr('charsheet', {'name': 'Krug'}), outdir)
        return 0
    
    if __name__ == "__main__":
        main()

  4. #14
    You'd want to loop through every campaign like it does now but don't check for the names. I don't have the time at the moment to write it out; but I believe in you!

  5. #15
    I don't know python but would you please make any suggestions? Do I just need the two pprint lines? What is the significance of feat?
    Code:
    from phantasy import datahelper
    import pprint
    import os
    
    def main():
        x = datahelper.DataHelper()
        mycampaign = None
        print(__file__)
        for campaign in x.campaigns:
            mycampaign = x.getCampaign(campaign)
            outdir = os.path.join(os.path.dirname(__file__))	
        		pprint.pprint(mycampaign.getAttribute('charsheet'))
        		pprint.pprint(mycampaign.getAttribute('feat'))
        		# mycampaign.rD(mycampaign.getAttr('charsheet'), outdir)
        return 0
    
    if __name__ == "__main__":
        main()
    Last edited by mlesnews; February 19th, 2018 at 00:09.

  6. #16

    @Bidmaron

    Question for you Bidmaron, were you able to get it to work where it created a module that you then loaded into Fantasy Grounds? If so, what did do or show? Thanks in advance.

  7. #17
    I don't know python but would you please make any suggestions? Do I just need the two pprint lines? What is the significance of feat?
    Sure, I've updated the project. If you would get latest you can now see that the run.py has been changed to backup all characters from all campaigns. (You can read the changelog if you want to know more about the new backup function)


    Question for you Bidmaron, were you able to get it to work where it created a module that you then loaded into Fantasy Grounds? If so, what did do or show? Thanks in advance.
    I know you're asking Bid, but I wanted to provide a few screenshots of what it looks like to make a module and what it looks like in game.


    First you add all of the pictures that you want to make into a module into the image folder and setup your script to render from and zip to the correct locations.

    Then you can freely load up or create a new campaign. Check the load modules tab.


    From there you can load the images from the Images & Maps tab from the group dropdown.


    Cheers!

  8. #18

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    2,953
    What he said!

  9. #19
    Thanks guys, I'll update, run it and see what happens! Whoop, I'm excited!

    Code:
    from phantasy import datahelper
    import pprint
    import os
    
    def main():
        x = datahelper.DataHelper()
        for title, campaign in x.campaigns.items():
            outdir = os.path.join(os.path.dirname(__file__), 'render', title)
            if not os.path.exists(outdir):
                os.makedirs(outdir)
            if 'Princes' in title:
                characters = x.getCharacters(campaign)
                for name, charsheet in characters.items():
                    outfile = os.path.join(outdir, name)
                    x.renderData(charsheet, outfile, campaign.metadata['db.xml'])
                    
        return 0
    
    if __name__ == "__main__":
        main()
    When I run this, it doesn't even generate any output or errors. No mod file gets created. I suspect its because as I've highlighted in red in the codeblock, I do not have any campaigns that contain the word 'Princes' in it.


    Last edited by mlesnews; February 21st, 2018 at 02:48.

  10. #20
    Yeah, if you don't have any campaigns with that in it you may want to remove it or change it to a campaign you have saved. I just add that for my testing purposes as I have a few campaigns and don't want to backup all characters for all campaigns.

    Also I think you misunderstand the current separation between projects.

    FGModGen is the code for generating a mod file based on data.

    FantasyGrounded is a way to read and backup data from campaigns.

    At some point I hope to merge the two, but currently they're separate.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Log in

Log in