마인크래프트 스크립트 강좌 -5
본문 바로가기

마인크래프트

마인크래프트 스크립트 강좌 -5

728x90
반응형
SMALL

안녕하세요, 소니압니다.

 

오랜만에 돌아온 스크립트 강좌!

 

이번 강좌에서는 플라이 쿠폰 스크립트 강좌를 하려합니다.

 

코드를 보기 전에 변수의 종류에 대해서 잠깐 설명하겠습니다.

 

기본 코드와 주석이 달린 코드는 글의 맨 밑에 첨부해두니 참고해주시길 바랍니다!

 

롤 아케인 케이스 (리그오브레전드) 아이폰13 다양한 캐릭터 초등학생 선물용 범퍼케이스

COUPANG

www.coupang.com

 


 - 기본적인 변수는 중괄호{} 안에 변수의 이름을 넣는 형태입니다.

 

 

리그 오브 레전드: 공식 스토리북:룬테라의 세계

COUPANG

www.coupang.com

 

 

 - 지역변수: {_변수이름} 처럼 변수의 이름 앞에 언더바_를 붙여서 만드며, 발생된 그 이벤트에서만 존재하는 변수입니다. 해당 이벤트가 끝나면 저장된 값이 사라집니다.
 이는 보통 잠시 사용할 변수가 필요할 때 자주 쓰입니다.

 

 - 배열변수: {변수이름::*} <- 이 형태의 변수는 여러개의 값을 저장할 수 있습니다.

add [값] to {변수이름::*} 으로 값을 저장할 수 있으며,

{변수이름::1}, {변수이름::2}, {변수이름::3}... 이런식으로 데이터에 접근할 수 있습니다.

 


반응형
options:
     f : &f[&bFly coupon&f]

        
command /플라이 [<text>] [<integer>]:
    trigger:
        if arg 1 is not set:
            if player is not op:
                if {플라이가능월드목록::*} doesn't contain player's world:
                    send "{@f} &c이 월드에서는 플라이를 사용할 수 없습니다."
                    stop
                if {flytime.%uuid of player%} is not set:
                    set {flytime.%uuid of player%} to 0
                if {flytime.%uuid of player%} <= 0:
                    send "{@f} &c플라이 시간이 부족합니다!"
                    stop
            if player's flight mode is true:
                set player's flight mode to false
                send "{@f} 플라이가 비활성화되었습니다."
            else if player's flight mode is false:
                set player's flight mode to true
                send "{@f} 플라이가 활성화되었습니다."
                
        else if arg 1 is "남은시간":
            if player is op:
                send "{@f} 잔여 플라이 시간: &a무제한&f(OP)"
                stop
            send "{@f} 잔여 플라이 시간: &a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초"
            stop
            
        else if arg 1 is "도움말":
            send ""
            send "&f[ &b플라이 명령어&f ]"
            send ""
            send "{@f} /플라이 &7- 플라이 On/Off"
            send "{@f} /플라이 남은시간 &7- 남은시간을 봅니다. (OP는 무제한)"
            send "{@f} /플라이 액션바 &7- 액션바에 뜨는 남은시간 On/Off"
            if player is op:
                send "{@f} /플라이 발급 <분> &7- 플라이쿠폰 발급"
                send "{@f} /플라이 월드추가  &7- 현재 자신이 서있는 월드를 플라이가 가능한 월드로 추가합니다."
                send "{@f} /플라이 월드초기화 &7- 플라이가 가능한 월드목록을 초기화시킵니다."
            send ""
            stop
            
        else if arg 1 is "액션바":
            if {fly-actionbar.%uuid of player%} is true:
                set {fly-actionbar.%uuid of player%} to false
                send "{@f} 액션바 플라이 남은시간 표시 Off"
            else if {fly-actionbar.%uuid of player%} is false:
                set {fly-actionbar.%uuid of player%} to true
                send "{@f} 액션바 플라이 남은시간 표시 On"
        if player is op:
            if arg 1 is "발급":
                if arg 2 is not set:
                    send "&c발급할 플라이 추가권의 시간(분)를 입력해주세요."
                    stop
                give enchanted book named "{@f} &b%arg 2% &f분" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은 시간 으로 확인" to player
                send "{@f} &b%arg 2%&f 분 이 발급되었습니다."
                stop
            else if arg 1 is "월드추가":
                if {플라이가능월드목록::*} contain player's world:
                    send "{@f} &c%player's world% 월드는 이미 플라이를 사용할 수 있습니다."
                    stop
                add player's world to {플라이가능월드목록::*}
                send "{@f} &a이제 %player's world% 월드에서도 플라이를 사용할 수 있습니다."
            else if arg 1 is "월드초기화":
                delete {플라이가능월드목록::*}
                send "{@f} &a플라이가 가능한 월드목록을 모두 초기화하였습니다."
                 stop




on left click with enchanted book:
    if name of tool of player contain "Fly coupon":
        set {_itemname::*} to uncolored name of player's tool split by " "
        set player's tool to air
