Having issue with Condition #98
|
Sorry to keep opening new threads but I figure keeping them distinct makes them easier to find for new people coming from e.g. Ren'py. I'm not able to get day_1.action([
// ...
Condition
// None of these work.
// .If(state.equals("laura_mood", 10),
// .If(state.evaluate("laura_mood", (mood) => mood > 9),
.If(state.isTrue("is_lost"),
[chars.laura.say`1`])
// Else doesn't work either.
// Tried leaving off the Else also.
.Else([chars.laura.say`2`]),
// This happens though.
chars.laura.say`3`I attached my full source. Related: is there a way to have a conditional menu choice? E.g. in Ren'py: menu:
"Which way should we go?"
# Don't let player choose "Left" if you're already lost
"Left" if state.laura.mood > 8 :
jump l_day_1_menu_left
"Right" :
jump l_day_1_menu_rightLikewise, is there a way to show a menu choice but disable it (e.g. if the player doesn't have the right stats to perform a certain action but you want to let them know it's possible)? I tried this, but it doesn't work because I can't get Conditional to work: function get_menu(can_stay_lost : boolean) {
let menu =
Menu.prompt("Which way?")
.choose(("Go home"), [
chars.laura.say`Thank God!`
])
if (true === can_stay_lost) {
return menu.choose(("Stay lost"), [
chars.laura_images.happy.hide({ duration : 1000 }),
day_1.jumpTo(day_2, new FadeIn(3000)),
])
}
else {
return menu;
}
}
day_1.action([
// ...
Condition
.If(state.evaluate("laura_mood", (mood) => mood > 9),
[get_menu(true)])
.Else([get_menu(false)]),
// ...If that isn't possible yet, I can try to make a PR, I just thought I'd ask in case I'm overlooking something. Thank you as always! |
Replies: 5 comments
|
Starting a new thread is absolutely fine! In fact, I really appreciate everything you’ve done. The growth of a product always relies on testing and feedback, and your thoughts are both practical and insightful. Regarding the issue with As for the Thanks again for everything you’ve contributed! |
|
The issue with This issue was caused by incorrect usage of the stack model. The This error caused all actions to not be executed. Thank you again for raising this issue! |
|
Thank you! That works and I'm now able to have a conditional menu item with, for example: function get_menu(scene : Scene) {
let menu =
Menu.prompt("Which way?")
.choose("Go home", [
chars.laura.say`Thank God!`
// 20250909 The end
])
return Condition
.If(state.evaluate("laura_mood", (mood) => mood < 10),
[menu])
.Else([menu.choose("Stay lost", [
chars.laura_images.happy.hide({ duration : 1000 }),
scene.jumpTo(day_2, new FadeIn(3000)),
])]);
} |
|
Let me announce something exciting! Now let's rewrite your old script: function get_menu(scene : Scene) {
let menu =
Menu.prompt("Which way?")
.choose("Go home", [
chars.laura.say`Thank God!`
// 20250909 The end
])
return Condition
.If(state.evaluate("laura_mood", (mood) => mood < 10),
[menu])
.Else([menu.choose("Stay lost", [ // THIS IS UNSAFE
chars.laura_images.happy.hide({ duration : 1000 }),
scene.jumpTo(day_2, new FadeIn(3000)),
])]);
}to: Menu.prompt("Which way?")
.choose("Go home", [
chars.laura.say`Thank God!`
])
.showWhen(
state.evaluate("laura_mood", (mood) => mood >= 10),
"Stay lost",
[
character1_images.happy.hide({ duration : 1000 }),
scene1.jumpTo(scene2, new FadeIn(3000)),
]
),Even more concisely: Menu.prompt("Which way?")
.choose("Go home", [
chars.laura.say`Thank God!`
])
.choose("Stay lost", [
character1_images.happy.hide({ duration : 1000 }),
scene1.jumpTo(scene2, new FadeIn(3000)),
]).hideIf(state.evaluate("laura_mood", (mood) => mood < 10))Add these directly to All of these things require the latest version of narraleaf-react, use |
|
A huge thank you! It works great! Very helpful that you can also apply it to any menu item in the chain. Menu.prompt("Which way?")
.choose("Go home", [
chars.laura.say`Thank God!`
])
.hideIf(state.evaluate("laura", (laura) => laura.mood.current >= 10))
.choose("Stay lost", [
chars.laura_images.happy.hide({ duration : 1000 }),
day_1.jumpTo(day_2, new FadeIn(3000)),
])
.hideIf(state.evaluate("laura", (laura) => laura.mood.current < 10)) |
The issue with
Conditionnot working has been fixed in version 0.8.2. Update to the latest version usingnpm i narraleaf-react@latest.This issue was caused by incorrect usage of the stack model. The
condition:actionaction incorrectly usedliveGame.createStackModelto create a new stack model. Instead, the action to be executed should be pushed onto the stack by simply returning the actions.This error caused all actions to not be executed. Thank you again for raising this issue!