Skocz do zawartości
  • 0

Paski w zmiennych


Zirrek

Pytanie

10 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Trzymaj :kappa:

on damage of entity:
	if health of victim > 10:
		set name of victim to "♥♥♥♥♥♥♥♥♥♥"
	if health of victim < 10:
		set name of victim to "♥♥♥♥♥♥♥♥♥"
	if health of victim < 9:
		set name of victim to "♥♥♥♥♥♥♥♥"
	if health of victim < 8:
		set name of victim to "♥♥♥♥♥♥♥"
	if health of victim < 7:
		set name of victim to "♥♥♥♥♥♥"
	if health of victim < 6:
		set name of victim to "♥♥♥♥♥"
	if health of victim < 5:
		set name of victim to "♥♥♥♥"
	if health of victim < 4:
		set name of victim to "♥♥♥"
	if health of victim < 3:
		set name of victim to "♥♥"
	if health of victim < 2:
		set name of victim to "♥"

 

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255593
Udostępnij na innych stronach

  • 0
8 godzin temu, Zirrek napisał:

Witam :P Przychodzę z następującym pytaniem:
Czy może ktoś podać mi skript który działał by na zasadzie 

Mob ma 10 hp
więc jego nazwa to ♥♥♥♥♥♥♥♥♥♥

Z góry dzięki ;>

 

function healthBar(health: number, maxHealth: integer) :: text:
	if {_health} is greater than 0:
		set {_bar} to "&c"
		loop {_maxHealth} times:
			set {_bar} to "%{_bar}%♥"
			if {_health} is loop-number:
				set {_bar} to "%{_bar}%&8"
		return "%{_bar}%"		
	else:			
		set {_bar} to "&7"
		loop {_maxHealth} times:
			set {_bar} to "%{_bar}%♥"
		return "%{_bar}%"
		
on damage:
	if victim is not player:
		set victim's name to "%healthBar(victim's health, victim's max health)%"

Proszę, powinno działać.

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255617
Udostępnij na innych stronach

  • 0

Wywala błąd:
"The 2nd argument given to the function 'healthBar' is not of the required type integer. Chect the correct order of the arguments and put lists into parenthleses if appropriate. "
Błąd dotyczy linijki z set victim's name

 

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255807
Udostępnij na innych stronach

  • 0
2 minuty temu, Zirrek napisał:

Wywala błąd:
"The 2nd argument given to the function 'healthBar' is not of the required type integer. Chect the correct order of the arguments and put lists into parenthleses if appropriate. "
Błąd dotyczy linijki z set victim's name

 

Zastąp 3 ostatnie linijki tym:

on damage:
	if victim is not player:
		set {_mh} to round(victim's max health)
		set victim's name to "%healthBar(victim's health, {_mh})%"

Sprawdź czy zadziała.

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255812
Udostępnij na innych stronach

  • 0
1 minutę temu, Zirrek napisał:

Działa fajnie tylko że jak hp zejdzie o 2 to potem co 2 atak nazwa resetuje się
i wygląda tak jakby miała full hp

 

Mógłbyś to jakoś pokazać?

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255815
Udostępnij na innych stronach

  • 0
19 minut temu, Zirrek napisał:

Link do zdjęcia
po lewej twój skrypt po prawej to ile faktycznie ma hp

https://drive.google.com/file/d/1OnDVFNxQCY3Ivuz0LkDE1PmawtcI5IF1/view?usp=sharing

on damage:
	if victim is not player:
		set {_h} to round(victim's health)
		set {_mh} to round(victim's max health)
		set victim's name to "%healthBar({_h}, {_mh})%"

Teraz powinno działać. Działo się tak, gdyż funkcja próbowała co drugi raz porównywać liczbę z przecinkiem do liczby całkowitej. Teraz powinno być okej.

Odnośnik do komentarza
https://skript.pl/temat/41004-paski-w-zmiennych/#findComment-255867
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ę...