Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7863 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

How "translateble" is the following C++ code into a script? Is it possible to make a script that functions this way at all?

int Ob(int n)

{

int temp;

if (n == 0) {

return(0); }

else {

temp = rand() % 6 + 1;

if (temp == 6) {

temp = Ob(2); }

return (temp + Ob(n - 1));

}

}

Many thanks in advance!

Posted

Ehum OK.

Well it's about dice rolls. So-called unlimited dice rolls. When you roll a 6, you roll that dice together with a new one again until you don't have anymore 6:s left. The 'Ob' is the sign for 'Obest

Posted

Hello Pontus,

I think that the Swedish>>English translation in your original posting is more confounding than the C++>>FileMaker translation. smile.gifsmile.gif

However I suspect that what you are looking for may be along the lines of:

SetField{"gCounter", "0"]

Loop

If ["not gCounter = 0"]

SetField{"gDiceRoll", "Int(Random * 6) + 1"]

End If

Exit Loop If ["not gDiceRoll = 6"]

End Loop

SetField{"RepeatRollCount", "gCounter - 1"]

You gave us a rather cryptic explanation of what you want to do (admittedly it was less cryptic than your original post), but you didn't say anything about *why* you want to do it or what you hope to achieve by it.

If what I've suggested is wide of the mark, then perhaps it will nonetheless give you some ideas to work with. wink.gif

Posted

Thanks for the link, Lee. And thanks for your script too CobaltSky, with the following changes I've managed to get it workin':

Loop

If ["not gCounter = 0"]

Set Field ["gDiceRoll","Int(Random*6)+1"]

End if

If ["not gDiceRoll = 6"]

Set Field ["gDiceCount","gDiceCount + gDiceRoll"]

Set Field ["gCounter","gCounter - 1"]

End if

Exit loop If ["gCounter=0"]

If ["gDiceRoll = 6"]

Set Field ["gCounter","gCounter + 1"]

End if

End Loop

Before using it one must set gCounter to the number of dices one want to roll, and gDiceCount to zero. Then let the dice roll and take the sum from gDiceCount.

Thanks for the help, everyone!

This topic is 7863 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.