Storage
App storage는 스페이스 내의 App 데이터의 저장공간 입니다.
Last updated
Was this helpful?
Was this helpful?
App.onStart.Add(function(){
if(App.storage == null){
App.setStorage(JSON.stringify({count: 0}))
}
})
// Q 키를 누르면 동작하는 함수
App.addOnKeyDown(81,function(player){
// App.storage를 최신화 한 후 callback 함수를 실행합니다.
App.getStorage(function () {
let appStorage = JSON.parse(App.storage);
appStorage.count += 1;
App.sayToAll(`count: ${appStorage.count}`)
// App.setStorage를 사용해 변경내용을 저장합니다.
App.setStorage(JSON.stringify(appStorage));
});
// App.getStorage 함수 다음 라인에 App.storage 코드를 작성할 경우 동기화를 보장할 수 없습니다.
App.sayToAll(App.storage);
})