Skocz do zawartości
  • 0

Enchant z loop-index


DaWiHsS

Pytanie

Więc mam coś takiego:

loop 3 times:
	set {_num} to loop-number
(...)
	loop {customEnchant.%player%.ench%{_num}%::*}:
		send loop-index to player
		enchant slot 37 of player's current inventory with loop-index 1

I nie chce to działać, zarówno gdy użyję (linijka z enchant slot 37) :

with %loop-index% 1
with %{loop-index}% 1
with (loop-index parsed as enchant) 1
with (loop-index parsed as text) 1
with (%loop-index% parsed as enchant) 1
with (%{loop-index}% parsed as text) 1

Mimo tego, że tuż pod tym mam:

loop {customEnchant.%player%.ench%{_num}%::*}:
	send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player

I działa to bez problemów.
Błąd wyrzuca że albo nie znalazło pętli z możliwością loop-index albo że nie rozumie tego warunku/efektu

W zmiennej ench%{_num}%:: są takie rzeczy jak

::sharpness
::unbreaking
::bane of arthropods
.
.
.

Jak teraz mogę z indexów 
::sharpness (watość: 5)
zrobić 
enchant <item> with sharpness 5

Edytowane przez DaWiHsS
Wyrzucone przypadkowe emotki z nawiasu zamykającego
Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/
Udostępnij na innych stronach

13 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Ja tu chciałbym tylko dodać że zmiennych nie tworzy się w ten sposób:

{customEnchant.%player%.ench%{_num}%::*}

Poprawnie zdefiniowana zmienna powinna mieć każdy indeks oddzielony dwukropkami A NIE KROPKAMI. Dwukropki pozwalają potem te zmienne w dowolnym punkcie zapętlać i pracować na ich pod-zmiennych, powinno to wyglądać tak:

{customEnchant::%player%::ench%{_num}%::*}

Ważna jest też kolejność zapisu poszczególnych indeksów - powinno się je tworzyć tak, aby mieć łatwy dostęp do wszystkich indeksów i wartości oraz aby nie tworzyć nadmiaru zmiennych.

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237171
Udostępnij na innych stronach

  • 0
5 godzin temu, xAxee napisał:

(loop-index parsed as enchantment) 

 

enchant slot 37 of player's current inventory with (loop-index parsed as enchantment) 1 
Can't understand this condition/effect: enchant slot 37 of player's current inventory with (loop-index parsed as enchantment) 1

Still coś nie halo

 

52 minuty temu, PanMaruda napisał:

Poprawnie zdefiniowana zmienna powinna mieć każdy indeks oddzielony dwukropkami A NIE KROPKAMI. Dwukropki pozwalają potem te zmienne w dowolnym punkcie zapętlać i pracować na ich pod-zmiennych, powinno to wyglądać tak:


{customEnchant::%player%::ench%{_num}%::*}

 

Ma to sens.
Ma to bardzo duży sens. Zwrócę na to uwagę, dzięki :3

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237173
Udostępnij na innych stronach

  • 0
1 godzinę temu, PanMaruda napisał:

Dwukropki pozwalają potem te zmienne w dowolnym punkcie zapętlać i pracować na ich pod-zmiennych

Niestety tak pięknie nie jest :< i można jedynie zapętlać ostatni index (chyba że naprawili to w wersjach 2.2+ (jak tak to sorka))

command /test:
	trigger:
		loop ("elo" and "lol", "qwert", "asdas"):
			loop 15 times:
				set {test::%loop-value-1%::%loop-number%} to 0
		loop {test::*}:
			send "%loop-index%" #Nic nie wyświetli
		send "%{test::*}%" #Wyświetli 4x <none>
command /test:
	trigger:
		loop ("elo" and "lol", "qwert", "asdas"):
			loop 15 times:
				set {test::%loop-value-1%::%loop-number%} to 0
		loop {test::elo::*}:
			send "%loop-index%" #Wyswietli liczby od 1 do 15
		send "%{test::elo::*}%" #Wyswietli 15x 0
7 godzin temu, DaWiHsS napisał:

Jak teraz mogę z indexów 
::sharpness (watość: 5)
zrobić 
enchant <item> with sharpness 5

enchant %item% with ("%loop-index% %loop-value%" parsed as enchantment type)

 

Edytowane przez xAxee
Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237185
Udostępnij na innych stronach

  • 0
39 minut temu, xAxee napisał:

 


enchant %item% with ("%loop-index% %loop-value%" parsed as enchantment type)

 

enchant slot (round(34 + 3*{_num})) of player's current inventory with ("sharpness 2" parsed as enchantment type)

enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type) 

Pierwsza linijka działa, druga natomiast ni chu.

Can't understand this condition/effect: enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type)

 

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237195
Udostępnij na innych stronach

  • 0
21 minut temu, DaWiHsS napisał:

