Skocz do zawartości
  • 0

Inventory slot item


DaWiHsS

Pytanie

Próbuję zrobić nowy system Enchantowania, i potrzebuję odpowiedni event w momencie, w którym włożę item w slot 22 wirtualnej skrzyni.
Czyli otwieram "Enchant", przekładam z inv gracza do wirtualnego, i jeśli jest to slot 22, i w tym slocie jest teraz miecz to zrób A, jeśli jest kilof zrób B, jeśli zbroja C itd.

Aktualnym kodem dochodzę do momentu wskazania na opowiedni slot, ale item ma się nijak do porównania z tool albo sword.
Aktualny kod także nie wyrzuca błędów, wersja 1.12

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:
                send "EventSlot" to player
                wait 1 tick
                if player's item is tool:
                    send "TOOL" to event-player
                if event-item is a sword:
                    send "SWORD" to player

 

A tak ekwipunek wygląda ekwipunek po włożeniu miecza do 22:

Skript_ench1.PNG

 

Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/
Udostępnij na innych stronach

6 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Może ja zaproponuję to:

https://skriptlang.github.io/Skript/classes.html#inventoryaction

Wyrażenie sprawdza co dokładnie gracz zrobił - np. położył jeden item, zabrał połowę, wyrzucił wszystkie ze slota itd. przykład:

inventory click:
	if clicked item is air:
		clicked slot is 22:
			inventory action is place one:
				send "Gracz położył %cursor slot of player% w slocie 22"
jeżeli kliknięty slot jest pusty:
	jeżeli kliknięty slot ma indeks 22:
		jeżeli gracz położył w slocie jeden przedmiot:
			send ""

 

Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/#findComment-236997
Udostępnij na innych stronach

  • 0
6 godzin temu, PanMaruda napisał:

Wyrażenie sprawdza co dokładnie gracz zrobił - np. położył jeden item, zabrał połowę, wyrzucił wszystkie ze slota itd. przykład:


inventory click:
	if clicked item is air:
		clicked slot is 22:
			inventory action is place one:
				send "Gracz położył %cursor slot of player% w slocie 22"

 

Okej, akcję ja mam, nawet widać na zdj efekt zareagowania na klikniecie, co prawda nie miałem inventory action is place one:, ale dalej to nie rozwiązuje zadania sprawdzenia, co za przedmiot został wstawiony, a o to mi głównie chodzi.

Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/#findComment-237021
Udostępnij na innych stronach

  • 0
18 godzin temu, DaWiHsS napisał:

Okej, akcję ja mam, nawet widać na zdj efekt zareagowania na klikniecie, co prawda nie miałem inventory action is place one:, ale dalej to nie rozwiązuje zadania sprawdzenia, co za przedmiot został wstawiony, a o to mi głównie chodzi.

z tego co rozumiem to chcesz przedmiot pobrać przy kliknięciu w te butelki z expem?

inventory click:
	if (butelka):
		set {_item} to item in slot 22 of current inventory of player
		if {_item} is any sword:
			enchant {_item} with sharpness 5
		set slot 22 of current inventory of player to {_item}

 

Edytowane przez PanMaruda
Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/#findComment-237038
Udostępnij na innych stronach

  • 0
3 godziny temu, PanMaruda napisał:

z tego co rozumiem to chcesz przedmiot pobrać przy kliknięciu w te butelki z expem?

... nie w tym momencie, ale moment po położeniu.
Myślałem żeby wykorzystać wait 1 tick, tylko nie mogłem porównać przedmiotu ze slotu 22.
 

3 godziny temu, PanMaruda napisał:

 


		set {_item} to item in slot 22 of current inventory of player

 

Wyrzuca błąd:
Can't understand this expression: 'item in slot 22 of current inventory of player' (<<<>>>.sk, line 38: set {_item} to item in slot 22 of current inventory of player')

 

Bardziej myślę jak już to nad:

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:
                send "EventSlot" to player
                wait 1 tick
                set {_item} to item in slot 22 of current inventory of player
                if {_item} is any tool:
                    send "TOOL" to event-player
                if {_item} is any sword:
                    send "SWORD" to player

 

 

Jak się okazuję nagle usuwając item  i dodając wait 2 tick nagle działa, jeśli zostawi się 1 tick trzeba dwa razy włożyć zanim zaskoczy:

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:
                send "EventSlot" to player
                wait 2 tick
                set {_item} to slot 22 of current inventory of player
                if {_item} is any tool:
                    send "TOOL" to event-player
                if {_item} is any sword:
                    send "SWORD" to player

Skript_ench2.PNG

Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/#findComment-237066
Udostępnij na innych stronach

  • 0

Rozpracowałem to.
Razem z tym

set {_item} to slot 22 of current inventory of player

...można było {_item} porównywać i na nim operować.

Kompletny kod, z obsługą w razie gdyby gracz zamknął enchant bez ściągania przedmiotu:

Spoiler

 


on right click on enchantment table:
    cancel event
    set {customEnchant.%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 {customEnchant.%player%.bookshelves}
    send "Bookshelves: %{customEnchant.%player%.bookshelves}%" to player #DEBUG
    open virtual chest with 6 row named "&4&lEnchanting" to player
    set slot (13,21,23 and 32) 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:
                send "EventSlot" to player
                wait 2 tick
                set {_item} to slot 22 of current inventory of player
                if {_item} is any tool:
                    send "TOOL" to event-player
                else if {_item} is any sword:
                    send "SWORD" 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

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

Dziękuję, w razie problemów napiszę na nowo.

 

Do zamknięcia.

EDIT: Nie wiem czy teraz zaznaczyć swoją czy Marudy odpowiedź za najlepszą xd

Edytowane przez DaWiHsS
Najlesza odpowiedź, w wpisie
Odnośnik do komentarza
https://skript.pl/temat/37228-inventory-slot-item/#findComment-237067
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ę...