#VARIABLE {itemlist}
{
{blue dagger}
{
{dice} {10}
{hp} {10}
{slot} {wield}
{str} {2}
}
{green hat}
{
{ac} {4}
{con} {2}
{slot} {head}
{wis} {2}
}
{leather cap}
{
{ac} {8}
{con} {1}
{slot} {head}
{str} {1}
}
}
#ALIAS {example}
{
#nop Add items as following:;
#variable itemlist[red rose] {{ac}{1}{int}{2}}
}
#ALIAS {saveitemlist}
{
#system echo -n "" > items.tin;
#foreach {$itemlist[]} {item}
{
#system echo "#var itemlist[$item] {$itemlist[$item]}" >> items.tin
}
}
#ALIAS {readitemlist}
{
#read itemlist.tin
}
#ALIAS {dice}
{
#nop Give the average of a dice, for example: dice 4d7;
#regexp {%0} {%dd%d}
{
#math result &1 + (&1 * &2 - &1) / 2.0;
};
#else
{
#math result 0
};
#showme Average of dice %0 is $result.
}
#ALIAS {itemfind}
{
#nop List items with matching names, for example: itemlist dagger;
#echo {<ffb>%h} {};
#foreach {$itemlist[]} {name}
{
#regexp {$name} {%0}
{
itemshow $name
}
};
#echo {<ffb>%h} {}
}
#ALIAS {itemstat}
{
#nop List items with matching stats, for example: itemstat str > 0 && dam > 3;
#echo {<ffb>%h} { ITEM LIST };
#foreach {$itemlist[]} {item}
{
#math check 0;
#if {"%1" != ""}
{
#math check @itemcheck{{$item}{%1}{%2}{%3}};
#if {"%4" != ""}
{
#math check $check %4 @itemcheck{{$item}{%5}{%6}{%7}};
#if {"%8" != ""}
{
#math check $check %8 @itemcheck{{$item}{%9}{%10}{%11}}
}
}
};
#if {$check}
{
itemshow $item
}
};
#echo {<ffb>%h} {}
}
#FUNCTION {itemcheck}
{
#if {{$itemlist[%1][%2]} == {^%d$}}
{
#math result $itemlist[%1][%2] %3 %4
};
#else
{
#math result {{$itemlist[%1][%2]} %3 {%4}}
}
}
#ALIAS {itemshow}
{
#variable tmp {};
#foreach {$itemlist[%0][]} {item}
{
#format tmp {%s %+8s} {$tmp} {$item $itemlist[%0][$item]}
};
#echo {<128>%+30s<178>: %s} {%0} {$tmp}
}
|