enchant slot (round(34 + 3*{_num})) of player's current inventory with ("sharpness 2" parsed as enchantment type)

enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type) 

Pierwsza linijka działa, druga natomiast ni chu.


Can't understand this condition/effect: enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type)

 

hmm no a dlaczego tam sie odwołujesz do kolejnego loopa.
podaj cały kod jaki masz zobacze u mnie

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237196
Udostępnij na innych stronach

  • 0
46 minut temu, xAxee napisał:

hmm no a dlaczego tam sie odwołujesz do kolejnego loopa.
podaj cały kod jaki masz zobacze u mnie

(...)	
	loop 3 times:
		(...)
		loop {horoEnchant::%player%::ench%{_num}%::*}:
			enchant slot (round(34 + 3*{_num})) of player's current inventory with ("sharpness 2" parsed as enchantment type)
			enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type) ### NIE DZIAŁA
			send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player ## działa bez zarzutów

 

Cały kod:

Spoiler


on right click on enchantment table:
    cancel event
    if block below is bookshelf:
        open chest with 6 row named "&4&lTest Enchanting" to player
        loop 9*6 times:
            set slot loop-number of player's current inventory to stone named "%loop-number%"
        exit
    set {horoEnchant::%player%::bookshelves} to 0
    loop all blocks in radius 3 around event-block: # do obliczenia maks. poziomu enchantu
        if loop-block is a bookshelf:
            add 1 to {horoEnchant::%player%::bookshelves}
    send "Bookshelves: %{horoEnchant::%player%::bookshelves}%" to player #DEBUG
    open virtual chest with 6 row named "&4&lEnchanting" to player
    set slot (13,21,23 and 31) of player's current inventory to blue glass pane named " " # otoczka
    set slot 37 of player's current inventory to experience bottle named "0"
    set slot 40 of player's current inventory to experience bottle named "0"
    set slot 43 of player's current inventory to experience bottle named "0"
    set slot (0,8,45 and 53) of player's current inventory to white glass pane named " " # rogi
    set slot (1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,18,19,20,24,25,26,27,28,29,30,32,33,34,35,36,38,39,41,42,44,46,47,48,49,50,51 and 52) of player's current inventory to black glass pane named " "
    

