Skocz do zawartości
  • 0

event-slot's name


the_kakus

Pytanie

siema, potrzebuje czegos aby wykrywalo czy klikniety w gui item ma w koncówce słowo "block" i zeby je usunelo i ustawilo nazwe itemu bez "block" do zmiennej
np. jezeli klikam w cobblestone to zmienna sie normalnie ustawia na cobblestone block, a ja chcialbym zeby skrypt wykryl ze ten item ma w nazwie "block" i zeby go usunelo

Odnośnik do komentarza
Udostępnij na innych stronach

Rekomendowane odpowiedzi

  • 0
1 minutę temu, the_kakus napisał:

siema, potrzebuje czegos aby wykrywalo czy klikniety w gui item ma w koncówce słowo "block" i zeby je usunelo i ustawilo nazwe itemu bez "block" do zmiennej
np. jezeli klikam w cobblestone to zmienna sie normalnie ustawia na cobblestone block, a ja chcialbym zeby skrypt wykryl ze ten item ma w nazwie "block" i zeby go usunelo

Użyj 'ends with'.

"%event-slot%" ends with "block"
# Dalszy kod

 

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
13 minut temu, the_kakus napisał:

zrobilem cos takiego (te sendy to na test są tylko) i dalej nie dziala

To nie zadziała, gdyż próbujesz ze zmiennej odejmować tekst, która ma zapisany ten slot.

Zresztą, w Skript'cie nie ma czegoś takiego jak odejmowanie tekstu.

Możesz to zrobić albo splitem jakimś, albo substringiem.

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0

moj kod to ogolnie kod na sklep tylko ze przez ten caly "block" ten sklep mi sie troche buguje
potrzebuje jedynie ogarnac zeby samo usuwało słowo block jezeli takowy item posiada to słowo
 

