# API Summary

## :mag:<mark style="color:blue;">Ctrl + F를 이용해 원하는 API를 찾아보세요!</mark>

## ═════════════════════

## 🕹️ ScriptApp&#x20;

## ═════════════════════

## ♻️ Lifecycle

### [onInit](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#oninit)

{% hint style="info" %}
&#x20;App.onInit.Add(function(){})
{% endhint %}

App이 최초로 시작될 때 한 번 호출됩니다.

### [onJoinPlayer](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#onjoinplayer)

{% hint style="info" %}
App.onJoinPlayer.Add(function(player){})
{% endhint %}

onInit이 호출된 후, 접속해 있는 모든 플레이어를 해당 이벤트를 통해 입장시키고, 이후 입장하는 플레이어가 있을 때 마다 동작합니다.

### [onStart](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#onstart)

{% hint style="info" %}
App.onStart.Add(function(){})
{% endhint %}

모든 플레이어가 onJoinPlayer를 통해 입장한 후 한 번 호출 됩니다.

### [onUpdate](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#onupdate)

{% hint style="info" %}
App.onUpdate.Add(function(dt){})
{% endhint %}

약 20ms 마다 주기적으로 실행되는 함수입니다.

### [onLeavePlayer](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#onleaveplayer)

{% hint style="info" %}
&#x20;App.onLeavePlayer.Add(function(player){})
{% endhint %}

퇴장하는 플레이어가 있을 때 마다 동작합니다. 이후, 다른 App이 실행되거나 설치한 Game Block이 파괴될 때 모든 플레이어를 이 함수를 통해 퇴장시킵니다.

### [onDestroy](https://docs-kr.zep.us/zep-script-api/scriptapp/lifecycle#ondestroy)

{% hint style="info" %}
App.onDestroy.Add(function(){})
{% endhint %}

다른 App이 실행되거나, 설치한 Game Block이 파괴될 때 동작합니다.

## 🗃️ Field

### [spaceHashID & mapHashID](https://docs-kr.zep.us/zep-script-api/scriptapp/field#spacehashid-and-maphashid)

{% hint style="info" %}
App.spaceHashID: String \
App.mapHashID: String
{% endhint %}

