Drink Menu
metalmario991
04 Jun 2016, 13:40In game, I made it able to order drinks at a bar and I keep getting this one area and I'd like to know how to fix it.
This is my error: Error running script: Error compiling expression 'game.drink = Beer': Unknown object or variable 'Beer'
This is my code:
msg ("You greet Henry with a friendly, \"Hullo.\"")
wait {
msg ("In response he says, \"What will it be, shorty?\"")
ShowMenu ("(What drink do you want, Harold?)", Split ("Beer;Wine;Whiskey;Vodka",";"), false) {
game.drink = result
msg ("\"You got it shorty!\" Henry says as he gets to work.")
wait {
if (game.drink = Beer) {
if (game.money >= 3) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.")
wait {
game.money = game.money - 3
msg ("You flip three bucks onto the counter.<br/>You grab the mug o'beer triumphantly, and down it and a macho man fashion.")
game.drink = default
}
}
else if (game.money < 3) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire mug on your head! \"Next time, don't order unless you can afford!\" he shouts.")
game.drink = default
}
}
else if (game.drink = Wine) {
if (game.money >= 5) {
msg ("Henry calmly puts the fine glass of wine on the counter.<br/>\"Cost ya five bucks, mister.\"")
wait {
firsttime {
msg ("You hand five bucks to Henry.<br/>You don't drink the wine, but instead decide to carry it with you. Shoving it very carefully into your right pants pocket.")
AddToInventory (wine)
MakeObjectVisible (wine)
game.money = game.money - 5
game.drink = default
IncreaseScore (5)
}
otherwise {
msg ("You've had enough wine for one night!")
}
}
}
else if (game.money < 5) {
msg ("Henry calmly puts the fine glass of wine on the counter.<br/>\"Cost ya five bucks, mister.\"<br/>You apologize to Henry for not being able to afford it.<br/>He angrily splashes the wine in your face! Have more money next time you order a drink!")
game.drink = default
}
}
else if (game.drink = Whiskey) {
if (game.money >= 6) {
msg ("Henry slides the shot of whiskey onto the counter.<br/>\"Six bucks, boy! Cough it up!\" he snorts.")
wait {
game.money = game.money - 3
msg ("You throw six bucks on to the counter.<br/>You down the shot of whiskey confidently!")
game.drink = default
}
}
else if (game.money < 6) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire mug on your head! \"Next time, don't order unless you can afford!\" he shouts.")
game.drink = default
}
else if (game.drink = Vodka) {
if (game.money >= 2) {
msg ("Henry throws the shot of vodka onto the counter.<br/>\"That will be two dollars, mac!\"")
wait {
game.money = game.money - 2
msg ("You flip two dollars onto the counter.<br/>The shot of vodka goes down smoothly.")
game.drink = default
}
}
else if (game.money < 2) {
msg ("Henry throws the shot of vodka onto the counter.<br/>\"That will be two dollars, mac!\"<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire shot on your suit! This is a $300 suit, goddamit!")
game.drink = default
}
}
}
}
}
This is my error: Error running script: Error compiling expression 'game.drink = Beer': Unknown object or variable 'Beer'
This is my code:
msg ("You greet Henry with a friendly, \"Hullo.\"")
wait {
msg ("In response he says, \"What will it be, shorty?\"")
ShowMenu ("(What drink do you want, Harold?)", Split ("Beer;Wine;Whiskey;Vodka",";"), false) {
game.drink = result
msg ("\"You got it shorty!\" Henry says as he gets to work.")
wait {
if (game.drink = Beer) {
if (game.money >= 3) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.")
wait {
game.money = game.money - 3
msg ("You flip three bucks onto the counter.<br/>You grab the mug o'beer triumphantly, and down it and a macho man fashion.")
game.drink = default
}
}
else if (game.money < 3) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire mug on your head! \"Next time, don't order unless you can afford!\" he shouts.")
game.drink = default
}
}
else if (game.drink = Wine) {
if (game.money >= 5) {
msg ("Henry calmly puts the fine glass of wine on the counter.<br/>\"Cost ya five bucks, mister.\"")
wait {
firsttime {
msg ("You hand five bucks to Henry.<br/>You don't drink the wine, but instead decide to carry it with you. Shoving it very carefully into your right pants pocket.")
AddToInventory (wine)
MakeObjectVisible (wine)
game.money = game.money - 5
game.drink = default
IncreaseScore (5)
}
otherwise {
msg ("You've had enough wine for one night!")
}
}
}
else if (game.money < 5) {
msg ("Henry calmly puts the fine glass of wine on the counter.<br/>\"Cost ya five bucks, mister.\"<br/>You apologize to Henry for not being able to afford it.<br/>He angrily splashes the wine in your face! Have more money next time you order a drink!")
game.drink = default
}
}
else if (game.drink = Whiskey) {
if (game.money >= 6) {
msg ("Henry slides the shot of whiskey onto the counter.<br/>\"Six bucks, boy! Cough it up!\" he snorts.")
wait {
game.money = game.money - 3
msg ("You throw six bucks on to the counter.<br/>You down the shot of whiskey confidently!")
game.drink = default
}
}
else if (game.money < 6) {
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire mug on your head! \"Next time, don't order unless you can afford!\" he shouts.")
game.drink = default
}
else if (game.drink = Vodka) {
if (game.money >= 2) {
msg ("Henry throws the shot of vodka onto the counter.<br/>\"That will be two dollars, mac!\"")
wait {
game.money = game.money - 2
msg ("You flip two dollars onto the counter.<br/>The shot of vodka goes down smoothly.")
game.drink = default
}
}
else if (game.money < 2) {
msg ("Henry throws the shot of vodka onto the counter.<br/>\"That will be two dollars, mac!\"<br/>You are sad to say to Henry that you can't afford the drink.<br/>Angrily, he pours the entire shot on your suit! This is a $300 suit, goddamit!")
game.drink = default
}
}
}
}
}
Korpsian
04 Jun 2016, 14:31i think... but i am not shure you forgot to close the if argument:
if (game.drink = Beer) { - open
if (game.money >= 3) { - open
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.")
wait { - open
game.money = game.money - 3
msg ("You flip three bucks onto the counter.<br/>You grab the mug o'beer triumphantly, and down it and a macho man fashion.")
game.drink = default
} - close
} - close
if (game.drink = Beer) { - open
if (game.money >= 3) { - open
msg ("Henry slams the mug of beer onto the counter.<br/>\"That will be three bucks, tiny!\" he shouts.")
wait { - open
game.money = game.money - 3
msg ("You flip three bucks onto the counter.<br/>You grab the mug o'beer triumphantly, and down it and a macho man fashion.")
game.drink = default
} - close
} - close
The Pixie
04 Jun 2016, 16:26It is this line:
if (game.drink = Beer) {
Beer is a string, so needs to go in double quotes (and the same for the other drinks too):
if (game.drink = "Beer") {
if (game.drink = Beer) {
Beer is a string, so needs to go in double quotes (and the same for the other drinks too):
if (game.drink = "Beer") {
HegemonKhan
05 Jun 2016, 00:02here's a post on/about the syntaxing of Values and Attributes and what Attributes to use:
viewtopic.php?f=10&t=6381#p43250
viewtopic.php?f=10&t=6381#p43250