Mass-adding items?
Moderators: Bob the Hamster, marionline, SDHawk
- BMR
- Metal King Slime
- Posts: 3310
- Joined: Mon Feb 27, 2012 2:46 pm
- Location: The Philippines
- Contact:
Mass-adding items?
Hiya, was wondering if there was a way to mass-add items in Custom? Like around 100+ items that I have charted out on a spreadsheet. I've been digging around trying to figure it out, is there a cunning to use a combination of unlumping, editing, and relumping to do what I want? Or am I over-complicating things?
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
- Spoonweaver
- Liquid Metal King Slime
- Posts: 6247
- Joined: Mon Dec 08, 2008 7:07 am
- Location: Home
- Contact:
There MAY be a way to do what you want but the likely hood of your chart being in the exact right format is very very low. Even if your format was pretty good, and the process of importing it wasn't shaky at best, you'd still have to go through all the items to make sure they came out right which chances are they wouldn't.
You're best bet is to just start entering them in to the editor.
You're best bet is to just start entering them in to the editor.
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
Oh, well, I meant there is no easy built-in way. If you are talking about programming your own tool for editing the .ITM lump, yes that is possible.
The documentation for the ITM lump is here: http://rpg.hamsterrepublic.com/ohrrpgce/ITM
Also, the nohrio python library already has at least partial support for the ITM lump, so that might be the easiest starting point. https://gitorious.org/nohrio
The documentation for the ITM lump is here: http://rpg.hamsterrepublic.com/ohrrpgce/ITM
Also, the nohrio python library already has at least partial support for the ITM lump, so that might be the easiest starting point. https://gitorious.org/nohrio
I had a play around, and found that nohrio's description of the ITM lump was wrong (which was the fault of the wiki page, which didn't mention an unused field. A fix is available from my nohrio clone
I wrote a script to convert an .itm lump to a .csv file:
General enough to be used for most other lumps too.
If you're interested, I can write the csv to itm direction.
I wrote a script to convert an .itm lump to a .csv file:
Code: Select all
import numpy as np
from nohrio.ohrstring import *
from nohrio.wrappers import OhrData
from nohrio.dtypes import dt
def get_field_decoder(dtype, name):
"""
Depack a (possibly compound) field of a dtype, returning a (header, decoder) tuple
A header is a list of one or more field names.
A decoder takes a data field and returns a list (same length as header) of ints/floats/strings
"""
ty = dtype[name]
if len(ty):
# compound field
if ty.names[0] == 'length':
# it's a string. Assume vstr2, since that's the only one used in ITM
decoder = lambda x: ['"' + get_str16(x) + '"']
header = [name]
else:
# a tuple
decoder = lambda x: x
header = [name + ':' + n for n in ty.names]
elif len(ty.shape):
# array
assert len(ty.shape) == 1
decoder = list
header = [name + ' ' + str(i) for i in range(ty.shape[0])]
else:
# simple integer/float
decoder = lambda x: [x]
header = [name]
return header, decoder
def lump2csv(lump, fields):
headers2, decoders = [], []
for name in fields:
headers, decoder = get_field_decoder(lump.dtype, name)
headers2.extend(headers)
decoders.append(decoder)
ret = [','.join(headers2)]
for item in lump:
stuff = []
for i, name in enumerate(fields):
stuff.extend(decoders[i](item[name]))
ret.append(','.join(str(a) for a in stuff))
return '\n'.join(ret)
itm = np.memmap("viking.itm", dtype = dt['itm'], mode = 'r+')
# If you're interested in ALL data
#fields = dt['itm'].names
# Only interested in some...
fields = (
'name',
'info',
'value',
'attack',
'weaponattack',
'equippable',
# 'teach',
# 'oobuse',
'weaponpic',
'weaponpal',
'bonuses',
# 'equippableby',
# 'bitsets',
'consumability',
# 'own_tag',
# 'in_inventory_tag',
# 'equipped_tag',
# 'equippedby_active_tag',
# 'frame2handle',
# 'frame1handle',
# 'elemdmg'
)
print lump2csv(itm, fields)If you're interested, I can write the csv to itm direction.
- BMR
- Metal King Slime
- Posts: 3310
- Joined: Mon Feb 27, 2012 2:46 pm
- Location: The Philippines
- Contact:
Sweet. That would be great if you could do the csv to itm as well, if it's not too much trouble. I can read through that code and get a basic idea of how it works, but the programming level just goes way above my head, hehe... Thanks.
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Using Editor version wip 20170527 gfx_sdl+fb music_sdl