DS 맵 비어있는지 확인하기
ds_map_empty
함수는 지정된 데이터 구조(이전에 생성된 DS 맵)가 키/값 쌍을 포함하고 있는지 확인하여, 포함하고 있지 않으면 true
, 포함하고 있으면 false
를 반환합니다.
문법
ds_map_empty(id);
인수 설명
인수 | 타입 | 설명 |
---|---|---|
id | 데이터 구조 핸들 | 확인할 데이터 구조의 핸들입니다. |
반환값
- 키/값 쌍이 없으면
true
- 키/값 쌍이 있으면
false
예제
if (ds_map_empty(inventory)) {
weight = 0;
}
위 코드는 "inventory" 변수에 인덱스된 DS 맵이 키/값 쌍을 포함하고 있는지 확인하고, 포함하지 않으면 "weight" 변수를 0으로 설정합니다.
활용 예제
- 게임 아이템 관리
gml if (ds_map_empty(player_items)) { show_message("아이템이 없습니다."); } else { show_message("아이템이 있습니다."); }
- 퀘스트 진행 확인
gml if (ds_map_empty(active_quests)) { show_message("현재 진행 중인 퀘스트가 없습니다."); } else { show_message("진행 중인 퀘스트가 있습니다."); }
- 상점 재고 확인
gml if (ds_map_empty(shop_inventory)) { show_message("상점에 재고가 없습니다."); } else { show_message("상점에 재고가 있습니다."); }
- 플레이어의 상태 확인
gml if (ds_map_empty(player_status)) { show_message("플레이어 상태가 비어 있습니다."); } else { show_message("플레이어 상태가 존재합니다."); }
- 레벨 업 조건 확인
gml if (ds_map_empty(level_up_requirements)) { show_message("레벨 업 조건이 없습니다."); } else { show_message("레벨 업 조건이 있습니다."); }