순정도 좋은데 개조해서 쓰니까 편하길래 소개하려고 함

모드 관리하는 방식이 일관적인 경우에 가져가서 입맛대로 바꿔서 사용하면 좋을것 같음

py파일 그냥 공유할까 하다가 스크립트다 보니 방법 소개만 하는게 나을것 같아서 코드 캡쳐랑 붙여넣을 코드 조각 두가지 같이 적겠음



1. 모드가 여러개인 경우 'all' 입력으로 한꺼번에 배열에 넣기

namespace.py는 리스트에서 머지할 모드들을 고르도록 되어있는데

나같은 경우는 아예 머지 안할 모드는 별도 폴더에 보관하고 있어서 그럴 필요가 사실 없음

전부 다 머지할건데 모드가 한두개면 그냥 입력하겠지만 10개쯤만 되어도 다 입력하기 매우 귀찮아서 짰음


맨처음 숫자 입력 받을때 all 입력하고, 처음 시작할 인덱스까지 지정하면 그것부터 배열이 시작됨

예를 들어 20개중에 10번째 모드다 하면 10을 입력하면 순서가 10, 11, 12, ..., 20, 1, 2, 3, ... 이런 순서로 됨

바닐라인 0은 제외하도록 짰음 넣고 싶으면 ini_files[1:start_index]에서 1 지우면 됨

만약 수동으로 하고 싶으면 all 입력 안하고 기존 방식 그대로 하면 됨

 



        if choice == ["all"]:  # Special case for "all"

            start_index = input("Enter the starting index or press enter to start from the first index: ").strip()

            if start_index.isdigit():  # Validate that input is a digit and within range

                start_index = int(start_index)

                if 1 <= start_index < len(ini_files):

                    # Rotate list to start at the index specified and exclude the first index

                    return ini_files[start_index:] + ini_files[1:start_index]

                else:

                    print("\nERROR: Index out of range or is the first index. Please enter a valid index from 1 to {}.\n".format(len(ini_files)-1))

            elif start_index == "":  # If no starting index is specified, return the list excluding the first index

                return ini_files[1:]

            else:

                print("\nERROR: Invalid input. Please enter a numeric index.\n")



2. 리스팅 제외할 문자열 추가

캐릭터 본체 외에 무기나 날개 같은 것들도 모드로 넣는 경우가 많은데 그럴때 한 폴더에 넣고 돌리면 걔네들까지 다 잡히게 됨

그래서 그것들은 다른 폴더에 빼놓고 돌리거나 리스트에서 수동으로 제외시켜야 해서 매우 귀찮음

거기다 삭제할때 까먹고 그냥 날려버리면 더 귀찮아지기때문에.. 그냥 리스트에서 빼버림


기존에는 disabled 문자열 하나만 제외하도록 되어있었는데 저 부분을 배열로 수정하면 됨

제외할 문구를 수정할게 있으면 ["disabled", "extra", "weapon", "glider"] 이 배열을 수정하면 되겠음

예를 들어 나는 'aaa'도 제외하고 싶다 하면 ["disabled", "extra", "weapon", "glider", "aaa"] 이런 식으로



if any(substring in root.lower() for substring in ["disabled", "extra", "weapon", "glider"]):



3. 이름이랑 토글키 자동 지정

나는 무조건 Master이름은 캐릭터 이름이고, 캐릭터 토글키는 ],[이기 때문에 매번 입력하기 귀찮아서 자동으로 드가도록 함

그리고 모드가 여러개인 경우 < '캐릭터 이름' integrated > 폴더 하위에 < '캐릭터 이름' '모드 이름' > 폴더로 되도록 이름들을 전부 맞춰둠

예를 들어 라이덴인 경우 Raiden integrated 하위에 Raiden Mei, Raiden Acheron 이런 식으로 되어있음


그래서 현재 디렉토리 이름을 가져온다음 공백으로 분할해서 첫번째 인덱스를 가져오면 무조건 캐릭터 이름이 되기 때문에 여기서 가져옴

만약 'integrated'가 포함되지 않은 경우 무기나 다른 경우로 간주하고 기존대로 이름이랑 토글키를 지정하게 함


이번에 수정할 부분은 두군데임 위가 메인 부분이고 아래는 위에서 호출한 메소드를 정의하는 부분




time.sleep(1)은 1초 대기하는 코드인데 이름이랑 토글키가 제대로 되었나 확인하려고 넣음 

사용하려면 라이브러리 추가가 필요하고 필요 없으면 안넣어도 무방함



----


print("\nPlease enter the name of the object this merged mod is for (no spaces)\n")

    name = get_name_from_current_directory()

    if name is None:

        print("\nPlease enter a name\n")

        name = input()

     # key, back macro

    

    current_dir_name = os.path.basename(os.getcwd())

    if 'integrated' in current_dir_name.lower():

        key = ']'

        back = '['

    else:

        key, back = get_key_from_user()

    print(f"Key to cycle mods: {key}")

    print(f"Key to cycle mods backwards: {back}")

    

    time.sleep(1)

    

----------


def get_name_from_current_directory():

    current_dir_name = os.path.basename(os.getcwd())

    if 'integrated' in current_dir_name.lower():

        name_parts = current_dir_name.split()

        if name_parts:

            print(f"Master Name: {name_parts[0]}")

            return name_parts[0]

    return None

    

def get_key_from_user():

    print("\nPlease enter the key that will be used to cycle mods. Key must be a single letter\n")

    key = input().strip()

    while not key or len(key) != 1:

        print("\nKey not recognized, must be a single letter\n")

        key = input().strip()

    key = key.lower()


    print("\nPlease enter the key that will be used to cycle mods backwards. Key must be a single letter\n")

    back = input().strip()

    while not back or len(back) != 1:

        print("\nKey not recognized, must be a single letter\n")

        back = input().strip()

    back = back.lower()


    return key, back




내용은 이상임

커스터마이징하기 쉽도록 코드 메커니즘까지 상세하게 설명하려고 노력했는데 혹시 질문있으면 댓글 바람

감사합니다