2011-08-22 19:04:28 -04:00
|
|
|
#!/bin/bash
|
2011-08-22 21:27:06 -04:00
|
|
|
#
|
|
|
|
# Common inventory commands
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Mike Gerwitz
|
|
|
|
#
|
|
|
|
# This file is part of gsgp. This program is free software: you can
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
# License as published by the Free Software Foundation, either version 3 of
|
|
|
|
# the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
|
|
|
. "$mypath/common"
|
2011-08-22 19:04:28 -04:00
|
|
|
|
|
|
|
itemdir="$( dirname $0 )/../items"
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Retrieve name of item from item descriptor file
|
|
|
|
#
|
|
|
|
# @param string item tag
|
|
|
|
#
|
|
|
|
# @output full item name
|
|
|
|
##
|
|
|
|
inv-item-name()
|
|
|
|
{
|
|
|
|
local id=$( inv-item-id "$1" )
|
|
|
|
|
|
|
|
# we're looking for the NAME line, in the format of "NAME <full name>"
|
|
|
|
cat "$itemdir/$id" <<< "$1" \
|
|
|
|
| grep '^NAME ' \
|
|
|
|
| cut -d' ' -f2-
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inv-item-id()
|
|
|
|
{
|
|
|
|
cut -d':' -f2 <<< "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inv-item-count()
|
|
|
|
{
|
|
|
|
cut -d':' -f1 <<< "$1"
|
|
|
|
}
|
|
|
|
|