개인 자료란 (JE)

  서버 커뮤니티

Profile 데빌하트 대표칭호 없음

D3VILH4RRT a4b5e1bfdef74b93af06cbd3c8b3f76b

Profile

질문하기 스크립트

스크립트 random integer에 대해서 알고 싶은데

2023.11.16 조회 수 28 추천 수 0
이해도 입문자 
게임버전 (JE) 1.20.1 
게임버전 (BE) 관련없음 
스크립트 버전 2.7.2 

options:

    o : of current inventory of player

command /광부상점:

    trigger:

        open chest with 6 row named "&1&l광부상점" to player

        set {_slot} to 0

        loop 54 times:

            set slot {_slot} {@o} to black stained glass pane

            add 1 to {_slot}

        set slot 19 {@o} to copper ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : %{상점.광부.판매가격::1}%원" and "&6가격 변동 : %{상점.광부.판매전가격::1}%" and "&e좌클릭 구매/우클릭 판매"

        

on inventory click:

    if inventory name is "&1&l광부상점":

        cancel event

        if clicked item is black stained glass pane:

        else:

            if click type is right mouse button:

                if clicked raw slot is smaller than 54:

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

                    replace all "판매가격" and ":" and " " and "원" and "가격 변동" 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 {%uuid of player%.돈}

                        play sound "entity.experience_orb.pickup" with volume 0.5 and pitch 3 to the player

                    else:

                        send "&c현재 해당 아이템을 가지고 있지 않아 판매할 수 없습니다." to player

                        play sound "UI_BUTTON_CLICK" with volume 0.3 and pitch 3 to the player


on load:

    set {상점.광부.개수} to 1 #광부상점 구문 set slot 구문 숫자만큼 셋팅 (유리 제외)

    loop {상점.광부.개수} times:

        add 1 to {_int} 

        set {상점.광부.판매가격::%{_int}%} to 6

        set {상점.광부.판매전가격::%{_int}%} to "&70"


every 30 seconds:

    loop {상점.광부.개수} times:

        add 1 to {_int.1}

        set {_int} to random integer between -20 and 30

        add {_int} to {상점.광부.판매가격::%{_int.1}%}

        if {_int} is between -30 and -1:

            set {상점.광부.판매전가격::%{_int.1}%} to "&c%{_int}%"

        if {_int} is 0:

            set {상점.광부.판매전가격::%{_int.1}%} to "&70"

        if {_int} is between 1 and 30:

            set {상점.광부.판매전가격::%{_int.1}%} to "&a+%{_int}%"

        if {상점.광부.판매전가격::%{_int.1}%} <= 0:

            set {상점.광부.판매전가격::%{_int.1}%} to 100 


    send "&e[광부상점] 시세가 변동되었습니다!" to all players # 플레이어에게 변동 알림 전송

on rightclick on entity:

    if entity's name is "광부":

        player command "광부상점"


시세 상점 스크립트의 구문인데  보면 구리 주괴가 초기 금액이 6원인데

하양 했을 때 최대 1원까지 떨어지고 상향 했을 때 최대 15원까지 올라가게 하고 싶은데

아무리 만져봐도 상향 하면 10원을 넘어서고 하양 하면  -까지 내려서 가서 어떻게 해야 할지 모르겠는데 

잘 아시는 분 있나요?





3개의 댓글

코코냐
2023.11.16

일단 계산한 뒤에 범위 밖이면 강제로 범위 안으로 넣죠..?

데빌하트
2023.11.16
@코코냐

알려주신 바탕으로 만들어서 15원이 안 넘어가게 는 만들었는데  예를 들어 이전 가격이 14원일떄 다음 가격이 상향한다고 하면 15원 고정인데 상향 값이 +1뿐만 아니라 +2나 +8이여도 15원으로 되니까 불편한데 방법없나요

코코냐
2023.11.17
@데빌하트

몇부터 벗어냐는지 계산해서 범위 자체를 유동적으로 하면 되죠..?

뉴스 및 창작물
/files/thumbnails/268/789/003/262x150.crop.jpg?20240515192032

레드스톤

벌레먹은 돌 빠르게 제거하는 법

GlassesFilm

2024-05-15

0

/files/thumbnails/797/788/003/262x150.crop.jpg?20240515090924

건축

마인크래프트로 구현한 카르카손 보드게임

Warak

2024-05-15

1

/files/thumbnails/487/784/003/262x150.crop.jpg?20240508233607

모드

Windows Borderless 모드에서 악성코드 발견

학교가기싫다

2024-05-08

1

/files/thumbnails/384/778/003/262x150.crop.jpg?20240512002324

업데이트

마인크래프트 자바 에디션 스냅샷 24w18a

학교가기싫다

2024-05-06

0

/files/thumbnails/855/781/003/262x150.crop.jpg?20240505141129

레드스톤

레이저 클리너

GlassesFilm

2024-05-05

1