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;)
ID:172778
![]() Mar 28 2004, 8:42 am
|
|
The problem is that you've used pick() very... incorretcly. You need to do:
var/number = rand(1,5) Pick() cannot be used to pick bits of code. |
Hazman wrote:
The problem is that you've used pick() very... incorretcly. You need to do: > var/number = rand(1,5) 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 |
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;) |
Silversmith5 wrote:
I used the pick() in the same way as the DM ref. Heres the errors: You have " all over the place. You can only start with one, and end with one. --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;) |
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> |
Here you go...
verb/Play() |
You're using two prob(100) calls, which is pretty redundent. Try making one 95, and the other 90, since 100 will always happen.
|
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. |
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- |
Silversmith5 wrote:
else() Your problem is the line thats bold. Have a look at what was posted, and have a look at what you have written. |
Tell us the errors.
--SSJ4_Gohan_Majin