current_day 변수 설명
current_day
는 읽기 전용 변수로, 현재 날짜의 일을 1부터 31까지의 값으로 반환합니다. 이 값은 현재 월에 따라 달라집니다.
문법
current_day;
반환값
- 현재 날짜의 일(1~31)
예제
아래 코드는 현재 날짜의 일, 월, 연도를 화면에 출력합니다.
draw_text(32, 32, "Today is " + string(current_day) + "/" + string(current_month) + "/" + string(current_year) + ".");
위 코드를 실행하면 "Today is X/Y/Z" 형식으로 현재 날짜가 표시됩니다.
활용 예제
예제 번호 | 설명 | 코드 스니펫 |
---|---|---|
1 | 현재 날짜를 텍스트로 표시하기 | gml draw_text(32, 32, "Today is " + string(current_day)); |
2 | 날짜에 따라 다른 메시지 출력하기 | gml if (current_day == 1) { draw_text(32, 32, "It's the first day of the month!"); } |
3 | 특정 날짜에 이벤트 발생시키기 | gml if (current_day == 15) { // 이벤트 코드 } |
4 | 날짜를 기반으로 게임 내 보상 주기 | gml if (current_day % 7 == 0) { // 보상 코드 } |
5 | 날짜를 파일에 저장하기 | gml var file = file_text_open_write("date.txt"); file_text_write_string(file, string(current_day)); file_text_close(file); |
이와 같이 current_day
변수를 활용하여 다양한 기능을 구현할 수 있습니다.