# AddTimeEvent

일정 시간 후에 원하는 함수를 등록해주는 방법이에요.

***

## 일정 시간 후 실행할 함수 등록

원하는 함수를 만들고, AddTimeEvent 함수를 사용해 일정 시간 후 실행되도록 등록해요.

* AddTimeEvent("등록할 이름", 대기 시간, 실행할 함수)

```lua
local WaitTime = 1

local function TimeChecker() --원하는 함수를 만들어요.
    print("1 second passed")
end
Game:AddTimeEvent("TimeCheck", WaitTime, TimeChecker)
--"TimeCheck"라는 이름으로 waitTime 후에 실행할 TimeChecker 함수를 등록해요.
```

***

## 일정 시간을 주기로 함수 호출하기

```lua
local PassedTime = 0
local WaitTime = 1

local function TimeChecker()
    PassedTime = PassedTime + 1
    print(PassedTime .. " second passed")

    if PassedTime == 10 then --조건을 주어 반복을 멈춰요.
        return
    end
		
    --waitTime 후 호출할 함수를 등록해요.		
    Game:AddTimeEvent("TimeCheck", WaitTime, TimeChecker) 
end
Game:AddTimeEvent("TimeCheck", WaitTime, TimeChecker) 
--waitTime 후 호출할 함수를 등록해요.
```

***

## 등록한 함수 제거하기 (DeleteTimeEvent)

DeleteTimeEvent 함수를 이용해 등록한 함수를 제거할 수 있어요.

* DeleteTimeEvent("등록한 함수 이름")

```lua
local WaitTime = 1

local function TimeChecker()
    print("1 second passed")
end
Game:AddTimeEvent("TimeCheck", WaitTime, TimeChecker) 
--waitTime 후 실행할 함수를 등록해요.

Game:DeleteTimeEvent("TimeCheck") --등록한 함수를 제거해요.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ditoland-utplus.gitbook.io/ditoland/manual/addtimeevent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