앱이 설치된 스페이스의 spaceHashID와 mapHashID를 가져옵니다. [<mark style="color:purple;">(스페이스와 맵 이해하기)</mark>](https://docs-kr.zep.us/creator/reference/undefined)

### [creatorID](https://docs-kr.zep.us/zep-script-api/scriptapp/field#creatorid)

{% hint style="info" %}
App.creatorID
{% endhint %}

App을 실행한 플레이어의 ID 값을 가져옵니다.

### [players](https://docs-kr.zep.us/zep-script-api/scriptapp/field#players)

{% hint style="info" %}
App.players: ScriptPlayer\[]
{% endhint %}

맵에 있는 모든 플레이어 리스트를 배열로 가져옵니다.

### [playerCount](https://docs-kr.zep.us/zep-script-api/scriptapp/field#playercount)

{% hint style="info" %}
App.playerCount: Number
{% endhint %}

앱이 설치된 맵에 있는 플레이어의 수를 가져옵니다.

### [cameraEffect & cameraEffectParam1](https://docs-kr.zep.us/zep-script-api/scriptapp/field#cameraeffect-and-cameraeffectparam1)

{% hint style="info" %}
App.cameraEffect: NONE = 0, SPOTLIGHT = 1 \
App.cameraEffectParam1: Number
{% endhint %}

App.cameraEffect: 카메라 이펙트의 종류를 셋팅할 변수 값

App.cameraEffectParam1: 카메라 이펙트 효과의 범위 값

### [displayRatio](https://docs-kr.zep.us/zep-script-api/scriptapp/field#displayratio)

{% hint style="info" %}
App.displayRatio
{% endhint %}

화면의 줌을 컨트롤 하는 값 (기본 값: 1)

### [storage](https://docs-kr.zep.us/zep-script-api/scriptapp/field#storage)

{% hint style="info" %}
App.storage: String
{% endhint %}

스페이스 내의 App 데이터의 저장공간 입니다. (스페이스 한정) [**Storage 페이지**](https://docs-kr.zep.us/zep-script-api/zepscriptapi/scriptapp/storage)를 참고해주세요.

### [followPlayer](https://docs-kr.zep.us/zep-script-api/scriptapp/field#followplayer)

{% hint style="info" %}
&#x20;App.followPlayer: Boolean
{% endhint %}

App의 따라가기 기능 활성화 여부 값 입니다. (기본 값 : false)

### [showName](https://docs-kr.zep.us/zep-script-api/scriptapp/field#showname)

{% hint style="info" %}
&#x20;App.showName: Boolean
{% endhint %}

플레이어의닉네임 숨김여부 값 입니다. (기본 값: true)

### [appHashID](https://docs-kr.zep.us/zep-script-api/scriptapp/field#apphashid)

{% hint style="info" %}
App.appHashID: String&#x20;
{% endhint %}

앱의 HashID를 가져옵니다.

## ️💾 Storage

### [setStorage, getStorage](https://docs-kr.zep.us/zep-script-api/zepscriptapi/scriptapp/storage)

{% hint style="info" %}
App.setStorage(string) / App.getStorage(function())
{% endhint %}

App.setStorage 함수로 App storage를 저장하고, 앱을 사용중인 다른 맵의 App storage 변경사항이 있을 경우 App.getStorage 함수로 App storage를 동기화 할 수 있습니다.

{% hint style="warning" %}
App.getStorage 함수는 비동기 함수이기 때문에 App.getStorage 함수 다음 라인에 App.storage를 사용하는 코드를 작성할 경우 동기화를 보장할 수 없습니다.
{% endhint %}

## 🛰️ EventListeners

### [onSay](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onsay)

{% hint style="info" %}
App.onSay.Add(function(player, text){});
{% endhint %}

플레이어가 채팅을 입력할 때 동작합니다.

### [onPlayerTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onplayertouched)

{% hint style="info" %}
App.onPlayerTouched.Add(function(sender, target, x, y){});
{% endhint %}

캐릭터들끼리 충돌할 때 동작합니다.

### [onObjectTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onobjecttouched)

{% hint style="info" %}
App.onObjectTouched.Add(function(sender, x, y, tileID, obj){});
{% endhint %}

캐릭터가 오브젝트와 충돌할 때 동작합니다.

### [onAppObjectTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onappobjecttouched)

{% hint style="info" %}
App.onAppObjectTouched.Add(function(sender, key, x, y ){});
{% endhint %}

️ 캐릭터가 키 값을 가진 오브젝트와 충돌할 때 동작합니다.

### [onUnitAttacked](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onunitattacked)

{% hint style="info" %}
App.onUnitAttacked.Add(function(sender, x, y, target){});
{% endhint %}

플레이어가 공격 키(Z)로 다른 캐릭터를 공격할 때 동작합니다.

### [onObjectAttacked](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onobjectattacked)

{% hint style="info" %}
App.onObjectAttacked.Add(function(sender, x, y){});
{% endhint %}

플레이어가 공격 키(Z)로 오브젝트를 공격할 때 동작합니다.

### [onSidebarTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onsidebartouched)

{% hint style="info" %}
App.onSidebarTouched.Add(function(player){});
{% endhint %}

플레이어가 사이드바 앱을 클릭(터치) 할 때 동작합니다.

### [onTriggerObject](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#ontriggerobject)

{% hint style="info" %}
App.onTriggerObject.Add(function(player, layerID, x, y, key){});
{% endhint %}

오브젝트와 F 상호작용 시 동작하는 함수입니다.

### [onAppObjectAttacked](https://docs-kr.zep.us/zep-script-api/scriptapp/event-listeners#onappobjectattacked)

{% hint style="info" %}

```
App.onAppObjectAttacked.Add(function (sender, x, y, layer, key) {});
```

{% endhint %}

플레이어가 공격 키(Z)로 키 값을 가진 오브젝트를 공격할 때 동작합니다.

## ☎️ Callbacks

### [runLater](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#runlater)

{% hint style="info" %}
App.runLater(function(){}, time: number);
{% endhint %}

time(초) 후에 callback 함수를 실행합니다.

### [addOnTileTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#addontiletouched)

{% hint style="info" %}
App.addOnTileTouched(x:number, y: number, function(player){})
{% endhint %}

지정한 x, y좌표에 플레이어가 도착할 경우 callback 함수를 실행합니다.

### [addOnLocationTouched](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#addonlocationtouched)

{% hint style="info" %}
App.addOnLocationTouched(name: string, function(player){})
{% endhint %}

플레이어가 맵에디터에서 지정한 ‘지정영역’에 도착했을 때 callback 함수를 실행합니다.

### [addOnKeyDown](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#addonkeydown)

{% hint style="info" %}
App.addOnKeyDown(keycode : number, function(player){});
{% endhint %}

플레이어가 지정된 키를 눌렀을 때 callback 함수를 실행합니다.

### [setTimeout](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#settimeout)

{% hint style="info" %}
setTimeout(function(){}, time: number);
{% endhint %}

time(ms) 후에 callback 함수를 실행합니다.

### [setInterval](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#setinterval)

{% hint style="info" %}
setInterval(function(){}, time: number);
{% endhint %}

time(ms) 간격으로 callback 함수를 실행합니다.

### [addMobileButton](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#addmobilebutton)

{% hint style="info" %}
App.addMobileButton( anchor: number, posX: number, posY: number, function(player){} )
{% endhint %}

모바일 환경에서 커스텀 모바일 버튼을 추가하고, 버튼을 눌렀을 때 동작하는 함수를 지정합니다.

### [putMobilePunch](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#putmobilepunch)

{% hint style="info" %}
App.putMobilePunch(enable: boolean = true)
{% endhint %}

enable이 true이면 모바일 환경에서 펀치 버튼이 추가됩니다.

### [putMobilePunchWithIcon](https://docs-kr.zep.us/zep-script-api/scriptapp/callbacks#putmobilepunchwithicon)

{% hint style="info" %}
App.putMobilePunchWithIcon(icon: ScriptDynamicResource)
{% endhint %}

로드한 이미지로 펀치 버튼을 만들어 추가합니다.

## 💠 Methods

### [loadSpritesheet](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#loadspritesheet)

{% hint style="info" %}
App.loadSpritesheet(fileName: string, frameWidth: number, frameHeight: number, anims: array, frameRate: number): ScriptDynamicResource
{% endhint %}

스프라이트 시트 그림 파일을 읽어 객체화하는 함수입니다.

### [showCenterLabel](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#showcenterlabel)

{% hint style="info" %}
App.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: number = 0, time: number = 3000)
{% endhint %}

모든 플레이어에게 지정된 위치에 text를 3초간 표시하는 함수입니다.

### [showCustomLabel](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#showcustomlabel)

{% hint style="info" %}
App.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: number = 3000);
{% endhint %}