on inventory click:
	name of player's current inventory = "&8» &7&lSKLEP - BLOKI ¹" or "&8» &7&lSKLEP - BLOKI ²" or "&8» &7&lSKLEP - FARMA, JEDZENIE ¹" or "&8» &7&lSKLEP - FARMA, JEDZENIE ²" or "&8» &7&lSKLEP - LOOT Z MOBÓW" or "&8» &7&lSKLEP - SUROWCE" or "&8» &7&lSKLEP - ENCZANTY" or "&8» &7&lSKLEP - EFEKTY" or "&8» &7&lSKLEP - RÓŻNE"
	clicked inventory is not player's inventory
	cancel event
	if clicked slot is 45 or 53:
		execute player command "/sklep"
	if clicked slot is not 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 17 or 18 or 26 or 27 or 35 or 36 or 37 or 38 or 39 or 40 or 41 or 42 or 43 or 44 or 46 or 48 or 49 or 50 or 52:
		clear {_item} and {_buy1} and {_buy64} and {_sell1} and {_sell64}
		set {_item} to event-slot
		set {_buy1} to (substring of (line 2 of event-slot's lore) from characters 18 to (length of (line 2 of event-slot's lore) - 5)) parsed as integer
		set {_buy64} to (substring of (line 3 of event-slot's lore) from characters 19 to (length of (line 3 of event-slot's lore) - 5)) parsed as integer
		set {_sell1} to (substring of (line 4 of event-slot's lore) from characters 23 to (length of (line 4 of event-slot's lore) - 5)) parsed as integer
		set {_sell64} to (substring of (line 5 of event-slot's lore) from characters 24 to (length of (line 5 of event-slot's lore) - 5)) parsed as integer
		if (line 2 of event-slot's lore) is "":
			clear {_buy1}
		if (line 3 of event-slot's lore) is "":
			clear {_buy64}
		if (line 4 of event-slot's lore) is "":
			clear {_sell1}
		if (line 5 of event-slot's lore) is "":
			clear {_sell64}
		wait 2 ticks
		set {_xd} to event-slot
		send "1 %{_xd}%"
		if "%{_xd}%" ends with "block":
			set {_xd} to event-slot
		send "2 %{_xd}%"
		if clicked type is left mouse button:
			if {_buy1} is not set:
				stop
			else:
				if ({_buy1}) = {money.%player%}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					remove ({_buy1}) from {money.%player%}
					give 1 of {_item} to player
					send "&8» &aKupiłeś &b&o1 &r&b%{_item}%&a! &8&o[&2&o-%{_buy1}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop	
				if ({_buy1}) < {money.%player%}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					remove ({_buy1}) from {money.%player%}
					give 1 of {_item} to player
					send "&8» &aKupiłeś &b&o1 &r&b%{_item}%&a! &8&o[&2&o-%{_buy1}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop
				if ({_buy1}) > {money.%player%}:
					play sound "minecraft:entity.blaze.hurt" to player
					send "&8» &cNie stać cię na ten zakup!"
					stop
		if clicked type is left mouse button with shift:
			if {_buy64} is not set:
				stop
			else:
				if ({_buy64}) = {money.%player%}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					remove ({_buy64}) from {money.%player%}
					give 64 of {_item} to player
					send "&8» &aKupiłeś &b&o64 &r&b%{_item}%&a! &8&o[&2&o-%{_buy64}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop	
				if ({_buy64}) < {money.%player%}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					remove ({_buy64}) from {money.%player%}
					give 64 of {_item} to player
					send "&8» &aKupiłeś &b&o64 &r&b%{_item}%&a! &8&o[&2&o-%{_buy64}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop
				if ({_buy64}) > {money.%player%}:
					play sound "minecraft:entity.blaze.hurt" to player
					send "&8» &cNie stać cię na ten zakup!"
					stop
		if clicked type is right mouse button:
			if {_sell1} is not set:
				stop
			else:
				if player has 1 of {_item}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					add ({_sell1}) to {money.%player%}
					remove 1 of {_item} from player
					send "&8» &aSprzedałeś &b&o1 &r&b%{_item}%&a! &8&o[&2&o+%{_sell1}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop
				else:
					play sound "minecraft:entity.blaze.hurt" to player
					send "&8» &cNie masz tylu przedmiotów!"
					stop
		if clicked type is right mouse button with shift:
			if {_sell64} is not set:
				stop
			else:
				if player has 64 of {_item}:
					play sound "minecraft:entity.experience_orb.pickup" to player
					add ({_sell64}) to {money.%player%}
					remove 64 of {_item} from player
					send "&8» &aSprzedałeś &b&o64 &r&b%{_item}%&a! &8&o[&2&o+%{_sell64}%&7&oPLN&8&o]"
					set slot 49 of player's current inventory to paper of infinity named " &8»  &6STAN KONTA &8• &2%{money.%player%}%&7PLN  &8« " with lore "", "&aKup &21x &r&8• &7&oLPM", "&aKup &264x &r&8• &7&oLPM + Shift", "&cSprzedaj &41x &r&8• &7&oPPM", "&cSprzedaj &464x &r&8• &7&oPPM + Shift", ""
					stop
				else:
					play sound "minecraft:entity.blaze.hurt" to player
					send "&8» &cNie masz tylu przedmiotów!"
					stop

 

Edytowane przez the_kakus
Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
5 minut temu, the_kakus napisał:

moj kod to ogolnie kod na sklep tylko ze przez ten caly "block" ten sklep mi sie troche buguje
potrzebuje jedynie ogarnac zeby samo usuwało słowo block jezeli takowy item posiada to słowo

Najprościej będzie chyba splitować nazwę bloku na "block".

set {_b::*} to ("%type of event-slot%") split at "block"
set {_i} to "%{_b::*}%" parsed as item

 

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
5 minut temu, Kormic napisał:

Najprościej będzie chyba splitować nazwę bloku na "block".



set {_b::*} to ("%type of event-slot%") split at "block"
set {_i} to "%{_b::*}%" parsed as item

 

powiem ci, ze zrobilem tak jak napisales i dalej bez zmian
 

# wcześniejszy kod
send "1 %{_item}%"
set {_b::*} to ("%type of event-slot%") split at "block"
set {_item} to "%{_b::*}%" parsed as item
send "2 %{_item}%"
# dalszy kod

https://imgur.com/a/lRfj7Oc

Edytowane przez the_kakus
Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
3 minuty temu, the_kakus napisał:

powiem ci, ze zrobilem tak jak napisales i dalej bez zmian
 



# wcześniejszy kod
send "1 %{_item}%"
set {_b::*} to ("%type of event-slot%") split at "block"
set {_item} to "%{_b::*}%" parsed as item
send "2 %{_item}%"
# dalszy kod

https://imgur.com/a/lRfj7Oc

Czekaj, czekaj. Przecież zapomniałem o 'replace all'. :facepalm:

set {_t} to "%type of event-block%"
replace all "block" with "" in {_t}

 

Edytowane przez Kormic
Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Nieaktywny
Odpowiedz na pytanie...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

  • Ostatnio przeglądający   0 użytkowników

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