Why isn't this working? I start in a room without the flag, then I take the bottle and try to fill it. This should get the response "There is no water here", but I just get a blank response.
if (Got(empty water bottle)) {
if (GetBoolean(player, "water")) {
msg ("You fill the bottle.")
}
}
else {
if (Got(empty water bottle)) {
if (not GetBoolean(player, "water")) {
msg ("There is no water here.")
}
}
}
Edit.
Sorry, I know I do a lot of this (answering my own questions, I mean) but it's just the way I work.
The mistake I was making in the above script was having the second rule set as an 'else' when it should have been another 'if'.
I always wondered why there wasn't a way to say "If bla bla bla AND bla bla bla then print "bla bla bla". But now I think I understand that a series of simple ifs does this.
This is the modified script and covers all combinations concerning source and whether the player is carrying the bottle or not.
if (Got(empty water bottle)) {
if (GetBoolean(player, "water")) {
msg ("You fill the bottle.")
}
}
if (Got(empty water bottle)) {
if (not GetBoolean(player, "water")) {
msg ("There is no water here.")
}
}
if (not Got(empty water bottle)) {
if (GetBoolean(player, "water")) {
msg ("You don't have a bottle.")
}
}
Just need to work out the script for the 'drink' command and how to diminish the supply on 'drink' so that it's reflected in the inventory. I don't know anything about Integers.
In fact... brainwave! I'm going to make the supply a simple 'one drink and it's gone' affair, rather than a fancy diminishing supply. Then I only need to handle whether the bottle is full or empty.