모든 플레이어에게 지정된 위치에 text를 3초간 표시하는 함수입니다.

text 부분에 <mark style="color:purple;">`span`</mark> 태그를 넣어 텍스트를 꾸밀 수 있습니다.

### [sayToAll](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#saytoall)

{% hint style="info" %}
&#x20;App.sayToAll(text: string, color: uint = 0xFFFFFF)
{% endhint %}

채팅창에 text 내용을 출력합니다.

### [sayToStaffs](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#saytostaffs)

{% hint style="info" %}
&#x20;App.sayToStaffs(text: string, color: uint = 0xFFFFFF)
{% endhint %}

Staff이상 권한의 유저 채팅창에 text 내용을 출력합니다.

### [showWidget](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#showwidget)

{% hint style="info" %}
&#x20;App.showWidget(fileName: string, align: string, width: number, height: number): ScriptWidget
{% endhint %}

모든 플레이어에게 지정된 align의 위치에 해당 html파일을 위젯으로 불러오는 함수입니다.

### [showYoutubeWidget](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#showyoutubewidget)

{% hint style="info" %}
App.showYoutubeWidget(link: string, align: string, width: number, height: number): ScriptWidget
{% endhint %}

링크에 해당하는 Youtube 컨텐츠를 위젯으로 불러옵니다.

### [spawnPlayer](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#spawnplayer)

{% hint style="info" %}
App.spawnPlayer(playeID: string, tileX: number, tileY: number)
{% endhint %}

playerID 에 해당하는 플레이어를 tileX, tileY 좌표로 이동시키는 함수입니다.

### [kickPlayer](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#kickplayer)

{% hint style="info" %}
App.kickPlayer(playerID: string)
{% endhint %}

playerID 에 해당하는 플레이어를 추방하는 함수입니다.

### [forceDestroy](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#forcedestroy)

{% hint style="info" %}
App.forceDestroy();
{% endhint %}

미니게임 앱을 강제 종료하는 함수입니다.

### [clearChat](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#clearchat)

{% hint style="info" %}
App.clearChat();
{% endhint %}

모든 채팅 내용을 삭제하는 함수입니다.

### [getPlayerByID](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#getplayerbyid)

{% hint style="info" %}
App.getPlayerByID(playerID: string);
{% endhint %}

id 에 해당하는 플레이어를 반환하는 함수입니다.

### [playSound](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#playsound)

{% hint style="info" %}
App.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)
{% endhint %}

모든 플레이어에게 사운드를 재생하는 함수입니다.

### [playSoundLink](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#playsoundlink)