#        remove 1 of enchanted book named "%colored name of player's tool%" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은시간 으로 확인" from player's inventory
        add {_itemname::3} parsed as integer*60 to {flytime.%uuid of player%}
         send "{@f} 플라이 시간 &b%{_itemname::3}%&f분이 추가되었습니다. [&a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초]"

on join:
    if {flytime.%uuid of player%} is not set:
        set {flytime.%uuid of player%} to 0
    if {fly-actionbar.%uuid of player%} is not set:
        set {fly-actionbar.%uuid of player%} to true
        
every 1 seconds:
    loop all players:
        if loop-player is not op:
            if loop-player's flight mode is true:
                subtract 1 from {flytime.%uuid of loop-player%}
                if {fly-actionbar.%uuid of loop-player%} is true:
                    set action bar of loop-player to "남은 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"
                if {flytime.%uuid of loop-player%} <= 0:
                    set loop-player's flight mode to false
                    send "{@f} 플라이 남은 시간을 모두 사용하였습니다." to loop-player
                if {플라이가능월드목록::*} doesn't contain loop-player's world:
                    set loop-player's flight mode to false
                    send "{@f} 이 월드에서는 플라이를 사용할 수 없습니다." to loop-player
        else:
            if loop-player's flight mode is true:
                if {fly-actionbar.%uuid of loop-player%} is true:
                     set action bar of loop-player to "남은 플라이 시간: &a무제한&f(OP)"

설명

 

로지텍 KDA 리그 오브 레전드 마우스 장패드

COUPANG

www.coupang.com

 

options:
     f : &f[&bFly coupon&f]

        
command /플라이 [<text>] [<integer>]: # integer는 정수
    trigger:
        if arg 1 is not set:
            if player is not op:
                 if {플라이가능월드목록::*} doesn't contain player's world:

 # {변수이름::*} <- 이 형태의 변수는 배열변수입니다.
 # 여기선 {플라이가능월드목록::*}가 player's world값을 포함하고 있는지를 검사하고 있습니다.
  # 포함하고있지 않으면 true, 포함하고있으면 false
                    send "{@f} &c이 월드에서는 플라이를 사용할 수 없습니다."
                    stop
                 if {flytime.%uuid of player%} is not set:

 # uuid of player는 해당 플레이어의 uuid 값을 저장하고 있다.
  # 이 변수는 각 플레이어의 플라이 남은시간을 초 단위로 저장하는 기능을 합니다.
                    set {flytime.%uuid of player%} to 0
                if {flytime.%uuid of player%} <= 0: # '<='는 '이하'를 뜻하는 연산기호입니다.
                    send "{@f} &c플라이 시간이 부족합니다!"
                    stop
            if player's flight mode is true: # flight mode는 해당 플레이어가 날 수 있는 상태일 때 true를, 날 수 없는 상태일 때 false를 가집니다.
                set player's flight mode to false
                send "{@f} 플라이가 비활성화되었습니다."
            else if player's flight mode is false:
                set player's flight mode to true
                send "{@f} 플라이가 활성화되었습니다."
                
        else if arg 1 is "남은시간":
            if player is op:
                send "{@f} 잔여 플라이 시간: &a무제한&f(OP)"
                stop
             send "{@f} 잔여 플라이 시간: &a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초"

            stop

 # 이 줄에서 나오는 floor()와 mod(,)는 스크립트가 기본으로 제공하는 함수입니다. 
 # floor()는 괄호안에 입력된 수의 소수점을 반내림하여 값을 반환합니다. ex) floor(60.72) = 60
 # mod()는 mod(a,b)로 쓰이며 a를 b로 나눈 나머지를 반환합니다.    ex) mod(3,2) = 1
 # 이 줄에서는 floor로 시간(초)을 저장한 변수를 60으로 나눈 값을 소수점을 제거하여 '분'을 나타냈고, mod로 시간(초)을 저장한 변수를 60으로 나눈 나머지 값을 출력하여 '초'를 나타냈습니다, 
             
        else if arg 1 is "도움말":
            send ""
            send "&f[ &b플라이 명령어&f ]"
            send ""
            send "{@f} /플라이 &7- 플라이 On/Off"
            send "{@f} /플라이 남은시간 &7- 남은시간을 봅니다. (OP는 무제한)"
            send "{@f} /플라이 액션바 &7- 액션바에 뜨는 남은시간 On/Off"
            if player is op:
                send "{@f} /플라이 발급 <분> &7- 플라이쿠폰 발급"
                send "{@f} /플라이 월드추가  &7- 현재 자신이 서있는 월드를 플라이가 가능한 월드로 추가합니다."
                send "{@f} /플라이 월드초기화 &7- 플라이가 가능한 월드목록을 초기화시킵니다."
            send ""
            stop
            
        else if arg 1 is "액션바":
            if {fly-actionbar.%uuid of player%} is true: # 플라이중일 때 남은시간을 액션바에 표기할지 여부를 결정하는 변수
                set {fly-actionbar.%uuid of player%} to false
                send "{@f} 액션바 플라이 남은시간 표시 Off"
            else if {fly-actionbar.%uuid of player%} is false:
                set {fly-actionbar.%uuid of player%} to true
                send "{@f} 액션바 플라이 남은시간 표시 On"
        if player is op:
            if arg 1 is "발급":
                if arg 2 is not set:
                    send "&c발급할 플라이 추가권의 시간(분)를 입력해주세요."
                    stop
                give enchanted book named "{@f} &b%arg 2% &f분" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은시간 으로 확인" to player
                
 # give는 아래 방식으로 사용하면 된다.
 # give 아이템이름(아이템코드x) named "아이템이름" with lore "아이템설명1" and "아이템설명2" to player
 # 아이템 이름을 아는법은 아래 코드를 이용하여 손에 든 아이템의 이름을 쉽게 알아낼 수 있다.
 #command /itemname:
 #    trigger:
 #        send "%player's tool%"
  #
                
                send "{@f} &b%arg 2%&f 분 이 발급되었습니다."
                stop
            else if arg 1 is "월드추가":
                if {플라이가능월드목록::*} contain player's world:
                    send "{@f} &c%player's world% 월드는 이미 플라이를 사용할 수 있습니다."
                    stop
                add player's world to {플라이가능월드목록::*} # 여러개의 변수값을 저장할 수 있는 변수에 player's world 값을 추가시킴
                send "{@f} &a이제 %player's world% 월드에서도 플라이를 사용할 수 있습니다."
            else if arg 1 is "월드초기화":
                delete {플라이가능월드목록::*} # 변수에 저장된 값을 모두 삭제
                send "{@f} &a플라이가 가능한 월드목록을 모두 초기화하였습니다."
                 stop