on inventory click:
    if event-inventory's name is "&4&lEnchanting":
        if event-slot is not (22, 37, 40 or 43):
            cancel event
        else:
            if event-slot is 22:
                wait 2 tick
                set {_item} to slot 22 of current inventory of player
                if {_item} is enchanted:
                    send "Cant enchant enchanted item" to player
                    exit
                if {_item} is any tool:
                    send "TOOL" to event-player
                else if {_item} is any sword:
                    send "SWORD" to player
                    set {_maxLvl} to {horoEnchant::%player%::bookshelves} * 2
                    loop 3 times:
                        # Roll 1
                        set {_num} to loop-number
                        set {horoEnchant::%player%::ench%{_num}%::lvl} to {_maxLvl} * {_num} / 3
                        # X
                        set {_rollx} to random number from 0 to 100
                        if {_rollx} < 40:
                            set {horoEnchant::%player%::ench%{_num}%::sharpness} to getSharp({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player)
                        else if {_rollx} < 60:
                            set {horoEnchant::%player%::ench%{_num}%::smite} to get410Ench({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player)
                        else if {_rollx} < 80:
                            set {horoEnchant::%player%::ench%{_num}%::bane of arthropods} to get410Ench({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player)
                        # Y
                        set {_rolly} to random number from 0 to 100
                        if {_rolly} < 30:
                            set {horoEnchant::%player%::ench%{_num}%::fire aspect} to get2lvlEnch({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player,9,18)
                        else if {_rolly} < 60:
                            set {horoEnchant::%player%::ench%{_num}%::knockback} to get2lvlEnch({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player,8,16)
                        else if {_rolly} < 90:
                            set {horoEnchant::%player%::ench%{_num}%::looting} to get3lvlEnch({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player,8,16,24)
                        # Z
                        set {_rollz} to random number from 0 to 100
                        if {_rollz} < 10:
                            if {horoEnchant::%player%::ench%{_num}%::lvl} >= 44:
                                set {horoEnchant::%player%::ench%{_num}%::mending} to 1
                        else if {rollz} < 80:
                            set {horoEnchant::%player%::ench%{_num}%::unbreaking} to get3lvlEnch({horoEnchant::%player%::ench%{_num}%::lvl},{_num},event-player,6,14,24)
                        
                        set slot (round(34 + 3*{_num})) of player's current inventory to experience bottle named "%{_maxLvl} * {_num} / 3%"
                        loop {horoEnchant::%player%::ench%{_num}%::*}:
                            enchant slot (round(34 + 3*{_num})) of player's current inventory with ("sharpness 2" parsed as enchantment type)
                            enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type) ### NIE DZIAŁA
                            send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player

                        send "======" to player
                        # loop {horoEnchant::%player%::ench%{_num}%::*}:
                        #     send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player

                else if {_item} is a bow:
                    send "BOW" to player

                else if {_item} is a fishing rod:
                    send "ROD" to player
                else if {_item} is a shear:
                    send "SHEAR" to player
                else if {_item} is any armor:
                    send "ARMOR" to player
                else:
                    send "NOT FOUND/OPERABLE: %{_item}%" to player
                    delete {horoEnchant::%player%::ench1::*}
                    delete {horoEnchant::%player%::ench2::*}
                    delete {horoEnchant::%player%::ench3::*}
                    send "Roll: %{_roll1}%, lvl: %{horoEnchant::%player%::ench1::lvl}%" to player

on inventory close:
    if event-inventory's name is "&4&lEnchanting":
        set {_closeItem} to slot 22 of current inventory of player
        if {_closeItem} is air:
            send "Clear" to player
        else:
            send "Not clear" to player
            if player has enough space for {_closeItem}:
                send "Space" to player
                give {_closeItem} to player
            else:
                send "Not space" to player
                drop {_closeItem} at player's location
        delete {horoEnchant::%player%::*}
        

function getSharp(lvl:number,ench:number,player:player) :: number:
    if {_lvl} >= 21:
        if {_lvl} >= 32:
            if {_lvl} >= 45:
                reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 45
                return 5
            else:
                reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 32
                return 4
        else:
            reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 21
            return 3
    else if {_lvl} >= 12:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 12
        return 2
    else if {_lvl} >= 5:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 5
        return 1
    else:
        return 0

function get410Ench(lvl:number,ench:number,player:player) :: number:
    if {_lvl} >= 18:
        if {_lvl} >= 28:
            if {_lvl} >= 40:
                reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 40
                return 5
            else:
                reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 28
                return 4
        else:
            reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 18
            return 3
    else if {_lvl} >= 12:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 10
        return 2
    else if {_lvl} >= 5:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by 4
        return 1
    else:
        return 0

function get2lvlEnch(lvl:number,ench:number,player:player,lvl1:number,lvl2:number) :: number:
    if {_lvl} >= {_lvl2}:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by {_lvl2}
        return 2
    else if {_lvl} >= {_lvl1}:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by {_lvl1}
        return 1
    else:
        return 0

function get3lvlEnch(lvl:number,ench:number,player:player,lvl1:number,lvl2:number,lvl3:number) :: number:
    if {_lvl} >= {_lvl2}:
        if {_lvl} >= {_lvl3}:
            reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by {_lvl3}
            return 3
        else:
            reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by {_lvl2}
            return 2
    else if {_lvl} >= {_lvl1}:
        reduce {horoEnchant::%{_player}%::ench%{_ench}%::lvl} by {_lvl1}
        return 1
    else:
        return 0

 

 

Edytowane przez DaWiHsS
błąd wcięcia kodu
Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237197
Udostępnij na innych stronach

  • 0

Eeeeeeeeeeeeeee
dafuq.
Właśnie zrobiłem update, z
spigot 1.12 i skript <nie wiem>
przeszedłem na
spigot 1.12.2 i skript 2.4.1.

Błędy takie same wyskoczyły.

Ale. Zauważyłem jeden problem.
Dlaczego linijka 1 nie działa a 2 tak?
 

send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player ## działa bez zarzutów
send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player

Usunąłem komentarz i błąd zniknął.
Like.
Dlaczego. xD 
Nie interpretuje polskich znaków w komentarzach? :v

W każdym razie, usunąłem komentarz przy 

enchant slot (round(34 + 3*{_num})) of player's current inventory with ("%loop-index% %loop-value-2%" parsed as enchantment type)

i błąd zniknął, działa jak powinno.
 

Dlatego to:

W dniu 28.02.2020 o 19:23, xAxee napisał:

enchant %item% with ("%loop-index% %loop-value%" parsed as enchantment type)

 

Jest jednak rozwiązaniem, a na komentarze trzeba uważać

Axee, chcesz naj czy dać do tego wpisu?

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237327
Udostępnij na innych stronach

  • 0
14 minut temu, DaWiHsS napisał:

spigot 1.12.2 i skript 2.4.1.

do 1.12.2 skript maksymalnie w wersji 2.3, reszta jest na nowsze wersje 1.13+

15 minut temu, DaWiHsS napisał:

send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player ## działa bez zarzutów
send "Ench nr.%{_num}% Key: %loop-index% Value: %loop-value-2%" to player

Usunąłem komentarz i błąd zniknął.
Nie interpretuje polskich znaków w komentarzach? :v

Bo komentarz zapisuje się jako jeden znak #, podwójny oznacza, że chcesz aby składnia go zawierała.

Odnośnik do komentarza
https://skript.pl/temat/37258-enchant-z-loop-index/#findComment-237333
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...