{% hint style="info" %}
App.playSoundLink(link: string, loop: boolean = false)
{% endhint %}

모든 플레이어에게 사운드를 재생하는 함수입니다.

### [stopSound](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#stopsound)

{% hint style="info" %}
App.stopSound();
{% endhint %}

재생되고 있는 사운드를 멈추는 함수입니다.

### [httpGet](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#httpget)

{% hint style="info" %}
App.httpGet(url: string, headers: object, function(res: string){})
{% endhint %}

http get 요청을 보내는 함수입니다.

### [httpPost](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#httppost)

{% hint style="info" %}
App.httpPost(url: string, headers: object, body: object, function(res: string))
{% endhint %}

Form-Data 형태의 http post 요청을 보내는 함수 입니다.

### [httpPostJson](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#httppostjson)

{% hint style="info" %}
App.httpPostJson(url: string, headers: object, body: object, function(res: string))
{% endhint %}

Json 형태의 http post 요청을 보내는 함수 입니다.

### [sendUpdated](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#sendupdated)

{% hint style="info" %}
App.sendUpdated()
{% endhint %}

App 관련 필드 값이 변경되면 변경 값을 적용하는 함수입니다.

### [changeAttackSound](https://docs-kr.zep.us/zep-script-api/scriptapp/methods#changeattacksound)

{% hint style="info" %}
App.changeAttackSound(fileName:string)
{% endhint %}

찌르기(Z키) 공격 효과음을 변경하는 함수입니다.

## ═════════════════════

## 🗺️ ScriptMap&#x20;

## ═════════════════════

## 🗃️ Field

### [width & height](https://docs-kr.zep.us/zep-script-api/scriptmap/field#width-and-height)

{% hint style="info" %}
Map.width : Number Map.height : Number
{% endhint %}

맵의 너비와 높이 값을 가져옵니다.

## 💠 Methods

### [putTileEffect](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#puttileeffect)

{% hint style="info" %}
Map.putTileEffect(x: number, y: number, tileID: TileEffectType)
{% endhint %}

지정한 좌표에 타일 효과를 적용하는 함수입니다.

### [putObject](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#putobject)

