set {_행운석스탯::*} to uncolored lore of slot 31 of current inventory of player
replace all " " and "강화" and "확률을" and "%" and "올려줍니다." with "" in {_행운석스탯::1}
set {_행운석스탯} to {_행운석스탯::1} parsed as number
이렇게 해주면 확률만 {_행운석스탯::1}에 저장되겠죠
그럼 행운석이 아닌 다른 아이템을 올렸을 때 진행이 안되야겠죠
if slot 31 of current inventory of player is not air:
if {_행운석스탯::3} is not "행운석":
message "[무기대장장이]: 행운석 자리에 이상한걸 넣었군" to player
exit
# 행운석 정보를 변수에 대입
set {_행운석스탯::*} to uncolored lore of slot 31 of current inventory of player
replace all " " and "강화" and "확률을" and "%%" and "올려줍니다." with "" in {_행운석스탯::1}
set {_행운석스탯} to {_행운석스탯::1} parsed as number
set {_luckitem} to slot 31 of current inventory of player
if {_luckitem} is not air:
if {_행운석스탯::3} is not "행운석":
message "[무기대장장이]: 행운석 자리에 이상한걸 넣었군" to player
exit
코드를 수정해서 원하는대로 만들었습니다.
행운석 자리에 행운석이 아닌 아이템을 넣으면 안되도록 했고
넣으면 의도한대로 되야겠죠
set {_강화확률} to {_강화확률} + {_행운석스탯}
이거 한줄과
play sound "BLOCK_ANVIL_DESTROY" with volume 1 and pitch 1 at player
launch burst colored white at player timed 0.1
chance of 10%:
message "[무기대장장이]: 이런, 강화 단계가 내려갔다..." to player
delete slot 20 of current inventory of player
set slot 24 of current inventory of player to {_아이템} with lore " " and "&b%{_강화단계} - 1%단계" and "&e==========" and "&a + 체력 %{_강화체력} - 0.5%" and "&c + 공격력 %{_강화공격력} - 1%" and "&9 + 방어력 %{_강화방어력} - 0.8%" and "&e=========="
exit
else:
message "[무기대장장이]: 으음, 강화에 실패했군. 다음엔 성공하길 바래" to player
exit
else:
set {_enc} to transEnchant({_enclore::1}) parsed as enchantment
set {_pitemenlv} to enchant level of {_enc} of {_pitem}
set {_isMax} to isMaxEnchant({_enclore::1}, {_pitemenlv}, player)
if {_isMax} is false:
delete slot 20 of current inventory of player
delete slot 24 of current inventory of player
wait 12 tick
set {_amount} to {_am} - 1
set slot 24 of current inventory of player to {_amount} of {_encitem}
enchant {_pitem} with "%{_enc}% %{_pitemenlv} + 1%" parsed as enchantment type
set slot 20 of current inventory of player to {_pitem}
subtract 50000 from player's money
message "[무기대장장이]: 아이템의 인챈트가 강화되었다. 잘쓰라고!" to player
play sound "BLOCK_ANVIL_USE" with volume 1 and pitch 1 at player
launch flickering ball colored red and yellow and green at player's location timed 0.8
exit
else:
message "[무기대장장이]: 음, 이 무기의 %{_enclore::1}% 인챈트는 더이상 올릴 수 없어." to player
exit
# 인챈트 한계치
function isMaxEnchant(s: string, i: number, p: player) :: boolean:
#message "%{_s}%, %{_i}%" to {_p}
if {_s} is "보호" or "화염 보호":
if {_i} = 6:
return true
else:
return false
한계치인지 아닌지 확인하는 함수를 만들어봤습니다.
일단 보호나 화염 보호레벨이 6이면 true를 줘서
강화하는 스크립트에 true면 할 수 없다고 뜨게하고 false면 그대로 진행하도록 했습니다.
이제 남은건 저 목록을 일일이 정하는거죠
# 인챈트 한계치
function isMaxEnchant(s: string, i: number, p: player) :: boolean:
#message "%{_s}%, %{_i}%" to {_p}
if {_s} is "수선":
if {_i} = 2:
return true
else:
return false
else if {_s} is "차가운 걸음":
if {_i} = 3:
return true
else:
return false
else if {_s} is "호흡" or "발화" or "빠른 장전" or "충절" or "행운" or "바다의 행운" or "미끼":
if {_i} = 4:
return true
else:
return false
else if {_s} is "약탈" or "밀치기" or "휘몰아치는 칼날" or "밀어내기" or "관통" or "급류" or "가시" or "가벼운 착지" or "내구성":
if {_i} = 5:
return true
else:
return false
else if {_s} is "보호" or "화염으로부터 보호" or "폭발로부터 보호" or "발사체로부터 보호":
if {_i} = 6:
return true
else:
return false
else if {_s} is "날카로움" or "강타" or "살충" or "힘" or "찌르기" or "효율":
if {_i} = 7:
return true
else:
return false
on rightclick on sign:
if line 1 is "test":
open chest with 1 rows named "test" to player
set slot 0 of current inventory of player to anvil named "test"
on inventory click:
if iname contains "test":
if click type is left mouse button with shift or right mouse button with shift or right mouse button:
cancel event
else:
if clicked raw slot is 0:
cancel event
set {_x} to slot 8 of current inventory of player
message "%{_x}%"
먼저 {_x}에 slot 8의 아이템 정보를 넣었고 amount of 로 {_x}의 양을 가져왔으니 slot 8에 있는
아이템의 수량만 가져오는건데 왜 전에 이상하게 생각했을까요 ㅋㅋㅋ
delete slot 8 of current inventory of player
만약 이렇게 써버리면 slot 8의 아이템은 통째로 삭제됩니다. 복구도 못해요.
보통 게임에서 원하는 수량만 없애지 통으로 없애지는 않죠
remove라는 문법이 있다고 하는데 저는 사용하지 않겠습니다.
오류가 떠서 잘 안되요. 제가 이해를 못하는건지...
여튼 제가 하려는 방법은 delete로 다 없애고
{_i} - 1만큼 set으로 다시 설정하는겁니다.
그럼 결과적으로 1만큼 없어진거죠.
set {_i} to amount of {_x} in current inventory of player - 1
위 사진의 코드 뒤에 - 1을 붙혔습니다.
이렇게 안하면 코드를 한줄 더 적어야하니까 미리 -1을 해놓는거죠.
set {_x} to slot 8 of current inventory of player
set {_i} to amount of {_x} in current inventory of player - 1
delete slot 8 of current inventory of player
wait 4 tick
set slot 8 of current inventory of player to {_i} of {_x}
시각적인 효과와 오류 방지를 위해 wait 4 tick을 주고
set slot 8 of current inventory of player to {_i} of {_x}
을 입력하여 원래 있던 수량 - 1 만큼 재설정하는 효과를 줬습니다.
만약 계속 버튼을 눌러 없애면 0 이하로 내려가 음수가 되는게 아니라
그냥 없어지고 air로 바뀝니다.
이걸 응용하면 수량을 요구하는 스크립트, 교환 등등 스크립트를 만들 수 있겠네요.
※ 스크립트 다운로드 ※
on rightclick on sign:
if line 1 is "test":
open chest with 1 rows named "test" to player
set slot 0 of current inventory of player to anvil named "test"
on inventory click:
if iname contains "test":
if click type is left mouse button with shift or right mouse button with shift or right mouse button:
cancel event
else:
if clicked raw slot is 0:
cancel event
set {_x} to slot 8 of current inventory of player
set {_i} to amount of {_x} in current inventory of player - 1
delete slot 8 of current inventory of player
wait 4 tick
set slot 8 of current inventory of player to {_i} of {_x}