on left click with enchanted book: # 인첸트된 책으로 좌클릭을 했을 때 발생하는 이벤트
    if name of tool of player contain "Fly coupon": # 플레이어의 도구의 이름이 "Fly coupon" 를 포함하고 있으면
        set {_itemname::*} to uncolored name of player's tool split by " " # A split by "B"는 A라는 문자열을 B라는 문자를 기준으로 나누어줍니다.
 # 보통 아래의 방식으로 나누어진 값이 배열변수에 차례대로 저장시킵니다.
 # set {배열변수::*} to A split by "B"
 # 나뉘어진 문자에는 {배열변수::1}, {배열변수::1}.. 과 같은 방식으로 접근할 수 있습니다.
                                                                           
  # uncolored 는 다음에 오는 문자열의 색코드의 발동을 막아줍니다.


 # 변수이름 앞에 {_변수이름} 이런식으로 언더바_를 붙이면 지역변수입니다.


        set player's tool to air # 플레이어의 도구를 air(아무것도 없음)로 설정합니다.
         add {_itemname::3} parsed as integer*60 to {flytime.%uuid of player%}

 # {_itemname::3}에는 나뉘어진 플라이쿠폰이름중에 시간(분) 정보가 문자타입으로 저장되어 있음.
 # 'A parsed as [타입]' 은 A라는 변수의 타입을 [타입]으로 인식시킵니다.
                                                                              
  # 이 줄에서는 {_itemname::3}에 저장된 시간(분)을 정수로 인식시키고 60을 곱하여 {flytime.%uuid of player%}에 저장합니다.
                                                                              
        send "{@f} 플라이 시간 &b%{_itemname::3}%&f분이 추가되었습니다. [&a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초]" # floor와 mod를 사용하여 남은시간을 분과 초로 출력

on join: # 플라이시간과 액션바 기본설정
    if {flytime.%uuid of player%} is not set:
        set {flytime.%uuid of player%} to 0
    if {fly-actionbar.%uuid of player%} is not set:
        set {fly-actionbar.%uuid of player%} to true
        
every 1 seconds: # 매초마다 발생하는 이벤트
    loop all players: # 모든 플레이어에 대하여 반복
        if loop-player is not op:
            if loop-player's flight mode is true:
                subtract 1 from {flytime.%uuid of loop-player%} # subtract는 사칙연산의 빼기입니다.
                if {fly-actionbar.%uuid of loop-player%} is true:
                    set action bar of loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"
                if {flytime.%uuid of loop-player%} <= 0:
                    set loop-player's flight mode to false
                    send "{@f} 플라이 시간을 모두 사용하였습니다." to loop-player
                if {플라이가능월드목록::*} doesn't contain loop-player's world:
                    set loop-player's flight mode to false
                    send "{@f} 이 월드에서는 플라이를 사용할 수 없습니다." to loop-player
        else:
            if loop-player's flight mode is true:
                if {fly-actionbar.%uuid of loop-player%} is true:
                     set action bar of loop-player to "잔여 플라이 시간: &a무제한&f(OP)"

스크립트를 직접 뜯어보면서 성장하는것도 좋습니다.

https://skripthub.net/

 

Skript Hub

Skript Hub is the best place to get the latest skript tools! Skript Hub is the best resource for skripters with an advanced documentation system, up to date tutorials and an active community.

skripthub.net

여기에는 예제나 스크립트 틀등을 직접 수정하여 여러분들의 스크립트를 직접 만들 수 있습니다.

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

728x90
반응형
LIST