find value in variable

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

DittoNut

Member
Mar 11, 2024
4
0
1
hi Skript, i have a variable like
{group::a} = "CuteMouse,TomCat,AmazingFrog"

and i need to find like:
find in group with {_value}:
return {_value} contain "AmazingFrog"
 
I think I see what they are wanting. They're trying to find if the variable they have contains a certain bit of text. With the way they have things set up it will be possible, but it would be easier to use a list instead of a csv (comma-separated value) format. Here's something you can try:
Code:
set {_list::*} to ("%{group::a}%" split at ",")
if {_list::*} contains "AmazingFrog":
  do stuff
else:
  send "Frog not found" to console

If you had set the variable to just be a list in the first place, it will be a lot easier:
Code:
# Put this wherever you had set {group::a} beforehand
set {group::a::*} to "CuteMouse", "TomCat", and "AmazingFrog"

# Then, when you need to check the list
if {group::a::*} contains "AmazingFrog":
  do stuff
else:
  send "Frog not found" to console