개인 자료란 (JE)

  서버 커뮤니티

Profile 먀먀사사상 대표칭호 없음
Profile

질문하기 스크립트

gui 상점 스크립트 관련 질문입니다.

2023.05.29 조회 수 82 추천 수 0
이해도 입문자 
게임버전 (JE) 1.16.5 
게임버전 (BE) 관련없음 
스크립트 버전 2.6.4 

안녕하세요. 이번에 유튜브를 보며 처음으로 스크립트를 한 번 만들어봤습니다.


command /상점:

    trigger:

        open chest with 3 rows named "&b상점" to player

        set slot 0 of current inventory of player to salmon with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 1 of current inventory of player to potato with lore "&e매매 가격: 3000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 2 of current inventory of player to baked potato with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 3 of current inventory of player to beetroot with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 4 of current inventory of player to iron ingot with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 5 of current inventory of player to gold ingot with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 6 of current inventory of player to diamond with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 7 of current inventory of player to lapis lazuli with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 8 of current inventory of player to emerald with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 9 of current inventory of player to wheat with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 10 of current inventory of player to carrot with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        set slot 11 of current inventory of player to cod with lore "&e매매 가격: 1000원" and "&b좌클릭시 구매합니다." and "&c우클릭시 판매합니다."

        

on inventory click:

    if inventory name is "&b상점":

        cancel event

        if clicked item is not air:

        if clicked raw slot is smaller than 17:

            if click type is left mouse button:

                set {_lore} to uncolored line 1 of lore of clicked item

                replace all "매매 가격: " and "원" with "" in {_lore}

                set {_lore} to {_lore} parsed as integer

                if {%player%.돈} is smaller than {_lore}:

                    message "&c돈이 부족해 해당 아이템을 구매할 수 없습니다."

                else:

                    set {_item} to clicked item

                    delete lore of {_item}

                    give {_item} to player

                    subtract {_lore} from {%player%.돈}

            else if click type is right mouse button:

                set {_lore} to uncolored line 1 of lore of clicked item

                replace all "매매 가격: " and "원" with "" in {_lore}

                set {_lore} to {_lore} parsed as integer

                set {_item} to clicked item

                delete lore of {_item}

                if player has 1 of {_item}:

                    remove 1 of {_item} from player's inventory

                    add {_lore} to {%player%.돈}

                else:

                    message "&c당신은 해당 아이템을 가지고 있지 않아 판매할 수 없습니다."

                   


이 스크립트를 사용한 상점에서는 구매가와 판매가를 변경할 수 없습니다.

혹시 구매가와 판매가를 따로따로 변경할 수 있게 하려면 어떻게 바꿔야 할까요??


여기저기 찾아봤는데 모르겠어서 질문한 번 해봅니다....





3개의 댓글

거너아나
2023.05.29

"&e매매 가격: 1000원" 를 "&e매매 가격: %{변수이름}%%원" 으로 하신 다음 {변수이름}을 변경하시면 됩니다

먀먀사사상
2023.05.29
@거너아나

안녕하세요. 우선 답변 감사합니다!

알려주신 대로 가격을 변경해보니 가격 변경은 됩니다! 다만 제 질문 의도는 이게 아니라 분리해서 변경을 하고 싶다는 의도였는데 혹시 구매가 따로 판매가 따로 변경을 하려면 스크립트를 완전히 다시 만들어야 하는 건가요??

거너아나
2023.05.30
@먀먀사사상

아마 그게 더 빠를 것입니다

아니면 인터넷에서 하나 얻는게 더 빠를듯

뉴스 및 창작물
/files/thumbnails/855/781/003/262x150.crop.jpg?20240505141129

레드스톤

레이저 클리너

GlassesFilm

2024-05-05

0

/files/thumbnails/576/775/003/262x150.crop.jpg?20240426232553

아티클

이달의 블록: 단단한 진흙

학교가기싫다

2024-04-26

0

/files/thumbnails/115/774/003/262x150.crop.jpg?20240428135129

업데이트

마인크래프트 1.20.5 정식 업데이트

학교가기싫다

2024-04-24

0

/files/thumbnails/762/770/003/262x150.crop.jpg?20240418073724

레드스톤

T.B.H (고민중독) | 노트블럭 버전 | NoteBlock Cover [한국어 영어 중국어 가사 추가]

노트블럭전문가

2024-04-18

0

/files/thumbnails/218/767/003/262x150.crop.jpg?20240412130213

레드스톤

우리의 꿈 - 원피스 오프닝

노트블럭전문가

2024-04-12

0