Methods
μκ°
νλ©΄μ UIλ₯Ό νμ, μ μ μ΄λ λλ κ°ν΄, μ¬μ΄λ μ¬μ λ± νΈλ¦¬ν κΈ°λ₯μ μ 곡νλ ν¨μλ€ μ λλ€.
Methods ν¨μλ μ©λμ λ°λΌ UI , User Control, Sound, ν΅μ , κ³΅ν΅ λ©μλλ‘ λλ μ μμ΅λλ€.
UI
loadSpritesheet
μ€νλΌμ΄νΈ μνΈ κ·Έλ¦Ό νμΌμ μ½μ΄ κ°μ²΄ννλ ν¨μμ λλ€.
showCenterLabel
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ textλ₯Ό 3μ΄κ° νμνλ ν¨μμ λλ€.
showCustomLabel
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ textλ₯Ό 3μ΄κ° νμνλ ν¨μμ λλ€. text λΆλΆμ span νκ·Έλ₯Ό λ£μ΄ ν μ€νΈλ₯Ό κΎΈλ° μ μμ΅λλ€.
sayToAll
λͺ¨λ νλ μ΄μ΄μ μ±ν μ°½μ text λ₯Ό μΆλ ₯νλ ν¨μμ λλ€.
sayToStaffs
Staff κΆν μ΄μμ νλ μ΄μ΄μ μ±ν μ°½μ text λ₯Ό μΆλ ₯νλ ν¨μμ λλ€.
showWidget
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ alignμ μμΉμ htmlνμΌμ μμ ―μΌλ‘ λΆλ¬μ€λ ν¨μμ λλ€.
showYoutubeWidget
λ§ν¬μ ν΄λΉνλ Youtube 컨ν μΈ λ₯Ό μμ ―μΌλ‘ λΆλ¬μ΅λλ€.
Control
spawnPlayer
νλ μ΄μ΄λ₯Ό μ§μ ν x, y μ’νλ‘ μ΄λ μν€λ ν¨μμ λλ€.
kickPlayer
νλ μ΄μ΄λ₯Ό μΆλ°©νλ ν¨μμ λλ€.
forceDestroy
λ―Έλκ²μ μ±μ κ°μ μ’ λ£νλ ν¨μμ λλ€.
clearChat
λͺ¨λ μ±ν λ΄μ©μ μμ νλ ν¨μμ λλ€.
getPlayerByID
id μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό λ°ννλ ν¨μμ λλ€.
Sound
playSound
μ¬μ΄λ νμΌμ μ¬μνλ ν¨μμ λλ€.
playSoundLink
μ¬μ΄λ URLμ μ¬μνλ ν¨μμ λλ€.
stopSound
μ¬μ μ€μΈ λͺ¨λ μ¬μ΄λλ₯Ό λ©μΆλ ν¨μμ λλ€.
ν΅μ
httpGet
http get μμ²μ 보λ΄λ ν¨μμ λλ€.
httpPost
Form-Data ννμ http post μμ²μ 보λ΄λ ν¨μ μ λλ€.
httpPostJson
JSON ννμ http post μμ²μ 보λ΄λ ν¨μμ λλ€.
곡ν΅
sendUpdated
App, Player κ΄λ ¨ νλ κ°μ΄ λ³κ²½λλ©΄ λ³κ²½ κ°μ μ μ©νλ ν¨μμ λλ€.
π API μ€λͺ
λ° μμ
π¨ UI Methods
UI ν¨μ ν λμ 보기
// μ€νλΌμ΄νΈ μνΈ κ·Έλ¦Ό νμΌμ μ½μ΄ κ°μ²΄ν
App.loadSpritesheet(fileName: string, frameWidth: number, frameHeight: number, anims: array, frameRate: number): ScriptDynamicResource
// λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ ν΄λΉ textλ₯Ό 1μ΄κ° νμ
App.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: int = 0, time: int = 3000)
// λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ ν΄λΉ textλ₯Ό 3μ΄κ° νμ, 컀μ€ν°λ§μ΄μ§ κ°λ₯
App.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: int = 3000);
// μ±ν
μ°½μ ν΄λΉ textλ΄μ©μ μΆλ ₯
App.sayToAll(text: string, color: uint = 0xFFFFFF)
// λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ alignμ μμΉμ ν΄λΉ htmlνμΌμ μμ ―μΌλ‘ λΆλ¬μ€κΈ°
App.showWidget(fileName: string, align: string, width: number, height: number): ScriptWidget
// λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ alignμ μμΉμ ν΄λΉ YouTube linkμ λμμμ μ¬μμν΄
App.showYoutubeWidget(link: string, align: string, width: number, height: number): ScriptWidget
loadSpritesheet
μ€νλΌμ΄νΈ μνΈ κ·Έλ¦Ό νμΌμ μ½μ΄ κ°μ²΄ννλ ν¨μμ λλ€.
ScriptDynamicResourceμ λν μ΄ν΄λ₯Ό λλ μ€νλΌμ΄νΈμνΈ μ΄ν΄νκΈ° λ¬Έμλ₯Ό νμΈν΄λ³΄μΈμ!
νλΌλ―Έν°
fileName
String
λΆλ¬μ¬ νμΌμ μ΄λ¦
frameWidth frameHeight
number
ν νλ μμ κ°λ‘, μΈλ‘ ν½μ ν¬κΈ°
anims
Array
μ λλ©μ΄μ μΌλ‘ μ§μ ν frame μ΄λ―Έμ§ λ²νΈ λ°°μ΄
frameRate
number
νλ μ νλ λΉ λ°μ΄ν°λ₯Ό νμνλ μλ frameRate: 8 β 1μ΄μ 8κ°μ μ΄λ―Έμ§λ₯Ό 보μ¬μ€
μμ
νμΈνΈλ§¨ - λΈλ£¨λ§¨ μ€νλΌμ΄νΈ μ΄λ―Έμ§ μ μ©ν΄λ³΄κΈ°
// ν νλ μμ μ¬μ΄μ¦ 48x64
let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
left: [5, 6, 7, 8, 9], // μ’λ°©ν₯ μ΄λ μ΄λ―Έμ§
up: [15, 16, 17, 18, 19],
down: [0, 1, 2, 3, 4],
right: [10, 11, 12, 13, 14],
dance: [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
down_jump: [38],
left_jump: [39],
right_jump: [40],
up_jump: [41],
}, 8);
// νλ μ΄μ΄κ° μ
μ₯νλ©΄ μΊλ¦ν° μ΄λ―Έμ§κ° λ°λ
App.onJoinPlayer.Add(function(player){
player.sprite = blueman;
player.sendUpdated();
});
showCenterLabel
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ textλ₯Ό 3μ΄κ° νμνλ ν¨μμ λλ€.
νλΌλ―Έν°
text
String
λΌλ²¨μ μΆλ ₯ν ν μ€νΈ
color
Uint
μΆλ ₯ν κΈμ¨μ μ (HexCode) κ°μ μ λ ₯νμ§ μμ κ²½μ°, ν°μ(0xFFFFFF)μΌλ‘ μ μ©λ©λλ€. β‘οΈκ΅¬κΈ μμ μ ν λꡬ
bgColor
Uint
λ©μμ§κ° μΆλ ₯λλ λΌλ²¨μ λ°°κ²½μ κ°μ μ λ ₯νμ§ μμ κ²½μ°, κ²μμ(0x000000)μΌλ‘ μ μ©λ©λλ€.
offset
number
offset κ°μ΄ ν΄μλ‘ νμλλ μμΉκ° νλ©΄ μλμͺ½ λ°©ν₯μΌλ‘ κ°κΉμμ§λλ€. κ°μ μ λ ₯νμ§ μμ κ²½μ°, 0μΌλ‘ μ§μ λ©λλ€.
time
number
λΌλ²¨ νμ μκ° (ms), κΈ°λ³Έ κ° 3000 ( 3μ΄ )
μμ
λ Έλμ λ°°κ²½ μ μ₯ λ©μμ§ λΌλ²¨μ 2μ΄κ° μΆλ ₯ν΄λ³΄κΈ°

