개인 자료란 (JE)

  서버 커뮤니티

Profile qwesx 대표칭호 없음

mnmn102030 21481da6061b41109425ca94be366a4d

Profile

질문하기 스크립트

방어구에 체력이 적용이 안돼요.

2022.08.19 조회 수 91 추천 수 0
게임버전 (JE) 1.12.2 
게임버전 (BE) 관련없음 

command /방어구설정 [<integer>] [<integer>]:

    trigger:

        if player is op:

            if arg-1 is not set:

                message "&6/방어구설정 <방어력> <체력>"

            else:

                if player's tool is air:

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

                else:

                    if arg-1 is not 0:

                        add "&3■방어력: %arg-1%" to lore of player's tool

                    if arg-2 is not 0:

                        add "&6■체력: %arg-2%" to lore of player's tool

every 1 second:

    loop all players:

        if loop-player's chestplate is not air:

            set {_lore::*} to uncolored lore of loop-player's helmet

            loop {_lore::*}:

                if loop-value-1 contains "■체력:":

                    set {_lr} to loop-value-1

                    replace all "■체력: " and ":" and " " with "" in {_lr}

                    set {_lr} to {_lr} parsed as number

                    add {_lr} to {_hp}

        

            set {_lore::*} to uncolored lore of loop-player's chestplate

            loop {_lore::*}:

                if loop-value-1 contains "■체력:":

                    set {_lr} to loop-value-1

                    replace all "■체력: " and ":" and " " with "" in {_lr}

                    set {_lr} to {_lr} parsed as number

                    add {_lr} to {_hp}

        

            set {_lore::*} to uncolored lore of loop-player's leggings

            loop {_lore::*}:

                if loop-value-1 contains "■체력:":

                    set {_lr} to loop-value-1

                    replace all "■체력: " and ":" and " " with "" in {_lr}

                    set {_lr} to {_lr} parsed as number

                    add {_lr} to {_hp}

        

            set {_lore::*} to uncolored lore of loop-player's boots        

            loop {_lore::*}:

                if loop-value-1 contains "■체력:":

                    set {_lr} to loop-value-1

                    replace all "■체력: " and ":" and " " with "" in {_lr}

                    set {_lr} to {_lr} parsed as number

                    add {_lr} to {_hp}

                    

every 1 tick:

    loop all players:

        set loop-player's max health to 10 + {_hp}*0.5
적용이 안되는 이유 좀 알려주세요.




9개의 댓글

코코냐
2022.08.19

파싱한 값이 뭔지 확인해보세요.

qwesx
2022.08.19
@코코냐

command /방어구설정 [] []:

trigger:

if player is op:

if arg-1 is not set:

message "&6/방어구설정 <방어력> <체력>"

else:

if player's tool is air:

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

else:

if arg-1 is not 0:

add "&3■방어력: %arg-1%" to lore of player's tool

if arg-2 is not 0:

add "&6■체력: %arg-2%" to lore of player's tool

every 1 second:

loop all players:

if loop-player's helmet is not air:

set {_lore::*} to uncolored lore of loop-player's helmet

loop {_lore::*}:

if loop-value-2 contains "■체력:":

set {_hp} to loop-value-2

replace all "■체력: " and ":" and " " with "" in {_hp}

set {_hp1} to {_hp} parsed as number

add {_hp1} to {hp4}

else:

delete {hp4}

every 1 second:

loop all players:

if loop-player's chestplate is not air:

set {_lore::*} to uncolored lore of loop-player's chestplate

loop {_lore::*}:

if loop-value-2 contains "■체력:":

set {_hp} to loop-value-2

replace all "■체력: " and ":" and " " with "" in {_hp}

set {_hp2} to {_hp} parsed as number

add {_hp2} to {hp3}

else:

delete {hp3}

every 1 second:

loop all players:

if loop-player's leggings is not air:

set {_lore::*} to uncolored lore of loop-player's leggings

loop {_lore::*}:

if loop-value-2 contains "■체력:":

set {_hp} to loop-value-2

replace all "■체력: " and ":" and " " with "" in {_hp}

set {_hp3} to {_hp} parsed as number

add {_hp3} to {hp2}

else:

delete {hp2}

 

every 1 second:

loop all players:

if loop-player's boots is not air:

set {_lore::*} to uncolored lore of loop-player's boots

loop {_lore::*}:

if loop-value-2 contains "■체력:":

set {_hp} to loop-value-2

replace all "■체력: " and ":" and " " with "" in {_hp}

set {_hp4} to {_hp} parsed as number

sdd {_hp4} to {hp1}

else:

delete {hp1}

이렇게 바꿨는데 체력이 계속 올라가는 이유을 아시나요?

qsef1256
2022.08.19
@qwesx

줄 맞춰서 올리세요. 스크립트는 들여쓰기가 매우 중요한 거 모르시나요?

qsef1256
2022.08.19
@qwesx

그리고 맨 밑에 sdd {_hp4} to {hp1} 해 놓은 건 뭐에요? 스크립트 돌아가긴 하나요?

qsef1256
2022.08.19
@qwesx

알겠네요, hp가 계속 올라가는 건 님 구문대로 잘 돌아가고 있어서 그래요.


every 1 second:
    loop all players:
        if loop-player's boots is not air:
            set {_lore::*} to uncolored lore of loop-player's boots
            loop {_lore::*}:
                if loop-value-2 contains "■체력:":
                    set {_hp} to loop-value-2
                    replace all "■체력: " and ":" and " " with "" in {_hp}
                    set {_hp4} to {_hp} parsed as number
                    add {_hp4} to {hp1}
        else:
            delete {hp1}

님 코드를 잘 보세요. add {_hp4} to {hp1} 잘 보이시죠? 1초마다 add를 하고 있는데 안 올라가면 그게 더 이상한 거 아니에요?

qsef1256
2022.08.19

1. every 1 tick/second 쓰지 마세요. 이 구문은 특수한 경우가 아니면 하등 쓸 데가 없고 렉만 늘리는 구문입니다, 보통 다른 방법이 있어요.

2. {_hp} 는 지역 변수라 저장 안됩니다, 맨 밑의 every 1 tick에서는 없는 변수란 소립니다. 다른 언어 같으면 컴파일 단계에서 걸렸는데, 스크립트는 이거 경고를 안 해줍니다.

qwesx
2022.08.19
@qsef1256

every 1 tick/second 대신 뭘 사용해야 하나요?

qsef1256
2022.08.19
@qwesx

이 경우에는 on armor equip/unequip 쓰는 게 맞습니다

qsef1256
2022.08.19
@qwesx

그리고 on death도 확인하시는 게 좋겠네요

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

/files/thumbnails/505/766/003/262x150.crop.jpg?20240411122306

레드스톤

기동전사 건담 수성의 마녀 | 노트블럭 커버 1

노트블럭전문가

2024-04-11

1