dupbool
Duplicates the value on top of the boolean stack. Good for saving a condition and using it again, for example to nest conditions in the body.
Facts
dupbool pushes a copy of the value on top of the boolean stack. With an empty stack it does nothing.
Its use is nesting conditions inside the body: you save a copy of the outer condition, combine it with an inner one using and, and when done a dropbool gives you back the outer one intact for the next. The bot This'n'That 1.01 (Peksa), from the Bestiary, does this to balance energy (.nrg) and body (.body):
' This'n'That 1.01 (Peksa): balances energy and body
cond
start
*.nrg *.body !%= dupbool
*.nrg *.body > and
*.nrg *.body sub 100 ceil .strbody store dropbool
*.body *.nrg > and
*.body *.nrg sub 100 ceil .fdbody store
stopThe outer condition is “energy and body differ by more than 10%” (!%=). The boolean stack goes through:
| After | Boolean stack (top on the right) |
|---|---|
!%= dupbool | differ, differ |
> and | differ, (differ and energy to spare) |
dropbool | differ |
> and | (differ and body to spare) |
That way, if there is energy to spare it moves it to the body (.strbody) and if there is body to spare it moves it to energy (.fdbody), 100 at a time at most (ceil keeps the smaller). A bot that starts with 3000 energy and 1000 body stops at 1300 and 1170.