User:Alejandro: Difference between revisions
From LiberationMUSH Wiki
(Created page with "Tally counter for a spendable that isn't covered by the +burn and +gain system This is unofficial code and is used for personal record keeping only. You can only have one at a...") |
No edit summary |
||
Line 3: | Line 3: | ||
<pre> | <pre> | ||
@create | @create item=10 | ||
&VAR.CAP | &VAR.CAP item=10 | ||
&VAR.CURRENT | &VAR.CURRENT item=10 | ||
&VAR.POOL.NAME | &VAR.POOL.NAME item=Glamour | ||
&VAR.ITEM.type | &VAR.ITEM.type item=Treasure | ||
&CMD.SPEND | &CMD.SPEND item=$^\+item/spend( \\d*)?$:@assert [gte(setr(remaining,u(var.current)),setr(arg,ifelse(%1, trim(%1),1)))]=@pemit %#=You cannot spend [r(arg)][u(var.pool.name)], you only have [r(remaining)] left in your [u(var.item.type)]'s pool.;&var.current me=setr(newRemaning,sub(r(remaining), r(arg)));@pemit %#=You have spent [r(arg)] [u(var.pool.name)] of your [u(var.item.type)]'s [u(var.pool.name)], you have [r(newRemaining)] left. | ||
@set | @set item/CMD.SPEND = regexp | ||
&CMD.POOL | &CMD.POOL item=$+item/pool:@pemit %#=Your [u(var.item.type)] has [u(var.current)] [u(var.pool.name)] left. | ||
&CMD.CHARGE | &CMD.CHARGE item=$^\+item/charge( \\d+)?$:@pemit %#=Topped up your [u(var.item.type)]'s [u(var.pool.name)] by [setr(amount,ifelse(gt(add(%1,u(var.current)),u(var.cap)), [sub(u(var.cap),u(var.current))], [trim(%1)]))];&var.current me=[add(u(var.current), r(amount))] | ||
@set | @set item/CMD.CHARGE = regexp | ||
@set | @set item=!no_command | ||
@desc item=Al's ticker counter. | |||
</pre> | </pre> |
Revision as of 15:42, 11 November 2021
Tally counter for a spendable that isn't covered by the +burn and +gain system This is unofficial code and is used for personal record keeping only. You can only have one at a time at present, because I haven't the mental capacity to improve it at at the moment.
@create item=10 &VAR.CAP item=10 &VAR.CURRENT item=10 &VAR.POOL.NAME item=Glamour &VAR.ITEM.type item=Treasure &CMD.SPEND item=$^\+item/spend( \\d*)?$:@assert [gte(setr(remaining,u(var.current)),setr(arg,ifelse(%1, trim(%1),1)))]=@pemit %#=You cannot spend [r(arg)][u(var.pool.name)], you only have [r(remaining)] left in your [u(var.item.type)]'s pool.;&var.current me=setr(newRemaning,sub(r(remaining), r(arg)));@pemit %#=You have spent [r(arg)] [u(var.pool.name)] of your [u(var.item.type)]'s [u(var.pool.name)], you have [r(newRemaining)] left. @set item/CMD.SPEND = regexp &CMD.POOL item=$+item/pool:@pemit %#=Your [u(var.item.type)] has [u(var.current)] [u(var.pool.name)] left. &CMD.CHARGE item=$^\+item/charge( \\d+)?$:@pemit %#=Topped up your [u(var.item.type)]'s [u(var.pool.name)] by [setr(amount,ifelse(gt(add(%1,u(var.current)),u(var.cap)), [sub(u(var.cap),u(var.current))], [trim(%1)]))];&var.current me=[add(u(var.current), r(amount))] @set item/CMD.CHARGE = regexp @set item=!no_command @desc item=Al's ticker counter.