Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(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()