Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Haversack (Bag +5)

Haversack holds gear in your tabletop campaign. 路 By Tartle Games

Arcane Spell Scrolls for store import

A topic by Tartle Games created Mar 15, 2018 Views: 562 Replies: 12
Viewing posts 1 to 8
Developer (1 edit)

I wrote a converter in Python and made this list using this online thing. Unfortunately, this list is REALLY long (200 scrolls). I was successful in importing it in the PC version of Bag +5, but when testing on the mobile version, it was just too long. I think my Samsung device's clipboard cuts the content at some built in limit. You may have different results with a different mobile device.  The content is in a basic text file. I can't paste the full text content here in the community page because it too has a limit of 20480 characters. I am sharing the text file from google drive.

https://drive.google.com/open?id=17Sbu9bflLZNjO-ONyTMgs-RElw7QJOfX

Developer (2 edits)

Also notice that the value of the scrolls isn't correct. I tried using a formula to calculate the value based on level, but the way the list read in, some spells didn't have a listed level because it varies by player class.

Developer (2 edits)

if you are interested in trying to adapt my python script to import other things here it is. This is in no way an easily reusable script. Good luck.

import json
''' not working
with open('JsonSpellListCleaned.json') as json_data:
    d = json.load(json_data)
    print("read this many ", len(d))
'''
json_content = " content goes here "
converted = json.loads(json_content)
'''
It is a json string.
title == the name of the custom store
count == the number of items in the store
id == needs to be "-"
store_items == is the list of items. There are two items in the example below.
store_items explained
t = name of the item
l = the description text of the item (that is a lower case L not and i)
n = the quantity that the item is sold in. Example, arrows are sold in batches of 20.
v = value of the item. How much it costs.
w = the weight of the item.
i = the item's icon name. see my other email for the complete list.
{"title":"Example Store","count":2,"id":"-","store_items":[{"t":"a thing","l":"a thingy - an item of some importance. Why else would you have put it in your bag?","n":1,"v":1,"w":1.0,"i":"Battle_axe"},{"t":"A Hammer","l":"lore text","n":1,"v":99875,"w":1.0,"i":"SilverHammer"}]}
'''
store = {}
store['title'] = "The Rat Wizard's Spells"
store['id'] = '-'
store['store_items'] = [] #this will be the dictionary in the store that contains the items
def AddItemToStore(item):
    converted_item = {}
    converted_item['t'] = item['name']
    build_lore = item['desc'][0] + '\n'
    #build_lore += "at higher level " +item['higher_level'][0] + '\n' # this was causing a lot of issues
    build_lore += "range " + item['range'] + '\n'
    build_lore += "components " + json.dumps(str(item['components'])) + '\n'
    #build_lore += "material " + item['material'] + '\n' # this was causing a lot of issues
    build_lore += "duration " + item['duration'] + '\n'
    build_lore += "concentration " + item['concentration'] + '\n'
    build_lore += "casting time " + item['casting_time'] + '\n'
    build_lore += "level " + str(item['level']) + '\n'
    build_lore += "School " + item['school']['name']
    converted_item['l'] = build_lore
    converted_item['n'] = 1
    converted_item['v'] = item['level'] * 250 + 100 #guessing here
    converted_item['w'] = 0
    converted_item['i'] = "EnchantedScroll"
    return converted_item
#len(converted) for testing, I am only going to do 3 items
#there is an issue with adding such a long store json in the mobile
#version of the app. But it works in the pc version.
for i in range(len(converted)):
    classes = converted[i]['classes']
    isGood = False
    for i in range(len(classes)):
        isGood = classes[i]['name'] == 'Wizard'
    if(isGood):
        d = AddItemToStore(converted[i])
        print('.', end='')
        store['store_items'].append(d) #assinging the item into the items list in the main dict
    
    
store['count'] = len( store['store_items'] )
print('imported ', store['count'], ' items')
final_string = json.dumps(store)
#print(final_string) #for the final product, this is huge and breaks python idle
f = open("spellListBagPlus5_v1.txt", 'w')
f.write(final_string)
f.close()

If you use Notepad++ to look at your text, and select Ada under languages, it becomes significantly easier to look at that text.

..not that I know what to do with it, but it gets easier.

Do you have a program / databse /spreadsheet to generate store lists, or just that script?

Developer

This script does clean up on items from this online database: http://www.dnd5eapi.co/

I don't have a random generator. The app itself has the means to import/export a JSON test list of a store.

(1 edit)
Oh, I didn't mean a random generator. I meant a program or etc. to export a JSON file which I can import in to the store. :)
Developer

Oh, you can do that in the app itself. I made these screenshots. If you view the stores there is a button that allows you to share that will automatically copy the json to the clipboard or you can click into the box and copy it. Pass that over and a friend can then copy it and paste it in if they also have the app. In these screenshots I used the default store in the app. You can create your own from the "stores" button, but it takes some time to add items in. If you make a cool merchant store share here in a post on the app's page and maybe some other people can use it :D

Very interesting! I guess I'll take a stab at trying to make a special template in Notepad++ to highlight and make it easier to read.  A template with code snippets would go a long way.
Unless you already have a solution for those things..?
I'll put it on my to-do list. ;)

Developer (1 edit)

I don't have anything like that but I do have these instructions I'd made for a friend on the variables in the json export.

This explains the json store that is in the export from the app.
title == the name of the custom store
count == the number of items in the store
id == needs to be "-"
store_items == is the list of items. There are two items in the example below.
------------------------------
store_items explained
t = name of the item
l = the description text of the item (that is a lower case L not and i)
n = the quantity that the item is sold in. Example, arrows are sold in batches of 20.
v = value of the item. How much it costs.
w = the weight of the item.
i = the item's icon name. There are a lot of these now, but if it is an invalid string it will just display as a white square.
{"title":"Test Store","count":2,"id":"-","store_items":[{"t":"a thing","l":"a thingy - an item of some importance. Why else would you have put it in your bag?","n":1,"v":1,"w":1.0,"i":"Battle_axe"},{"t":"A Hammer","l":"lore text","n":1,"v":99875,"w":1.0,"i":"SilverHammer"}]}
Developer

It's been a long while since I've been able to add anything to the app. The last update I did was adding some new stuff to the Android build, but then I could never get it working to update my iphone build because of changes to Unity and Xcode 馃槶

After a lot of effort I had to move on to other things or risk losing all my sanity. 

OH, that sucks. Well, as long as this build is stable..
Can you backgrade to the old build environment, and make it work that way?

Developer

Unfortunately not. I tried. I could get it to build in Unity, it's just when I took it to Xcode that I ran into problems. The issue was a combination of Unity's official in-app purchase package and X-code. It would have been possible to fix I'm sure, but I was going to need a lot more time and a new mac computer. Mine couldn't run the newest version of X-Code :(

I guess that's what I get for doing my Xcode compiling on a refurbished mac mini.

Meh, I'd blame it on Unity first. I keep hearing that Unity can be either a gift from God or a curse from Satan. I haven't done any compiling for a while, but didn't there used to be a Linux compiler that could compile cross platform? That might solve your Mac problem. Also, I think I saw an Open Source Mac OS X for installing on x86_64 machines just the other day. I don't pay much attention to Mac, but maybe you could install that on a USB drive or an SSD or something and do your Mac compiling that way? Maybe? No clue if Mac will compile across platforms, but...?