App.onJoinPlayer.Add(function(player){
App.showCenterLabel(`${player.name}λμ΄ μ
μ₯νμ
¨μ΅λλ€.`, 0x000000, 0xFFFF00, 200, 2000); // λ
Έλμ λ°°κ²½, κ²μ μ κΈμ¨λ‘ νμνκΈ°
});
showCustomLabel
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ μμΉμ textλ₯Ό 3μ΄κ° νμνλ ν¨μμ λλ€.
text λΆλΆμ span
νκ·Έλ₯Ό λ£μ΄ ν
μ€νΈλ₯Ό κΎΈλ° μ μμ΅λλ€.
νλΌλ―Έν°
text
String
λΌλ²¨μ μΆλ ₯ν ν μ€νΈ ( span νκ·Έ νμ© )
color
Uint
μΆλ ₯ν κΈμ¨μ μ (HexCode) κ°μ μ λ ₯νμ§ μμ κ²½μ°, ν°μ(0xFFFFFF)μΌλ‘ μ μ©λ©λλ€.
bgColor
Uint
λ©μμ§κ° μΆλ ₯λλ λΌλ²¨μ λ°°κ²½μ κ°μ μ λ ₯νμ§ μμ κ²½μ°, κ²μμ(0x000000)μΌλ‘ μ μ©λ©λλ€. β‘οΈκ΅¬κΈ μμ μ ν λꡬ
offset
number
offset κ°μ΄ ν΄μλ‘ νμλλ μμΉκ° νλ©΄ μλμͺ½ λ°©ν₯μΌλ‘ κ°κΉμμ§λλ€. κ°μ μ λ ₯νμ§ μμ κ²½μ°, 0μΌλ‘ μ§μ λ©λλ€.
width
number
λΌλ²¨μ λλΉλ₯Ό n%λ‘ μ€μ νλ κ° μ λλ€. (κΈ°λ³Έ κ° 100)
opacity
number
λΌλ²¨μ λ°°κ²½ ν¬λͺ λλ₯Ό μ€μ νλ κ° μ λλ€. (κΈ°λ³Έ κ° 0.6, λ²μ 0 ~ 1)
time
number
λΌλ²¨ νμ μκ° (ms), κΈ°λ³Έ κ° 3000 ( 3μ΄ )
μ΅μ
key
String
λΌλ²¨μ ν€ κ°μ ν λΉνμ¬, μλ‘ λ€λ₯Έ ν€ κ°μ κ°μ§ λΌλ²¨μ λμμ νμν μ μμ΅λλ€.
borderRadius
String
λΌλ²¨μ λͺ¨μ리μ λ₯κΈκΈ°λ₯Ό μ€μ ν μ μμ΅λλ€. ex) borderRadius: "8px"
fontOpacity
boolean
falseλ‘ μ€μ μ ν°νΈμ ν¬λͺ λκ° μ μ©λμ§ μμ΅λλ€.
padding
String
λΌλ²¨ λ΄λΆμ padding κ°μ μ§μ ν μ μμ΅λλ€. ex) padding: "8px"
μμ
컀μ€ν λΌλ²¨ μμ μ½λ νμ΄μ§λ₯Ό μ°Έκ³ ν΄μ£ΌμΈμ
sayToAll
μ±ν μ°½μ text λ΄μ©μ μΆλ ₯ν©λλ€.
νλΌλ―Έν°
text
String
μ±ν μ°½μ μΆλ ₯ν ν μ€νΈ
color
Uint
μΆλ ₯ν κΈμ¨μ μμ μ§μ ν©λλ€. (HexCode) κ°μ μ λ ₯νμ§ μμ κ²½μ°, ν°μ(0xFFFFFF)μΌλ‘ μ μ©λ©λλ€. β‘οΈκ΅¬κΈ μμ μ ν λꡬ
μμ
μ μ₯λ©μμ§λ₯Ό νλμμΌλ‘ μΆλ ₯ν΄λ³΄κΈ°

// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.sayToAll(`[info]${player.name} has entered.`, 0x00ffff); // νλμμΌλ‘ νμνκΈ°
});
sayToStaffs
Staffμ΄μ κΆνμ μ μ μ±ν μ°½μ text λ΄μ©μ μΆλ ₯ν©λλ€.
νλΌλ―Έν°
text
String
μ±ν μ°½μ μΆλ ₯ν ν μ€νΈ
color
Uint
μΆλ ₯ν κΈμ¨μ μμ μ§μ ν©λλ€. (HexCode) κ°μ μ λ ₯νμ§ μμ κ²½μ°, ν°μ(0xFFFFFF)μΌλ‘ μ μ©λ©λλ€. β‘οΈκ΅¬κΈ μμ μ ν λꡬ
μμ
μ μ₯λ©μμ§λ₯Ό νλμμΌλ‘ μΆλ ₯ν΄λ³΄κΈ°

// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.sayToStaffs(`[Staff] ${player.name} has entered.`, 0x00ffff); // νλμμΌλ‘ νμνκΈ°
});
showWidget
λͺ¨λ νλ μ΄μ΄μκ² μ§μ λ alignμ μμΉμ ν΄λΉ htmlνμΌμ μμ ―μΌλ‘ λΆλ¬μ€λ ν¨μμ λλ€.
νλΌλ―Έν°
fileName
String
λΆλ¬μ¬ νμΌμ μ΄λ¦
align
String
μμ ―μ νμν μμΉ βpopupβ, βsidebarβ, βtopβ, βtopleftβ, βtoprightβ, βmiddleβ, βmiddleleftβ, βmiddlerightβ, βbottomβ, βbottomleftβ, βbottomrightβ
width height
number
μμ ―μ νμν μμμ κ°λ‘, μΈλ‘ ν¬κΈ°(px)
μμ
μ΄μ±ν΄μ¦ μμ ― λ°λΌν΄λ³΄κΈ°
let _widget = null;
// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
_widget = App.showWidget("widget.html", "top", 200, 300); // νλ©΄ μλ¨, 200x300 μμμ μμ ―μ 보μ¬μ€
_widget.sendMessage({
timer: 15,
answer: "γ
γ
γ
",
});
});
showYoutubeWidget
λ§ν¬μ ν΄λΉνλ Youtube 컨ν μΈ λ₯Ό μμ ―μΌλ‘ λΆλ¬μ΅λλ€.
νλΌλ―Έν°
link
String
Youtube 컨ν μΈ url
align
String
μμ ―μ νμν μμΉ βpopupβ, βsidebarβ, βtopβ, βtopleftβ, βtoprightβ, βmiddleβ, βmiddleleftβ, βmiddlerightβ, βbottomβ, βbottomleftβ, βbottomrightβ
width height
number
μμ ―μ νμν μμμ κ°λ‘, μΈλ‘ ν¬κΈ°(px)
μμ
Youtube μμ ― νμν΄λ³΄κΈ°
// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.showYoutubeWidget("https://www.youtube.com/watch?v=SXnMGIR8cjY","top",600,500);
});
πControl Methods
Control ν¨μ ν λμ 보기
// playerID μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό tileX, tileY μ’νλ‘ μ΄λμν¨λ€.
App.spawnPlayer(playeID: string, tileX: number, tileY: number)
// playerID μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό μΆλ°©νλ€.
// μΆλ°©λΉν μ μ λ 24μκ° λμ ν΄λΉ μ€νμ΄μ€μ μ κ·Όνμ§ λͺ»νκ² λλ€.
App.kickPlayer(playeID: string)
// λ―Έλκ²μ μ±μ κ°μ μ’
λ£μν΅λλ€.
App.forceDestroy();
// λͺ¨λ μ±ν
λ΄μ©μ μμ ν©λλ€.
App.clearChat();
//id μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό λ°ννλ ν¨μμ
λλ€.
App.getPlayerID(playerID:string);
spawnPlayer
playerID μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό tileX, tileY μ’νλ‘ μ΄λμν€λ ν¨μμ λλ€.
νλΌλ―Έν°
playerID
String
νλ μ΄μ΄μ ID κ°
tileX tileY
number
νλ μ΄μ΄λ₯Ό μ΄λμν¬ x, y μ’ν κ°
μμ
μ μ₯νλ νλ μ΄μ΄λ₯Ό μ§μ μ’νλ‘ μ΄λμν€κΈ°
// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.spawnPlayer(player.id, 5, 5); // νλ μ΄μ΄λ₯Ό 5,5 μμΉλ‘ μ΄λμν€κΈ°
});
kickPlayer
playerID μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό μΆλ°©νλ ν¨μμ λλ€.
νλΌλ―Έν°
playerID
String
νλ μ΄μ΄μ ID κ°
μμ
κ°ν΄ λͺ λ Ήμ΄ λ§λ€μ΄λ³΄κΈ°
β κ°ν΄ λΉν μ°Έκ°μλ 24μκ° λμ ν΄λΉ μ€νμ΄μ€μ μ μνμ§ λͺ»ν©λλ€.
// νλ μ΄μ΄κ° μ±ν
μ μ
λ ₯ν λ μ€ν
// λͺ
λ Ήμ΄ νμ '!κ°ν΄ λλ€μ'
App.onSay.Add(function (player, text) {
let players = App.players;
if (text.indexOf("!κ°ν΄ ") == 0) {
let nickname = text.slice(4);
for (let i in players) {
let p = players[i];
if (p.name == nickname) {
App.kickPlayer(p.id);
break;
}
}
}
});
forceDestroy
λ―Έλκ²μ μ±μ κ°μ μ’ λ£νλ ν¨μμ λλ€.
μμ
λ―Έλκ²μ μ±μ κ°μ μ’ λ£μν€κΈ°
// q ν€λ₯Ό λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81, function (player) {
App.forceDestroy();
});

