if ( GetBoolean(suitcase, "onbed") ) {
s1 = "onbed"
} else {
s1 = "offbed"
}
if (GetBoolean(clock, "ringing")) {
s2 = "ringing"
} else {
s2 = "silent"
}
picturename = "picture_" + s1 + "_" + s2 + ".jpg"
if (color_1 = "red" and color_2 = "blue") {
color = "purple"
} else if (color_1 = "red" and color_2 = "yellow") {
color = "orange"
} else if (color_1 = "blue" and color_2 = "yellow") {
color = "green"
}
if (player.status_effects_string = "poisoned") {
player.hp = player.hp - 50 // per turn, obviously this needs a lot more coding, so just pretend here as it's only an example
} else if (player.status_effects_string = "confused") {
// blah script
}
OR
player.status_effects_stringlist = NewStringList ()
list add (player.status_effects_stringlist, "poisoned")
list add (player.status_effects_stringlist, "confused")
list remove (player.status_effects_stringlist, "poisoned")
if (ListContains (player.status_effects_stringlist, "poisoned") {
player.hp = player.hp - 50 // per turn, obviously this needs a lot more coding, so just pretend here as it's only an example
}
Jay wrote:if ( GetBoolean(suitcase, "onbed") ) {
s1 = "onbed"
} else {
s1 = "offbed"
}
if (GetBoolean(clock, "ringing")) {
s2 = "ringing"
} else {
s2 = "silent"
}
picturename = "picture_" + s1 + "_" + s2 + ".jpg"
jaynabonne wrote:The trick is to identify what the conditions are, and then you can both key off them to update the picture and know which state to check for changes to know *when* to update.
When you listed the pictures, it seems you have "suitcase on bed" as one condition (where the alternative is not). The other condition is less clear, since the picture has it missing. Do you knock it off the desk when you turn it off? Is it still in the room? The reason I'm asking is that if the clock disappears, then you can just check its parent to see if it's still there. Otherwise, you can just have a boolean attribute on the clock for "ringing" or not.
One way to handle the picture is to have "if"'s. The other is to encode the state into the name. (This is all just to show the pattern. You can use whatever names you like.)if ( GetBoolean(suitcase, "onbed") ) {
s1 = "onbed"
} else {
s1 = "offbed"
}
if (GetBoolean(clock, "ringing")) {
s2 = "ringing"
} else {
s2 = "silent"
}
picturename = "picture_" + s1 + "_" + s2 + ".jpg"
Then you'd have four pictures:
picture_ringing_onbed.jpg
picture_ringing_offbed.jpg
picture_silent_onbed.jpg
picture_silent_offbed.jpg
Though, I'm not sure why you would have the "ringing/onbed" case if you can't move the suitcase onto the bed until you have shut off the clock...
As far as updating the picture when they change, you can use "changed" scripts to automatically update the picture when the state changes (e.g. a "changedonbed" script on suitcase and "changedringing" on the clock).
if (GetBoolean(alarm clock, "taken")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture2.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture3.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (not GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture4.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (IsSwitchedOn(ringing alarm clock)) {
msg ("You wake up to the sound of an alarm clock which keeps ringing annoyingly every half a minute! The sound it is making is intolerable, but at least you are awake for your first day at school.<br/>---")
play sound ("Old Alarm Clock Sound - Ringing - Made in Germany 1920's - 30's..mp3", false, true)
}
else if (not GetBoolean(suitcase, "moved") and not IsSwitchedOn(ringing alarm clock) and not GetBoolean(alarm clock, "taken")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
Mareus wrote:"jaynabonne"
The trick is to identify what the conditions are, and then you can both key off them to update the picture and know which state to check for changes to know *when* to update.
When you listed the pictures, it seems you have "suitcase on bed" as one condition (where the alternative is not). The other condition is less clear, since the picture has it missing. Do you knock it off the desk when you turn it off? Is it still in the room? The reason I'm asking is that if the clock disappears, then you can just check its parent to see if it's still there. Otherwise, you can just have a boolean attribute on the clock for "ringing" or not.
One way to handle the picture is to have "if"'s. The other is to encode the state into the name. (This is all just to show the pattern. You can use whatever names you like.)if ( GetBoolean(suitcase, "onbed") ) {
s1 = "onbed"
} else {
s1 = "offbed"
}
if (GetBoolean(clock, "ringing")) {
s2 = "ringing"
} else {
s2 = "silent"
}
picturename = "picture_" + s1 + "_" + s2 + ".jpg"
Then you'd have four pictures:
picture_ringing_onbed.jpg
picture_ringing_offbed.jpg
picture_silent_onbed.jpg
picture_silent_offbed.jpg
Though, I'm not sure why you would have the "ringing/onbed" case if you can't move the suitcase onto the bed until you have shut off the clock...
As far as updating the picture when they change, you can use "changed" scripts to automatically update the picture when the state changes (e.g. a "changedonbed" script on suitcase and "changedringing" on the clock).
Well I read both of your comments and this is what I made so far:if (GetBoolean(alarm clock, "taken")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture2.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture3.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (not GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture4.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
else if (IsSwitchedOn(ringing alarm clock)) {
msg ("You wake up to the sound of an alarm clock which keeps ringing annoyingly every half a minute! The sound it is making is intolerable, but at least you are awake for your first day at school.<br/>---")
play sound ("Old Alarm Clock Sound - Ringing - Made in Germany 1920's - 30's..mp3", false, true)
}
else if (not GetBoolean(suitcase, "moved") and not IsSwitchedOn(ringing alarm clock) and not GetBoolean(alarm clock, "taken")) {
ClearScreen
picture ("bedroom-cool-idea-of-dorm-room-nuanced-in-blue-and-white-even-wooden-furniture.jpg")
msg ("You are standing in a small bedroom with glossy wooden floor and boring white walls. Despite its size the room is more than adequete for an aspiring student such as yourself and it offers everything you might need.<br/><br/>Not only do you have your own bed and your very own wooden desk with drawers both to the left and right, but there is also a sturdy old chair and a garbage bin next to it. The wardrobe on the opposite wall connects seamlessly with a nearby bookshelf and the room even has a big window which is decorated with beautiful red curtains and some flowers in a vase.<br/><br/>In short it really seems to be in mint condition, although it does suffer from that feminine touch that is so characteristic for your landlady.<br/>---")
}
Unfortunately when I turn off the clock and I finally get to the point when the game opens, I keep getting the wrong picture and I don't understand why.
if (GetBoolean(alarm clock, "taken")) {
// Some code
}
else if (GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
// Some other code
}
if (GetBoolean(alarm clock, "taken")) {
// taken case
if (GetBoolean(suitcase, "moved")) {
// taken and moved case
} else {
// taken and not moved case
}
} else {
// not taken case
if (GetBoolean(suitcase, "moved")) {
// not taken and moved case
} else {
// not taken and not moved case
}
}
jaynabonne wrote:I'm glad it's working for you. Just a small note about the code you posted. Perhaps it will help:if (GetBoolean(alarm clock, "taken")) {
// Some code
}
else if (GetBoolean(alarm clock, "taken") and GetBoolean(suitcase, "moved")) {
// Some other code
}
If the alarm clock is taken, then it will always go down the first branch. It will never get to the second. You could solve it by reversing the blocks (so the more specific check happens first). You could also break it down like this:if (GetBoolean(alarm clock, "taken")) {
// taken case
if (GetBoolean(suitcase, "moved")) {
// taken and moved case
} else {
// taken and not moved case
}
} else {
// not taken case
if (GetBoolean(suitcase, "moved")) {
// not taken and moved case
} else {
// not taken and not moved case
}
}