ID:172778
 
i need help heres the code:

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
usr << pick(
"The ball lands on a CHERRY! You double up!"
prob(100)
Coins += 8
"The ball lands on a BOXING GLOVE! You lose 4 coins..."
prob(100)
Coins -= 4
"The ball lands on a LEMON! You break even."
prob(50)
Coins += 4
"The ball lands on a BOMB! You lose 12 coins!"
prob(5)
Coins -= 12
"The ball lands on a JACKPOT! You win 12 coins!"
prob(5)
Coins += 12
)
else()
usr << "You don't have enough coins!"

the text wrapping messed up ;) Anyway, i get tons of errors. WHY? thx -Silver;)
Silversmith5 wrote:
i need help heres the code:

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
usr << pick(
"The ball lands on a CHERRY! You double up!"
prob(100)
Coins += 8
"The ball lands on a BOXING GLOVE! You lose 4 coins..."
prob(100)
Coins -= 4
"The ball lands on a LEMON! You break even."
prob(50)
Coins += 4
"The ball lands on a BOMB! You lose 12 coins!"
prob(5)
Coins -= 12
"The ball lands on a JACKPOT! You win 12 coins!"
prob(5)
Coins += 12
)
else()
usr << "You don't have enough coins!"

the text wrapping messed up ;) Anyway, i get tons of errors. WHY? thx -Silver;)

Tell us the errors.

--SSJ4_Gohan_Majin
The problem is that you've used pick() very... incorretcly. You need to do:
var/number = rand(1,5)
switch(number)
if(1)
usr << "The ball lands on a CHERRY! You double up!"
usr.coins += 8
if(2) //etc etc.

Pick() cannot be used to pick bits of code.
In response to Hazman
Hazman wrote:
The problem is that you've used pick() very... incorretcly. You need to do:
> var/number = rand(1,5)
> switch(number)
> if(1)
> usr << "The ball lands on a CHERRY! You double up!"
> usr.coins += 8
> if(2) //etc etc.
>

Pick() cannot be used to pick bits of code.

Ya, I think the closest you can get is a text string. Directly from the reference:
pick proc
See also:
prob proc
Format:
pick(Val1,Val2,...)
Returns:
One of the given values randomly chosen.
To make a particular value more or less likely to be chosen, a relative probability may be specified like this:

prob(P); Val
Or
P; Val

A value for P of 200 makes it twice as likely as the norm, 50 half as likely, and so on.

Example:
obj/food
verb/eat()
usr << pick (
"[usr] eats \a [src].",
prob(50)
"[usr] devours \a [src].",
prob(25)
"[usr] wolfs down \a [src]."
)
del(src)

Also, to pick a value randomly from a list, simply pass the list as the sole argument into pick(). In this case, there is no provision for weighting the probabilities. All items in the list are equally likely.
In response to SSJ4_Gohan_Majin
I used the pick() in the same way as the DM ref. Heres the errors:

loading ChanceChat.dme
ChanceChat.dm:117:error: Coins: missing comma ',' or right-paren ')'
ChanceChat.dm:117:error: Coins: expected end of statement
ChanceChat.dm:118:error: expected expression
ChanceChat.dm:121:error: expected expression

ChanceChat.dmb - 4 errors, 0 warnings (double-click on an error to jump to it)

thx -Silver;)
In response to Silversmith5
Silversmith5 wrote:
I used the pick() in the same way as the DM ref. Heres the errors:

loading ChanceChat.dme
ChanceChat.dm:117:error: Coins: missing comma ',' or right-paren ')'
ChanceChat.dm:117:error: Coins: expected end of statement
ChanceChat.dm:118:error: expected expression
ChanceChat.dm:121:error: expected expression

ChanceChat.dmb - 4 errors, 0 warnings (double-click on an error to jump to it)

thx -Silver;)

You have " all over the place. You can only start with one, and end with one.

--SSJ4_Gohan_Majin
In response to SSJ4_Gohan_Majin
K, im confused. Im using the pick proc like the reference. Heres the code i edited:

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
usr << pick(
"The ball lands on a CHERRY! You double up!",
"The ball lands on a BOXING GLOVE! You lose 4 coins.",
"The ball lands on a LEMON! You break even.",
"The ball lands on a BOMB! You lose 12 coins!",
"The ball lands on a JACKPOT! You win 12 coins!",
)