clearChat
λͺ¨λ μ±ν λ΄μ©μ μμ νλ ν¨μμ λλ€.
μμ
Qλ₯Ό λλ¬ μ±ν λ΄μ© μ§μ°κΈ°
// q ν€λ₯Ό λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81, function (player) {
App.clearChat();
});

getPlayerByID
id μ ν΄λΉνλ νλ μ΄μ΄λ₯Ό λ°ννλ ν¨μμ λλ€.
μμ
App.getPlayerByID μ¬μ© λ°©λ²
// q ν€λ₯Ό λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81, function (player) {
const myPlayer = App.getPlayerByID(player.id);
});
π Sound Methods
Sound ν¨μ ν λμ 보기
// λͺ¨λ νλ μ΄μ΄μκ² μ¬μ΄λλ₯Ό μ¬μ
App.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)
// λͺ¨λ νλ μ΄μ΄μκ² λ§ν¬μ ν΄λΉνλ μ¬μ΄λλ₯Ό μ¬μ
App.playSoundLink(link: string, loop: boolean = false)
// λͺ¨λ μ¬μλλ μ¬μ΄λλ₯Ό λ©μΆ€
App.stopSound()
// μ°λ₯΄κΈ°(Zν€) 곡격 ν¨κ³Όμμ λ³κ²½νλ ν¨μμ
λλ€.
App.changeAttackSound(fileName:string)
playSound
λͺ¨λ νλ μ΄μ΄μκ² μ¬μ΄λλ₯Ό μ¬μνλ ν¨μμ λλ€.
νλΌλ―Έν°
fileName
String
λΆλ¬μ¬ νμΌμ μ΄λ¦
loop
boolean
true: λ°λ³΅ μ¬μ false: 1ν μ¬μ
overlap
boolean
μ¬μ΄λ μ€λ²λ©(κ²ΉμΉ¨) μ¬μ κ°λ₯ μ¬λΆ
μμ
νλ μ΄μ΄κ° μ μ₯ν λ μ μ₯μ μ μ©ν΄λ³΄κΈ° ( νμΌ )
//νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.playSound("join.mp3", false, true);
});
playSoundLink
λͺ¨λ νλ μ΄μ΄μκ² μ¬μ΄λλ₯Ό μ¬μνλ ν¨μμ λλ€.
π‘ μ¬λ°λ₯Έ λ§ν¬λ₯Ό μ λ ₯νλλ° μ¬μμ΄ λμ§ μλ κ²½μ°
CORS μ μ± μ μλ°ν κ²½μ°μΌ κ°λ₯μ±μ΄ λμ΅λλ€. CORS μ μ± μ λ§μΆ μ μλ κ²½μ°μλ playSoundLink λμ μμ νμΌμ μ λ‘λ νμ¬ playSound ν¨μλ₯Ό μ¬μ©νλ κ²μ κΆμ₯λ립λλ€.
νλΌλ―Έν°
link
String
μ¬μ΄λ url
loop
boolean
true: λ°λ³΅ μ¬μ false: 1ν μ¬μ
μμ
νλ μ΄μ΄κ° μ μ₯ν λ μ μ₯μ μ μ©ν΄λ³΄κΈ° ( μ¬μ΄λ url )
// νλ μ΄μ΄κ° μ
μ₯ν λ μ€ν
App.onJoinPlayer.Add(function (player) {
App.playSoundLink("https://zep.us/assets/sounds/ring.mp3",false);
});
stopSound
μ¬μλκ³ μλ μ¬μ΄λλ₯Ό λ©μΆλ ν¨μμ λλ€.
νλΌλ―Έν°
μμ
μμ
qλ₯Ό λλ₯΄λ©΄ μ¬μ΄λκ° λ©μΆλ κΈ°λ₯ λ§λ€μ΄λ³΄κΈ°
// q ν€λ₯Ό λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81,function(p){
App.stopSound();
})
changeAttackSound
μ°λ₯΄κΈ°(Zν€) 곡격 ν¨κ³Όμμ λ³κ²½νλ ν¨μμ λλ€.
νλΌλ―Έν°
fileName
String
μ μ©ν μ¬μ΄λ νμΌλͺ
μμ
changeAttackSound μ¬μ© λ°©λ²
App.onStart.Add(function(){
App.changeAttackSound("attack.mp3");
})
π‘ ν΅μ Methods
ν΅μ ν¨μ ν λμ 보기
// ν΄λΉ URLμ HTTP Get μμ²μ μ€ν
App.httpGet(url: string, headers: object, callback: ((string) => void))
// ν΄λΉ URLμ HTTP Post ν¬μ€ν
μ μ€ν
App.httpPost(url: string, headers: object, body: object, callback: ((string) => void))
// ν΄λΉ URLμ HTTP Post ν¬μ€ν
μ μ€ν
App.httpPostJson(url: string, headers: object, body: object, callback: ((string) => void))
httpGet
http get μμ²μ 보λ΄λ ν¨μμ λλ€.
νλΌλ―Έν°
url
String
μμ²μ λ³΄λΌ μ£Όμ
headers
Object
μμ² ν€λ
res
String
μμ²μ λν μλ΅
μμ
νκ΅μ΄ λ³λͺ μμ±κΈ° APIλ₯Ό μ΄μ©ν΄ μ μ₯νλ νλ μ΄μ΄μ λλ€μμ λ°κΏλ³΄κΈ°

