Logo

[Help] I need help with a pattern.

Register Log In Back To Forums

Post #1 · Posted at 2016-07-27 11:00:35pm 7.7 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
I am doing something on my theme, and I got stuck on the following: I need that using string.match, I match the exact pattern, those patterns are "1000", "0100", "0010" and "0001" at the moment. And im not sure how to do it properly. This cuz, I am having falses matches due to the string I am using to match contains 1s and 0s. But I want the exact pattern. Not cuz the string contain 1s and 0s in any order.

In short I wanna match: "1000" and not "0001" cuz the string contains just the 1 and 0 on it.

Im not sure if I explained it correctly. Anyway, any help is very appreciated.
PD: I am doing something that involves the Song's charts, thats why "1000", "0100", etc.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #2 · Posted at 2016-07-28 12:05:49am 7.7 years ago

Offline MadkaT
MadkaT Avatar Member
820 Posts
Not Set
Reg. 2009-11-24

If you are searching just one step in a row, could test this:

string.match("0010", '(1+)')


If returns a value bigger than 1 it includes multiple steps.

I you need to test if the string starts with '10'

string.match("1100", '^10')


If returns something, the string starts with 10, if not i will return a nil value.

Post #3 · Posted at 2016-07-28 05:53:47pm 7.7 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
No, I am not trying to match a step on a line/row. I am trying to identify every arrow on a stepchart. That's why I need to match the exact pattern to identify what Arrow it is.

1000 > Left
0100 > Down
0010 > Up
0001 > Right

Thats why, the pattern "10", will match the four lines, etc.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #4 · Posted at 2016-07-29 01:53:43am 7.7 years ago

Offline MadkaT
MadkaT Avatar Member
820 Posts
Not Set
Reg. 2009-11-24


Last updated: 2016-07-29 01:54am
Then you can ask the position of the arrow, and determine the direction with the result

local position = string.find("0100", '1');
return position;


In this case 1 = Left
2 = Down
3 = Up
4 = Right

Post #5 · Posted at 2016-07-29 06:45:35pm 7.7 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
Quote: MadkaT
Then you can ask the position of the arrow, and determine the direction with the result

local position = string.find("0100", '1');
return position;


In this case 1 = Left
2 = Down
3 = Up
4 = Right

Right, the solution was always so simple. Thanks you a lot.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 4% · Database: 4% · Server Time: 2024-04-16 21:50:21
This page took 0.006 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language