Hi there.
I'm having problems accessing a variable outside of an if statement. I'll try to explain a bit clearer....
I have 2 characters I play, and for breaky they both drink 9 bottles of the dusty wine that gives 5-7 adventures. The bottle is different for each character, so I do an if statement to identify who I am, then set the variable "dusty" accordingly. I then call the function "booze", and pass it the variable "dusty".
The problem I have is that if I call the function "booze" outside of the if statement, I receive an error saying "Unknown variable 'dusty' " (As in the code attached).
However, if I call the booze function immediately after I set the variable (within the if statement), it works. For some reason, it isn't passing the dusty variable beyond the if statement. I know the easy answer is to just do it this way, as it works.. but it just seems messy, and I want to use the variable more.
Does anyone have any ideas or recommendations? Any help is appreciated.
Thanks.
I'm having problems accessing a variable outside of an if statement. I'll try to explain a bit clearer....
I have 2 characters I play, and for breaky they both drink 9 bottles of the dusty wine that gives 5-7 adventures. The bottle is different for each character, so I do an if statement to identify who I am, then set the variable "dusty" accordingly. I then call the function "booze", and pass it the variable "dusty".
The problem I have is that if I call the function "booze" outside of the if statement, I receive an error saying "Unknown variable 'dusty' " (As in the code attached).
However, if I call the booze function immediately after I set the variable (within the if statement), it works. For some reason, it isn't passing the dusty variable beyond the if statement. I know the easy answer is to just do it this way, as it works.. but it just seems messy, and I want to use the variable more.
Does anyone have any ideas or recommendations? Any help is appreciated.
Thanks.
Code:
///// Breakfast /////
void booze(item dusty) {
if(my_inebriety() == 0) {
if ( item_amount(dusty) < 9 ) {
buy((9 - item_amount(dusty)), dusty);
}
drink(9, dusty);
}
}
void main() {
if (my_name() == "Character1" ) {
item dusty = $item[dusty bottle of Pinot Noir];
}
if (my_name() == "Character2") {
item dusty = $item[dusty bottle of Marsala];
}
booze(dusty);
}