How to set variable to itself plus one through code #1326
-
I know that in the timeline editor of Dialogic, you can do Set Value > (Value) > to itself plus > (insert number). But I am using a custom button where I intend to do the above through code. How would I do it? So far I have tried: Attempt 1int(Dialogic.set_variable('story_passage', +1)) Attempt 2onready var story_passage = int(Dialogic.get_variable('story_passage')) func _on_Next_pressed(): Both of these attempts didn't work. I wanted to know if there is a way to do what you can in the editor but through code as I am using a button to achieve it. I know how to achieve: Set Value to be () by doing it like this | Dialogic.set_variable('story_passage', something) but I am completely stumped on how to achieve the rest. Set Value to be itself plus |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Okay, I solved the issue. It was because I wasn't saving it properly in my new scene. Here I'll post my code in case someone else has another question similar to this. // This converts string into integer // This will check what the number is and display the prompt (I have this match function within a process func to update constantly), you can also just have another func that will update when the variable is changed. // This is a button which increases the number by one and set the new value. |
Beta Was this translation helpful? Give feedback.
Okay, I solved the issue. It was because I wasn't saving it properly in my new scene. Here I'll post my code in case someone else has another question similar to this.
// This converts string into integer
onready var story_passage = int(Dialogic.get_variable('story_passage'))
// This will check what the number is and display the prompt (I have this match function within a process func to update constantly), you can also just have another func that will update when the variable is changed.
match story_passage:
0:
$RichTextLabel.bbcode_text = 'hello world'
// This is a button which increases the number by one and set the new value.
func _on_Next_pressed():
story_passage += 1
Dialogic.set_va…