# Another syntax for Anydice mechanic question

I’m trying to build a function to model not just a roll of the dice, but to have boolean operators to toggle using various powers that effect the dice. I’ve gotten everything to work except for one thing- looking at the result of the roll, seeing if a ‘1’ was rolled and then changing that ‘1’, but only once.

The dice mechanic is for Cryptomancer, and it works by takinging your rank in a skill which is 1 to 5 and rolling that many d10’s plus a number of d6’s that total to 5 dice. For d10s, 1’s are always botches (-1), numbers under the target number are 0’s and numbers equal to or greater the target are successes (+1). On the d6’s 1s are botches, 6s are success and everything else is 0.

I’ve been using custom die for my rolls but set the function up to build the roll off just a skill number and challenge number. Here’s what i got so far-

`function: sb B:n sp P:n skill SKILL:n vs CHALLENGE:n{ if P=1{ ROLL: SKILLd{-1,0:(CHALLENGE-2),1:(10-CHALLENGE),2}+(5-SKILL)d{-1,0:4,1} } else { ROLL: SKILLd{-1,0:(CHALLENGE-2),1:(11-CHALLENGE)}+(5-SKILL)d{-1,0:4,1} } if B=1{ if 5@ROLL=-1{ ROLL:ROLL+2 } } result:ROLL } `

The goal is that you can toggle things by entering a 1 or 0 for the values B and P to turn them on or off. P=1 makes all ’10s’ rolled be worth +2 success instead of +1. B=1 is suppose to check the last value of the roll, and if a -1 is present add 2 to the whole total, there by turning one and only one botch into a success, even if there are multiple botches in the roll.

Everything works till i turn on B. then i get an error that the boolean operation `if` can only be used on numbers. Turns out `5@ROLL` isn’t giving me the lowest roll of 5 dice but the probability of what that roll will be. How do i fix this? How can i convert `ROLL:d` into `ROLL:s`?