Logo

[Help] I need help with a pattern.

登録 ログイン フォーラム戻る

ポスト #1 · 2016-07-27 11:00:35pmにポスト 7.7年前

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 ポスト
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

ポスト #2 · 2016-07-28 12:05:49amにポスト 7.7年前

Offline MadkaT
MadkaT Avatar Member
820 ポスト
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.

ポスト #3 · 2016-07-28 05:53:47pmにポスト 7.7年前

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 ポスト
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

ポスト #4 · 2016-07-29 01:53:43amにポスト 7.7年前

Offline MadkaT
MadkaT Avatar Member
820 ポスト
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

ポスト #5 · 2016-07-29 06:45:35pmにポスト 7.7年前

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 ポスト
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
登録 ログイン フォーラム戻る

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

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 3% · Database: 12% · Server Time: 2024-05-02 16:31:25
このページは0.002秒サーバータイム使用する。
Theme: starlight · Language: japanese
Reset Theme & Language