Adding cases to switch syntax

XanMag
16 Feb 2016, 02:11Which is the most efficient way to add cases to a switch script?
"changing player health","change player health","changeplayerhealth","changehealth","change health"
Are the spaces required/needed?
Are added cases similar to command expressions? Is "change health" = "changehealth" = "chan health"?
If 'chan play heal' was typed in, would it get matched above? Would "common scripts" = "common scripts room"?
Would a selection with "if then else room" produce an error if a difference case had "if else room"?
Just trying to save time here before I get too deep!
Thanks!
"changing player health","change player health","changeplayerhealth","changehealth","change health"
Are the spaces required/needed?
Are added cases similar to command expressions? Is "change health" = "changehealth" = "chan health"?
If 'chan play heal' was typed in, would it get matched above? Would "common scripts" = "common scripts room"?
Would a selection with "if then else room" produce an error if a difference case had "if else room"?
Just trying to save time here before I get too deep!
Thanks!
The Pixie
16 Feb 2016, 13:15Switch looks for an exact match, so yes, you need the spaces. However, you could test against true, and use IsRegexMatch:
The "chan.*health" is a regular expression that will match anything like that, where the .* bit matches anything (or nothing).
switch (true) {
case (IsRegexMatch("chan.*health", s)) {
msg("here")
}
default {
msg("not here")
}
}
The "chan.*health" is a regular expression that will match anything like that, where the .* bit matches anything (or nothing).

XanMag
16 Feb 2016, 15:22Oooh. Nice. Thanks!