I get one warning about the statement having no effect x(
When i put in prob():

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
usr << pick(
"The ball lands on a CHERRY! You double up!",
"The ball lands on a BOXING GLOVE! You lose 4 coins.",
"The ball lands on a LEMON! You break even.",
"The ball lands on a BOMB! You lose 12 coins!",
"The ball lands on a JACKPOT! You win 12 coins!",
)

YAY! same warning! When i add the Coin VAR & change it:

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
usr << pick(
prob(50)
Coins += 8
"The ball lands on a CHERRY! You double up!",
prob(50)
Coins -= 8
"The ball lands on a BOXING GLOVE! You lose 4 coins.",
prob(50)
Coins += 4
"The ball lands on a LEMON! You break even.",
prob(50)
Coins -= 12
"The ball lands on a BOMB! You lose 12 coins!",
prob(50)
Coins += 12
"The ball lands on a JACKPOT! You win 12 coins!",
)

I GET TONS OF ERRORS:

loading ChanceChat.dme
ChanceChat.dm:117:error: "The ball lands on a CHERRY! You double up!": missing comma ',' or right-paren ')'
ChanceChat.dm:117:error: "The ball lands on a CHERRY! You double up!": expected end of statement
ChanceChat.dm:117:error: expected expression
ChanceChat.dm:117:error: ,: expected }
ChanceChat.dm:108:error: location of top-most unmatched {

ChanceChat.dmb - 5 errors, 0 warnings (double-click on an error to jump to it)

hmmm.... why? how can i fix this. Ive tried & tried but to no effect... thx -Silver;)


In response to Silversmith5
As others have already said, PICK() CANNOT BE USED TO CHOOSE BETWEEN DIFFERENT STATEMENTS. All you can do is pick() from a bunch of strings, or some numbers, or whatever.

What you want is rand() and a switch() statement, like this:

<code>switch(rand(1,5)) if (1) usr << "The ball lands on a CHERRY!" Coins+=8 if (2) usr << "The ball lands on something else entirely!" Coins-=100 if (3) usr << "The ball explodes!" Coins+=1000 if (4) usr << "The ball fails to hit anything." if (5) usr << "The ball falls into a black hole." Coins-=50</code>
In response to Crispy
Here you go...
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
switch(pick(
prob(100); 1,
prob(100); 2,
prob(50); 3,
prob(5); 4,
prob(5); 5))
if(1)
usr << "The ball lands on a CHERRY! You double up!"
usr.Coins += 8
if(2)
usr << "The ball lands on a BOXING GLOVE! You lose 4 coins..."
usr.Coins -= 4
if(3)
usr << "The ball lands on a LEMON! You break even."
usr.Coins += 4
if(4)
usr << "The ball lands on a BOMB! You lose 12 coins!"
usr.Coins -= 12
if(5)
usr << "The ball lands on a JACKPOT! You win 12 coins!"
usr.Coins += 12
else usr << "You don't have enough coins!"
In response to Yota
You're using two prob(100) calls, which is pretty redundent. Try making one 95, and the other 90, since 100 will always happen.
In response to Nadrew
Read up on pick() in the reference manual. pick() simply changes the odds of an item being picked. (Completly different from it's normal use.)

EDIT: I don't think thoes 100s are needed though in this case. 100 is the default probability.
In response to Yota
thx, i get it now. heres the code:

RouletteTable
icon = 'RouletteTable.dmi'
density = 1
verb/Play()
set category = "Roulette"
set src in oview(1)
if(Coins >= 4)
Coins -= 4
usr << "You bet 4 coins."
Gplay += 1
switch(pick(
prob(75); 1,
prob(75); 2,
prob(50); 3,
prob(5); 4,
prob(5); 5))
if(1)
usr << "The ball lands on a CHERRY! You double up!"
Coins += 8
if(2)
usr << "The ball lands on a BOXING GLOVE! You win nothing..."
Coins -= 4
if(3)
usr << "The ball lands on a LEMON! You break even."
Coins += 4
if(4)
usr << "The ball lands on a BOMB! You win no coins..."
Coins -= 12
if(5)
usr << "The ball lands on a JACKPOT! You win 12 coins!"
Coins += 12
else()
usr << "You don't have enough coins!"

It works fine. YAY! except theres one warning:

loading ChanceChat.dme
ChanceChat.dm:135::warning: statement has no effect
loading Casino.dmp
saving ChanceChat.dmb

ChanceChat.dmb - 0 errors, 1 warning (double-click on an error to jump to it)

Anyways, THX A TON. -Silver-
In response to Silversmith5
Silversmith5 wrote:
else()

It works fine. YAY! except theres one warning:

loading ChanceChat.dme
ChanceChat.dm:135::warning: statement has no effect
loading Casino.dmp
saving ChanceChat.dmb

ChanceChat.dmb - 0 errors, 1 warning (double-click on an error to jump to it)

Anyways, THX A TON. -Silver-

Your problem is the line thats bold. Have a look at what was posted, and have a look at what you have written.