개인 자료란 (JE)

  서버 커뮤니티

Profile ysj5896 대표칭호 없음
Profile

질문하기 스크립트

무기 데미지 설정

2023.02.24 조회 수 660 추천 수 0
이해도 초보자 
게임버전 (JE) 1.19.3 
게임버전 (BE) 관련없음 

command /무기설정 [<integer>]:

    trigger:

        player is op:

            if arg 1 is not set:

                message "&f/무기설정 &c<공격력>"

            else:

                if player's tool is air:

                    message "&c손에 장비를 들어주세요."

                else:

                    set the 5st line of player's tool' lore to "&c▩ 공격력 : %arg 1%"

                    message "&c무기스탯을 설정했습니다."


on damage:

    if attacker is player:

        set {_lore::*} to uncolored lore of attacker's tool 

        loop {_lore::*}:

            if loop-value contains "▩ 공격력 :":

                set {at} to loop-value

                replace all "▩ 공격력 : " with "" in {at}

                set {at} to {at} parsed as number

        if attacker's tool is wooden sword or diamond sword or iron sword or stone sword or golden sword:

            if {at} is set:

                set {_at2} to mod({at}/2,{at}) # {at2}에 {at}/2 값을 넣음

                set damage to random number between {_at2} to {at}

        else:

            set damage to random number between 0.01 to 1 

이런식으로 무기에 공격력 lore 가 붙은 검에만 설정한 데미지가 나오게 하고 

다른 것들은 다 0.01~1 사이의 데미지만 나오게 짠 것 같은데..

공격력 lore가 붙지 않은 무기들도 데미지가 0.01~1 사이가 아니라 다른 무기에  설정한 공격력이 설정이 되네요...

이유가 뭔가요?? 

3개의 댓글

qsef1256
2023.02.24

{at}가 전역 변수라서요. 스크립트에서 {a} 같이 그냥 적은 변수는 전역 변수고 전역 변수는 지우지 않은 이상 계속 남아요.

ysj5896
2023.02.24
@qsef1256

그럼 _넣어서 바꾸면 될까요? 혹시

set {_at2} to mod({at}/2,{at}) # {at2}에 {at}/2 값을 넣음

 

set damage to random number between {_at2} to {at}

여기 구문을 효과를 빼고 싶진 않은데 어떻게 바꾸면 좋을까요..

ysj5896
2023.02.24
@qsef1256

해결했습니다 감사합니다!!!

뉴스 및 창작물
/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

/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