0 votes
by (2.2k points)

Harlowe 2.0.1 is what I'm using.

I've read several about accumulating points to make an event happen as well as scales and I want to figure out how to connect them with with a dice roll, but the dice roll is already complicated to me so I don't know how to incorporate the variable that is luck.

(click: "roll")
(set: $diceroll1 to (random: 1,6))
(set: $diceroll2 to (random: 1,6))
(set: $result1 to $diceroll1 + $diceroll2)
(if: $result1 is 7 or it is 11)[blah words]
(else-if: $result1 is 2 or it is 3 or it is 12)[blah words]
(else-if: ($result1 >= 4 and it <= 6) or (it >= 8 and it <= 10))[blah words]

This is my dice roll, I didn't write it myself, I believe it's for a game called Crabs or Craps, I don't know. I tried to make my own but it didn't work because coding is like a broken leg that I couldn't even use in the first place. So yeah, I'm pretty bad.

Somehow I'd like to incorporate a variable into this to create a couple more outcomes based on the variable level, is that possible? If someone wants to walk me through doing that, that'd be great, I'm fine figuring out the code on my own, I just need help to understand how to do that.

Thank you.

1 Answer

0 votes
by (159k points)
selected by
Best answer

You left out two important pieces of information:

a. Do you want the luck to effect each individual roll of the dice or just the over-all result?

b. How do you want the luck to effect the answer to point A.
eg. What does the luck value represent: is it a straight percentage increase; a straight numerical increase; a percentage chance that an increase occurred and if so how do we determine what that increase was, etc...

Assuming that you want luck to effect the over-all result, and that the luck value represents a straight numerical increase of that result, then you could do something like the following.

(set: $result1 to $diceroll1 + $diceroll2)

<!-- 1. Increase the original result by the luck. -->
(set: $result1 to it + $luck)

<!-- 2. Make sure the new result is not larger than the maximum possible result. -->
(set: $result1 to (min: it, 12))


by (2.2k points)
I didn't think of those things, lol, but because you mentioned them I thought of a perfect way to set it up, so thank you!
by (159k points)
A common technique used by professional programmers (especially when learning a new language) is to first write down what they want to do and then to find the language's features that will allow them to achieve what they want, and generally the more detailed the original description/design is the easier it is to work out how to implement it.

As you become more knowledgeable in the language you learn terms that can be used as short-cuts in your design/descriptions but even then some programmers still try to be descriptive, as it can help them (or others) understand that design if they read it at some later date.