Lets do some more coding
lets create an object which changes quantity each time you think:
##push:runsub isitme;
##isitme:if $actor eq $target then incrit else end;
##incrit:
var $newqty to $actor's qty;
add 1 to $newqty;
set $target's qty to $newqty;
say 'msg',"[$actor] increated slightly because of [$init_obj]";
msg $loc,$actor,0,0,'force',"force:look $loc";
Some interesting new cowscript statements we have here are 'add' and 'msg with a force'.
add simply adds the first number to the variable.
msg with the force keyword is used to give players a refreshed view of their current location.
Lets put a cap on how high this quantity will go:
##push:runsub isitme;
##isitme:if $actor eq $target then incrit else end;
##incrit:
var $newqty to $actor's qty;
add 1 to $newqty;
if $newqty > 10 then nohigher else continue;
##continue:
set $target's qty to $newqty;
say 'msg',"[$actor] increased slightly because of [$init_obj]";
msg $loc,$actor,0,0,'force',"force:look $loc";
##nohigher:
say 'msg',"[$actor] appears the same as before [$init_obj]";
Now if we want it to slowly decrease once it has reached 10 then slowly increase when it reaches 1 we would do this:
##push:runsub isitme;
##isitme:if $actor eq $target then changeit else end;
##changeit:
var $newqty to $actor's qty;
var $direction = $actor's direction;
if $direction eq "decreased" then decrit else incrit;
set $target's qty to $newqty;
set $target's direction to $direction;
say 'msg',"[$actor] $direction slightly because of [$init_obj]";
msg $loc,$actor,0,0,'force',"force:look $loc";
##incrit:
add 1 to $newqty;
var $direction to "increase";
if $newqty > 10 then nohigher else end;
##nohigher:
take 1 from $newqty;
var $direction to "decrease";
##decrit:
take 1 to $newqty;
var $direction to "decrease";
if $newqty < 1 then nolower else end;
##nolower:
add 1 to $newqty;
var $direction to "increase";
Notice how we have two sets of blocks, one set to increase and the other to decrease, both putting limits on how far the newqty goes.