https://i.imgur.com/8mFXDPG.png
Printable View
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.
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()
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!
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()
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.
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)Quote:
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?
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.Quote:
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.
https://i.imgur.com/R4CkAJh.png
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.
https://i.imgur.com/PLsts9q.png
From there you can load the images from the Images & Maps tab from the group dropdown.
https://i.imgur.com/UGod9p1.png
Cheers!
What he said!
Thanks guys, I'll update, run it and see what happens! Whoop, I'm excited!
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.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()
https://i.imgur.com/G6hPpu7.png
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.