개인 자료란 (JE)

  서버 커뮤니티

Profile 마냥냥냥 대표칭호 없음

lunabbit f8fad04911f1497891b25168dec6d8bf

Profile

질문하기 스크립트

상점 스크립트를 수정하고 있는데

2021.04.06 조회 수 722 추천 수 0
이해도 1.12 
게임버전 (JE) 모드버킷 
스크립트 애드온 2.2-dev27 

궁금한 점이 생겨 처음 글 써 봅니다

1. 로어가 적용돼 있는 물품과 로어가 적용돼 있지 않은 물품이 동일한 물품이라 인식하지 못하는 건 어떻게 수정해야 할까요?

2. GUI 부분과 아래의 플레이어 인벤토리는 어떻게 구분할 수 있나요? 플레이어 인벤토리에서 좌클릭해서 물건을 판매하는 코드를 추가하고 싶습니다

3. GUI에서 다음 페이지로 넘어가게 하는 건 다른 GUI를 만들어서 하는 건가요?


아래는 스크립트 코드입니다

on inventory click:
    name of clicked inventory contain "{@inven.shop}"
    cancel event
    clicked inventory is player' current inventory
    event-slot is not air
    set {_name} to name of clicked inventory
    replace "{@inven.shop}" with "" in {_name}
    if "%click type%" contain "RIGHT":
        cancel event
        if {shop.list::%{_name}%::sell::%index of clicked slot + 1%} is not set:
            exit
        set {_sell} to {shop.list::%{_name}%::sell::%index of clicked slot + 1%}
        set {_item} to {shop.list::%{_name}%::item::%index of clicked slot + 1%}
        if amount of 1 of {_item} in player < 1:
            send "{@p} 판매할 아이템을 가지고 있지 않습니다."
            exit
        set {_amount} to item amount of clicked slot
        set {_player} to amount of {_item} in player
        if "%click type%" don't contain "SHIFT":
            cancel event
            if {_player} > {_amount}:
                set {_player} to {_amount}
        set {_sell} to {_sell} / {_amount} * {_player}
        set {_item} to {_player} of {_item}
        remove {_item} from player
        add {_sell} to {은행.%player%}
        send "{@p} 아이템을 &e%{_sell}% &f원에 성공적으로 판매했습니다."
        exit
    if "%click type%" contain "LEFT":
        cancel event
        if {shop.list::%{_name}%::buy::%index of clicked slot + 1%} is not set:
            exit
        set {_buy} to {shop.list::%{_name}%::buy::%index of clicked slot + 1%}
        set {_item} to {shop.list::%{_name}%::item::%index of clicked slot + 1%}
        if "%click type%" contain "SHIFT":
            cancel event
            set {_amount} to item amount of clicked slot
            set {_buy} to {_buy} / {_amount} * 64
            set {_item} to 64 of {_item}
        if {은행.%player%} < {_buy}:
            send "{@p} 돈이 부족합니다."
            exit
        subtract {_buy} from {은행.%player%}
        give {_item} to player
        send "{@p} 아이템을 &e%{_buy}% &f원에 성공적으로 구매했습니다."
        exit

2개의 댓글

스크립터브혼
2021.04.06

1. 아이템의 비교는 명확히 일치하는 경우만 같다고 판단합니다.

아이템을 구성하는 모든 아이템메타(이름, 갯수, 로어, 인첸트, 어트리뷰트, 플래그 등등)를 비교해 완전히 일치해야만 같은 아이템입니다.

로어가 다른데도 같은 아이템이어야 한다면, 로어를 제외한 각각의 메타데이터를 직접 비교하여 같은 경우를 걸러내야합니다.

애드온 없이 스크립트에서 사용 가능한 아이템메타는 이름, 갯수, 로어, 내구도, 인첸트, 커스텀 모델 데이터 등이 있습니다.

책의 경우 제목, 페이지, 저자등도 사용할 수 있습니다.


2. 열어 보고 있는 인벤토리는 [Opened Inventory] 익스프레션을 확인하세요.

플레이어나 블록의 인벤토리는 [Inventory] 익스프레션을 사용합니다.


3. 새로운 인벤토리를 열어주는것이 좋습니다.

플러그인 레벨에서는 인벤토리 업데이트 메소드가 있기 때문에 열려있는 인벤토리에서 닫지않고 변경된 부분을 바로 업데이트 해 줄 수 있지만, 스크립트는 상황에 따라 변경된 슬롯들이 업데이트가 안되는 경우가 있습니다.

마냥냥냥
2021.04.06
@스크립터브혼

도움이 많이 됐습니다 감사합니다!

뉴스 및 창작물
/files/thumbnails/520/751/003/262x150.crop.jpg?20240328020349

레드스톤

마인크래프트 노트블록으로 만든 『 Bling‐Bang‐Bang‐Born 』 1

Sonttukk

2024-03-23

1

/files/thumbnails/467/742/003/262x150.crop.jpg?20240311163123

레드스톤

[노트블럭커버] MILGRAM -ミルグラム(밀그램)- / 아마네 「숙청 행진」 제 2심 2

리비온

2024-03-11

0

/files/thumbnails/846/741/003/262x150.crop.jpg?20240310221214

레드스톤

워든 vs 라마 200마리 1

GlassesFilm

2024-03-10

0

/files/thumbnails/542/739/003/262x150.crop.jpg?20240309070457

레드스톤

[고인의 명복을 빕니다][노트블럭]드래곤볼 GT 오프닝 - 점점 마음이 끌려

리비온

2024-03-09

0

/files/thumbnails/326/738/003/262x150.crop.jpg?20240328020414

레드스톤

마인크래프트 노트블록으로 만든 『 Build Our Machine 』

Sonttukk

2024-03-07

0