// νλ μ΄μ΄κ° μ
μ₯ν λ λμνλ ν¨μ
App.onJoinPlayer.Add(function (player) {
App.httpGet(
"https://nickname.hwanmoo.kr/?format=json&count=1&max_length=6&whitespace=_",
null,
function (res) {
// μλ΅ κ²°κ³Όλ₯Ό JSON μ€λΈμ νΈλ‘ λ³κ²½
let response = JSON.parse(res);
player.name = response.words[0];
player.sendUpdated();
}
);
});
httpPost
Form-Data ννμ http post μμ²μ 보λ΄λ ν¨μ μ λλ€.
νλΌλ―Έν°
url
String
μμ²μ λ³΄λΌ μ£Όμ
headers
Object
μμ² ν€λ, μμ² ν€λκ° μμΌλ©΄ { } λ₯Ό μ λ ₯.
body
Object
μμ² λ°λ ( Form data )
res
String
μμ²μ λν μλ΅
μμ
μ±μμ λ³΄λΈ ν€λμ λ°μ΄ν°λ₯Ό μλ΅μΌλ‘ λ°μ μ±ν μ°½μ μΆλ ₯ν΄λ³΄κΈ°.
μμ μ κ°μ΄ key, value κ°μ string ννλ‘ μμ±ν΄μΌνλ©°, μμ² μλ²μμ νΌλ°μ΄ν°λ₯Ό λ°μ μ²λ¦¬κ° κ°λ₯ν΄μΌν©λλ€.
// qλ₯Ό λλ μ λ μ€νλλ ν¨μ
App.addOnKeyDown(81, function (player) {
App.httpPost(
"https://postman-echo.com/post",
{
"test-header": "zep",
},
{
"name": "zepscript",
},
(res) => {
// μμ² κ²°κ³Όλ₯Ό JSON μ€λΈμ νΈλ‘ λ³ν
let response = JSON.parse(res);
App.sayToAll(`λ³΄λΈ ν€λ: ${response.headers["test-header"]}`, 0xffffff);
App.sayToAll(`λ³΄λΈ λ°μ΄ν°: ${response.form.name}`, 0xffffff);
}
);
});
httpPostJson
Json ννμ http post μμ²μ 보λ΄λ ν¨μ μ λλ€.
νλΌλ―Έν°
url
String
μμ²μ λ³΄λΌ μ£Όμ
headers
Object
μμ² ν€λ, μμ² ν€λκ° μμΌλ©΄ { } λ₯Ό μ λ ₯.
body
Object
μμ² λ°λ ( JSON data )
res
String
μμ²μ λν μλ΅
μμ
μ±μμ λ³΄λΈ λ°μ΄ν°λ₯Ό μλ΅μΌλ‘ λ°μ μ±ν μ°½μ μΆλ ₯ν΄λ³΄κΈ°.
// qλ₯Ό λλ μ λ μ€νλλ ν¨μ
App.addOnKeyDown(81, function (player) {
App.httpPostJson(
"https://postman-echo.com/post",
{},
{
name: "zepscript",
},
(res) => {
App.sayToAll(`${res}`, 0xffffff);
// μμ² κ²°κ³Όλ₯Ό JSON μ€λΈμ νΈλ‘ λ³ν
let response = JSON.parse(res);
App.sayToAll(`λ³΄λΈ λ°μ΄ν°: ${response.data.name}`, 0xffffff);
}
);
});
π κ³΅ν΅ Methods
κ³΅ν΅ ν¨μ ν λμ 보기
// App κ΄λ ¨ νλκ°μ΄ λ³κ²½λλ©΄ λ³κ²½κ°μ μ μ©ν¨
App.sendUpdated()
sendUpdated
App κ΄λ ¨ νλ κ°μ΄ λ³κ²½λλ©΄ λ³κ²½ κ°μ μ μ©νλ ν¨μμ λλ€.
νλΌλ―Έν°
μμ
Last updated
Was this helpful?