Is there a command in choicescript for checking whether a variable contains something?
For instance if I had a variable with a value of “abcdef”, is there a way to check whether the variable contains the character “b”?
*if var CONTAINS “b”.
I haven’t been able to find anything on the ChoiceScript Wiki or here on the forums so I thought I would just ask. Thanks!
I believe you could make a loop and check the string char by char, but I haven’t actually tried.
Cslib is a collection of pluggable, ready to use subroutines. In the cslib_string
module you have three subroutines that could help you achieve what you want: find, index and contains. Contains being the one that best fit your use case.
4 Likes
CJW
December 19, 2023, 11:25pm
5
Example:
*create mystr "abcef"
*gosub_scene cslib_string contains mystr "b"
*if cslib_ret
Contains b!
3 Likes
Thank you! This is exactly what I was after - I will try it out and let you know how it goes.
system
Closed
December 21, 2023, 11:53am
7
This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.