{% hint style="info" %}
Map.putObject(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
{% endhint %}

지정한 좌표에 오브젝트를 놓는 함수입니다. (기준 좌표: Left Top) → [<mark style="color:purple;">**기준 좌표란?**</mark>](https://docs-kr.zep.us/creator/reference/coordinate)

### [putObjectMultiple](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#putobjectmultiple)

{% hint style="info" %}
Map.putObjectMultiple(tileArray: array, type: PutObjectType, dynamicResource: ScriptDynamicResource);
{% endhint %}

오브젝트를 배치할 좌표들을 2차원 배열로 입력하여 한 번에 오브젝트를 설치하는 기능입니다. 이 기능을 사용하면 한 번에 많은 오브젝트를 설치할 경우 부하를 줄이는 효과를 얻을 수 있습니다.

### [putObjectWithKey](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#putobjectwithkey)

{% hint style="info" %}
Map.putObjectWithKey(x: number, y: number, dynamicResource: ScriptDynamicResource, option: JsValue)
{% endhint %}

지정한 좌표에 키 값을 가진 오브젝트를 놓는 함수입니다. (기준 좌표: Left Top)

### [getObjectWithKey](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#getobjectwithkey)

{% hint style="info" %}
Map.getObjectWithKey(key: String)
{% endhint %}

해당 키 값을 가지고 있는 오브젝트의 정보를 가져옵니다.

### [playObjectAnimation](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#playobjectanimation)

{% hint style="info" %}
Map.playObjectAnimation(x: number, y: number, name: string)
{% endhint %}

해당 좌표에 있는 오브젝트의 스프라이트 애니메이션을 실행시키는 함수입니다.

해당 좌표 지점에[ <mark style="color:purple;">Map.putObject</mark>](#putobject) 함수가 선행되어야합니다.

### [playObjectAnimationWithKey](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#playobjectanimationwithkey)

{% hint style="info" %}
Map.playObjectAnimation(key: string, animName: string, repeatCount: number)
{% endhint %}

key 값이 일치하는 오브젝트의 스프라이트 애니메이션을 실행시키는 함수입니다.

###

### [moveObject](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#moveobject)

{% hint style="info" %}
Map.moveObject(x: number, y: number, targetX: number, targetY: number, time: number)
{% endhint %}

x, y 좌표에 위치한 오브젝트를 targetX, targetY로 time 초 동안 움직이는 함수입니다.

해당 좌표 지점에 [<mark style="color:purple;">Map.putObject</mark>](https://app.gitbook.com/o/-MkvEtFn2kFBYSN4_5rX/s/iW553XSGeKCAPpImxXi3/~/changes/bRylDKw8UxLaVWLvuhVV/creator/zep-script-v2_kr/api/scriptmap/methods) 함수가 선행되어야합니다.

### [moveObjectWithKey](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#moveobjectwithkey)

{% hint style="info" %}
Map.moveObjectWithKey(key: string, targetX: number, targetY: number, path:boolean = true)
{% endhint %}

key 값을 가진 오브젝트를 targetX, targetY로 움직이는 함수입니다.

### [clearAllObjects()](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#clearallobjects)

{% hint style="info" %}
Map.clearAllObjects()
{% endhint %}

ZEP 스크립트로 생성된 모든 오브젝트를 제거하는 함수입니다.

### [getTile](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#gettile)

{% hint style="info" %}
Map.getTile(layer: number, x: number, y: number): number
{% endhint %}

해당하는 레이어의 x, y 좌표에 있는 타일의 타입 값을 리턴, 타일이 없으면 -1을 리턴합니다.

### [getLocation](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#getlocation)

{% hint style="info" %}
Map.getLocation(locationName: string)
{% endhint %}

파라미터로 전달한 로케이션이 존재하는 경우, 로케이션 설치 좌표를 리턴합니다.

### [getLocationRandom](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#getlocationrandom)

{% hint style="info" %}
Map.getLocationRandom(locationName: string)
{% endhint %}

파라미터로 전달한 로케이션이 2개이상  존재하는 경우, 무작위로 선택하여 로케이션 설치 좌표를 리턴합니다.

### [hasLocation](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#haslocation)

{% hint style="info" %}
Map.hasLocation(locationName: String): Boolean
{% endhint %}

맵에 해당 로케이션이 있는지 체크하여 true/false 값을 리턴합니다.

### [getObjectsByType](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#getobjectsbytype)

{% hint style="info" %}
Map.getObjectsByType(type: numer) : array
{% endhint %}

&#x20;Type에 해당하는 오브젝트들을 리턴하는 함수입니다.

### [getTopObjectsByType](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#gettopobjectsbytype)

{% hint style="info" %}
Map.getTopObjectsByType(type: numer) : array
{% endhint %}

&#x20;Type에 해당하는 상단오브젝트들을 리턴하는 함수입니다.

### [sayObjectWithKey](https://docs-kr.zep.us/zep-script-api/scriptmap/methods#sayobjectwithkey)

{% hint style="info" %}
Map.sayObjectWithKey( key: string, message: string )
{% endhint %}

&#x20;key 값을 가진 오브젝트 위에 말풍선을 표시하는 함수입니다.

## ═════════════════════

## 👥 ScriptPlayer&#x20;

## ═════════════════════

## 🗃️ Field

### [id , name](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#id-name)

{% hint style="info" %}
player.id : Number player.name : String
{% endhint %}

플레이어의 id, 닉네임 값을 가져옵니다.

### [title](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#title)

{% hint style="info" %}
player.title : String
{% endhint %}

title은 캐릭터 닉네임 위에 노란색으로 노출되는 텍스트입니다.

### [role](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#role)

{% hint style="info" %}
player.role : Number
{% endhint %}

role은 플레이어의 권한을 나타내는 숫자 값 입니다. 플레이어의 role에 따라 다음과 같은 값을 출력합니다.

| 게스트 | -1   | 스태프  | 2000 |
| --- | ---- | ---- | ---- |
| 멤   | 0    | 관리자  | 3000 |
| 에디터 | 1000 | 맵소유자 | 3001 |

###

### [tileX, tileY](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#tilex-tiley)

{% hint style="info" %}
&#x20;player.tileX: Number player.tileY: Number
{% endhint %}

플레이어의 캐릭터가 서있는 X 좌표 값과 Y 좌표 값입니다.

### [dir](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#dir)

{% hint style="info" %}
player.dir : Number
{% endhint %}

플레이어의 캐릭터가 바라보고 있는 방향입니다.

캐릭터가 바라보고 있는 방향에 따라 다음과 같은 값을 출력합니다.

<div><figure><img src="https://2461137890-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiW553XSGeKCAPpImxXi3%2Fuploads%2FhasohAG4tL42qlMxMJeO%2FUntitled-1_(1).png?alt=media&#x26;token=8f57f3e5-5ae6-4e7f-9174-a052d15f56e6" alt=""><figcaption><p>캐릭터가 바라보는 방향에 따른 dir 값</p></figcaption></figure> <figure><img src="https://2461137890-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiW553XSGeKCAPpImxXi3%2Fuploads%2FZjCNMuZ3t8q0YWJcngUz%2Fimage.png?alt=media&#x26;token=59503601-1949-4726-94ae-843d764f0f5b" alt=""><figcaption></figcaption></figure></div>

### [moveSpeed](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#movespeed)

{% hint style="info" %}
player.moveSpeed : Number
{% endhint %}

플레이어의 이동속도 값입니다. (기본 값: 80)

### [sprite](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#sprite)

{% hint style="info" %}
player.sprite : ScriptDynamicResource
{% endhint %}

플레이어 캐릭터의 스프라이트 이미지입니다. (**null** 입력 시 기본 아바타 이미지로 초기화)

### [tag](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#tag)

{% hint style="info" %}
&#x20;player.tag: Any
{% endhint %}

tag를 사용해 플레이어에게 필요한 속성 값을 부여 할 수 있습니다.

### [hidden](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#hidden)

{% hint style="info" %}
player.hidden: Boolean
{% endhint %}

hidden 값이 true 이면, 해당 플레이어는 다른 플레이어에게 보이지 않습니다.

### [spotlight](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#spotlight)

{% hint style="info" %}
player.spotlight: Boolean
{% endhint %}

플레이어의 스팟 라이트 기능 활성화 여부입니다.

### [attackType](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#attacktype)

{% hint style="info" %}
player.attackType : Number
{% endhint %}

플레이어의 공격(Z키) 타입입니다. (기본: 0)

### [attackParam1](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#attackparam1)

{% hint style="info" %}
player.attackParam1: Number
{% endhint %}

공격(Z키) 이미지가 날아가는 거리 속성입니다. 공격 가능 거리는 늘어나지 않습니다.

### [attackParam2](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#attackparam2)

{% hint style="info" %}
player.attackParam2: Number
{% endhint %}

공격 가능 거리 속성입니다. attackType이 원거리 공격으로 설정 된 경우에만 유효합니다.

### [attackSprite](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#attacksprite)

{% hint style="info" %}
player.attackSprite : ScriptDynamicResource
{% endhint %}

공격(Z키) 이미지 속성입니다.

### [walletAddress](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#walletaddress)

{% hint style="info" %}
player.walletAddress : String
{% endhint %}

플레이어의 전자지갑 주소입니다.

### [storage](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#storage)

{% hint style="info" %}
player.storage : String
{% endhint %}

스페이스 내의 Player 값 저장 공간 입니다 (스페이스 한정)

### [isMobile](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#ismobile)

{% hint style="info" %}
&#x20;player.isMobile : Boolean
{% endhint %}

플레이어의 모바일 접속 여부를 true/false 로 출력합니다.

### [isMoving](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#ismoving)

{% hint style="info" %}
player.isMoving : Boolean
{% endhint %}

플레이어가 움직이고 있으면 True, 아니면 False를 반환합니다.

### [isJumping](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#isjumping)

{% hint style="info" %}
player.isJumping : Boolean
{% endhint %}

플레이어가 점프하고 있으면 True, 아니면 False를 반환합니다.

### [customData](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#customdata)

{% hint style="info" %}
&#x20;player.customData : String
{% endhint %}

URL 쿼리스트링으로 전달 받은 값을 저장하는 필드입니다. :fire: [<mark style="color:purple;">URL 쿼리스트링 활용하기</mark>](https://docs-kr.zep.us/creator/reference/url)

### [displayRatio](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#displayratio)

{% hint style="info" %}
player.displayRatio: number
{% endhint %}

플레이어화면의 줌을 컨트롤 하는 값 ( 기본 값: 1 )

### [titleColor](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#titlecolor)

{% hint style="info" %}
player.titleColor: number
{% endhint %}

플레이어의 타이틀 색상을 읽거나 수정 할 수 있습니다.

### [emailHash](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#emailhash)

{% hint style="info" %}
player.emailHash
{% endhint %}

플레이어의 이메일 Hash 값을 가져옵니다.

### [isGuest](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#isguest)

{% hint style="info" %}
player.isGuest
{% endhint %}

비로그인 플레이어인 경우 true 값을 가집니다.

### [away](https://docs-kr.zep.us/zep-script-api/scriptplayer/field#away)

{% hint style="info" %}
player.away
{% endhint %}

5분 이상 비활성화된 유저인 경우 `true`값을 가집니다.

## 💠 Methods

### [showCenterLabel](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showcenterlabel)

{% hint style="info" %}
&#x20;player.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: number = 0, time: number = 3000)
{% endhint %}

해당 플레이어에게 지정된 위치에 text를 3초간 표시하는 함수입니다.

### [showCustomLabel](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showcustomlabel)

{% hint style="info" %}
player.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: number = 3000);
{% endhint %}

모든 플레이어에게 지정된 위치에 text를 3초간 표시하는 함수입니다.

text 부분에 <mark style="color:purple;">`span`</mark> 태그를 넣어 텍스트를 꾸밀 수 있습니다.

### [showWidget](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showwidget)

{% hint style="info" %}
player.showWidget(fileName: string, align: string, width: number, height: number): ScriptWidget
{% endhint %}

해당 플레이어에게 지정된 align의 위치에 해당 html파일을 위젯으로 불러오는 함수입니다.

### [showBuyAlert](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showbuyalert)

{% hint style="info" %}
player.showBuyAlert(itemName: string, price: number, callback: function, payToSpaceOwner: boolean = false)
{% endhint %}

플레이어에게 구매 위젯을 표시하고, 구매 후 동작하는 콜백함수를 작성할 수 있습니다. **payToSpaceOwner** 옵션이 false인 경우 앱 소유자에게 수익이 전달되며, true인 경우에는 앱이 설치된 맵의 소유자에게 수익이 전달됩니다.

### [hideBuyAlert](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#hidebuyalert)

{% hint style="info" %}
player.hideBuyAlert()
{% endhint %}

플레이어의 구매 위젯을 닫습니다.

### [sendMessage](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#sendmessage)

{% hint style="info" %}
&#x20;player.sendMessage(text: string, color: uint = 0xFFFFFF)
{% endhint %}

유저 개인에게 채팅 메시지를 보내는 함수입니다.

### [showPrompt](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showprompt)

{% hint style="info" %}
&#x20;player.showPrompt(text: string, function(inputText), option = {})
{% endhint %}

플레이어에게 입력창을 보여주고, 플레이어의 응답에 따라 동작하는 callback 함수를 작성할 수 있습니다.

### [showConfirm](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showconfirm)

{% hint style="info" %}
&#x20;player.showConfirm(text: string, function(result), option = {})
{% endhint %}

플레이어에게 확인창을 보여주고, 플레이어가 OK를 눌렀을 때 동작하는 callback 함수를 작성할 수 있습니다. cancel을 누를 경우에는 callback 함수가 동작하지 않습니다.

### [showAlert](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showalert)

{% hint style="info" %}
&#x20;player.showAlert(text: string, function(), option = {})
{% endhint %}

플레이어에게 경고창을 보여주고, 플레이어가 OK를 눌렀을 때 동작하는 callback 함수를 작성할 수 있습니다.

### [showWidgetResponsive](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showwidgetresponsive)

{% hint style="info" %}

```
player.showWidgetResponsive(fileName:string, marginTop:number, marginRight:number, marginBottom:number, marginLeft:number)
```

{% endhint %}

위젯의 상/하/좌/우 여백을 화면 크기에 대한 %비율로 정의 하여 위젯을 표시합니다.

화면의 크기가 여백을 포함한 위젯 영역보다 작아질 경우, 위젯의 크기가 비례하여 작아집니다

### [openWebLink](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#openweblink)

{% hint style="info" %}
player.openWebLink(url:string, popup:boolean=false)
{% endhint %}

플레이어에게 웹 URL을 새 창이나 팝업 창으로 표시합니다.

### [showEmbed](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showembed)

{% hint style="info" %}
player.showWidget(url: string, align: string, width: number, height: number, hasBackdrop: boolean = true)
{% endhint %}

해당 플레이어에게 지정된 align의 위치에 url 임베드  화면을 표시하는 함수입니다.

### [showImageModal](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#showimagemodal)

{% hint style="info" %}
player.showImage(url: string)
{% endhint %}

플레이어에게 입력한 이미지 주소에 해당하는 이미지를 표시합니다.

### [showNoteModal](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#shownotemodal)

{% hint style="info" %}
player.showNoteModal(text: string)
{% endhint %}

플레이어에게 텍스트 창을 보여주는 함수입니다.

### [isEmail](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#isemail)

{% hint style="info" %}
player.isEmail(email: string): boolean
{% endhint %}

해당 플레이어의 이메일이 파라미터 값과 같다면 true, 아니면 false를 리턴합니다.

### [getLocationName](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#getlocationname)

{% hint style="info" %}
player.getLocationName : string
{% endhint %}

플레이어가 서있는 지정영역의 이름을 출력합니다.

### [spawnAt](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#spawnat)

{% hint style="info" %}
player.spawnAt(tileX: int ,tileY: int, dir: int = 0)
{% endhint %}

플레이어의 캐릭터를 tileX, tileY 좌표로 지정한 방향을 바라보게 이동시킵니다.

### [spawnAtLocation](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#spawnatlocation)

{% hint style="info" %}
player.spawnAtLocation(name: string, dir:int = 0)
{% endhint %}

플레이어의 캐릭터를 name에 해당하는 지정 영역으로 지정한 방향을 바라보게 이동시킵니다.

### [spawnAtMap](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#spawnatmap)

{% hint style="info" %}
player.spawnAtMap(spaceHashID string, mapHashID:string = null)
{% endhint %}

플레이어를 해당 스페이스 해당 맵으로 이동시킵니다.

### [setCameraTarget](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#setcameratarget)

{% hint style="info" %}
**\[1]** player.setCameraTarget( tileX: Number, tileY: Number, time: Number )

**\[2]** player.setCameraTarget( key: String, time: Number )
{% endhint %}

**\[1]** 플레이어의 시점을 지정된 좌표로 중심 이동시킵니다.

**\[2]** 플레이어의 시점을 특정 오브젝트로 중심 이동시킵니다.

### [setEffectSprite](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#seteffectsprite)

{% hint style="info" %}
player.setEffectSprite(resource: ScriptDynamicResource, offsetX: Number, offsetY: Number, type: Number)
{% endhint %}

플레이어의 배경 또는 전경 이미지를 설정 할 수 있습니다.

### [playSound](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#playsound)

{% hint style="info" %}
Player.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)
{% endhint %}

해당 플레이어에게 사운드를 재생하는 함수입니다.

### [playSoundLink](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#playsoundlink)

{% hint style="info" %}
player.playSoundLink(link: string, loop: boolean = false)
{% endhint %}

모든 플레이어에게 사운드를 재생하는 함수입니다.

### [sendUpdated](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#sendupdated)

{% hint style="info" %}
&#x20;player.sendUpdated()
{% endhint %}

App, Player 관련 필드 값이 변경되면 변경 값을 적용하는 함수입니다.

### [save](https://docs-kr.zep.us/zep-script-api/scriptplayer/methods#save)

{% hint style="info" %}
player.save()
{% endhint %}

App, Player storage 값이 변경되면 변경 값을 적용하는 함수입니다.

## ═════════════════════

## 🧙‍♂️ ScriptWidget&#x20;

## ═════════════════════

## 🗃️ Field

### [id](https://docs-kr.zep.us/zep-script-api/scriptwidget/field#id)

{% hint style="info" %}
widget.id
{% endhint %}

위젯의 아이디 값을 가져옵니다.

## 🛰️ EventListeners

### [onMessage](https://docs-kr.zep.us/zep-script-api/scriptwidget/event-listeners#onmessage)

{% hint style="info" %}
widget.onMessage.Add(function(player, data: any){});
{% endhint %}

위젯에서 App으로 메시지를 보내면 callback 함수가 동작합니다.

## 💠 Methods

### [sendMessage](https://docs-kr.zep.us/zep-script-api/scriptwidget/methods#sendmessage)

{% hint style="info" %}
widget.sendMessage(object: any)
{% endhint %}

App에서 위젯으로 데이터를 보냅니다.

### [destroy](https://docs-kr.zep.us/zep-script-api/scriptwidget/methods#destroy)

{% hint style="info" %}
widget.destroy()
{% endhint %}

위젯을 삭제하는 함수입니다.

## ═════════════════════

## 🔩 Utility Class&#x20;

## ═════════════════════

## ⏳ Time

### [getTime](https://docs-kr.zep.us/zep-script-api/utilityclass/time#gettime)

{% hint style="info" %}
Time.getTime()
{% endhint %}

ZEP 서버의 현재 시간을 milliseconds 단위의  값으로 리턴합니다.

### [getUtcTime](https://docs-kr.zep.us/zep-script-api/utilityclass/time#getutctime)

{% hint style="info" %}
Time.getUtcTime()
{% endhint %}

현재 UTC 시간을 milliseconds 단위의 값으로  리턴합니다.

### [getTimeInterval](https://docs-kr.zep.us/zep-script-api/utilityclass/time#gettimeinterval)

{% hint style="info" %}
Time.getTimeInterval(timeA: number, timeB: number, returnType: DateType)
{% endhint %}

`timeB - timeA`를 계산하고, 그 결과를 지정한 `returnType`으로 반환합니다.
