Skocz do zawartości
  • 0

Czytanie wartości z yml


uiuin17
 Udostępnij

Pytanie

on load:
	if folder "plugins/MyFood/config" doesn't exists:
		create folder "plugins/MyFood/config"
		if file "plugins/MyFood/config/message.yml" doesn't exists:
			create file "plugins/MyFood/config/message.yml"
		if file "plugins/MyFood/config/options.yml" doesn't exists:
			create file "plugins/MyFood/config/options.yml"
	set {full.health.message} to value "message.food.full" get of "plugins/MyFood/config/message.yml" 		
	set {food.apple.heal} to value "options.food.apple.heal" get of "plugins/MyFood/config/options.yml" 
on consume:
	if health of player is 10:
		cancel event
		send "&c%{full.health.message}%"
	item is apple:
		set {food.apple.heal} to value "options.food.apple.heal" get of "plugins/MyFood/config/options.yml" 
		loop 2 times:
			heal player by {food.apple.heal}
			wait 1 seconds

Witam mam problem bo gdy zjem jabłko to nie leczy mnie o wartość zapisaną w pliku YML

Sprawdzałem za pomocą komendy czy ta wartość jest dobra i jak zmieniłem ją na 1 to wysyłało mi wiadomość że jest to 1 jak na 3 to 3 itd.

Jednak nie ma żadnych błędów w tym skript a i tak mnie nie leczy gdy zjem jabłko

Odnośnik do komentarza
Udostępnij na innych stronach

Rekomendowane odpowiedzi

  • 0
options:
	config: plugins/MyFood/config/options.yml
	message: plugins/MyFood/config/message.yml
on load:
	if folder "plugins/MyFood/config" doesn't exists:
		create folder "plugins/MyFood/config"
		if file "plugins/MyFood/config/message.yml" doesn't exists:
			create file "plugins/MyFood/config/message.yml"
		if file "plugins/MyFood/config/options.yml" doesn't exists:
			create file "plugins/MyFood/config/options.yml"
on consume:
	if health of player is 10:
		set {_message.full.health} to coloured single value "message.full.health" get of "{@message}"
		cancel event
		send "%{_message.full.health}%"
on eat a apple:
	set {_options.health} to single value "options.health" get of "{@config}"
	heal player by {_options.health}
			

Config i message.yml:

Spoiler

Config wygląda tak:

options:
  health: 3

A message wygląda tak:

message:
  full.health: 'Twoje hp jest pelne'

Zarejestruj się lub zaloguj, aby zobaczyć ukrytą treść!

Zarejestruj się lub zaloguj, aby zobaczyć ukrytą treść!

 

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
3 godziny temu, Switsherker napisał:
options:
	config: plugins/MyFood/config/options.yml
	message: plugins/MyFood/config/message.yml
on load:
	if folder "plugins/MyFood/config" doesn't exists:
		create folder "plugins/MyFood/config"
		if file "plugins/MyFood/config/message.yml" doesn't exists:
			create file "plugins/MyFood/config/message.yml"
		if file "plugins/MyFood/config/options.yml" doesn't exists:
			create file "plugins/MyFood/config/options.yml"
on consume:
	if health of player is 10:
		set {_message.full.health} to coloured single value "message.full.health" get of "{@message}"
		cancel event
		send "%{_message.full.health}%"
on eat a apple:
	set {_options.health} to single value "options.health" get of "{@config}"
	heal player by {_options.health}
			

Config i message.yml:

Zarejestruj się lub zaloguj, aby zobaczyć ukrytą treść! Ukryj zawartość

Config wygląda tak:



options:
  health: 3

A message wygląda tak:


message:
  full.health: 'Twoje hp jest pelne'

Zarejestruj się lub zaloguj, aby zobaczyć ukrytą treść!

Zarejestruj się lub zaloguj, aby zobaczyć ukrytą treść!

 

Witam ale

options:

 i tu musi być apple bo nie mam tylko takiego efektu z jedzenia jabłek

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
10 godzin temu, TheDircikPL napisał:

@uiuin17
Code coś nie dodało bo dałem :D

on eat a apple:
	if {apple.type} is "true":
		loop 2 times:
			wait 1 seconds
			set {_apple.heal} to value "opcje.apple.ogolne.leczenie" get of "plugins/MyFood/config/opcje.yml"
			set player's health to player's health + {_apple.heal}

Coś nie działa 0 błędów

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
8 godzin temu, TheDircikPL napisał:

zamiast set {_apple.heal} to value daj set {_apple.heal} to single value

on load:
	if folder "plugins/MyFood/config" doesn't exists:
		create folder "plugins/MyFood/config"
		if file "plugins/MyFood/config/opcje.yml" doesn't exists:
			create file "plugins/MyFood/config/opcje.yml"
	if folder "plugins/MyFood/gracze" doesn't exists:
		create folder "plugins/MyFood/gracze"
	set {apple.chance.zatrucie} to single value "opcje.apple.negatywne.zatrucie" get of "plugins/MyFood/config/opcje.yml"
	set {apple.chance.tasiemiec} to single value "opcje.apple.negatywne.tasiemiec" get of "plugins/MyFood/config/opcje.yml"
	set {apple.chance.glizda} to single value "opcje.apple.negatywne.glizda" get of "plugins/MyFood/config/opcje.yml"
	set {apple.type} to single value "opcje.apple.ogolne.online" get of "plugins/MyFood/config/opcje.yml"
	set {apple.heal} to single value "opcje.apple.ogolne.leczenie" get of "plugins/MyFood/config/opcje.yml"

on eat a apple:
	if {apple.type} is "true":
		chance of {apple.chance.zatrucie}%:
			add 1 to {zatrucie.%player%}
			set "statystyki.%player%.zatrucie" to "%{zatrucie.%player%}%" in yaml file "plugins/MyFood/gracze/%player%.yml"
			loop 2 times:
				wait 1 seconds
				set {_apple.heal} to single value "opcje.apple.ogolne.leczenie" get of "plugins/MyFood/config/opcje.yml"
				heal player by {_apple.heal}

opcje:
  apple:
    ogolne:
      leczenie: '0.5'
      online: 'true'
    negatywne:
      zatrucie: '1'
      tasiemiec: '3'
      glizda: '5'

Dalej nie działa

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0

@uiuin17
Chyba już wiem
zamiast
leczenie: '0.5'

daj

leczenie: 0.5
 

Tak samo z online, itp. ' ' jest używane do tekstu np.
test: 'testuje'

a np. w booleanach (test: false), albo tasiemiec: '3' jest zwykły integer(number), więc nie trzeba.

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

  • 0
15 godzin temu, TheDircikPL napisał:

@uiuin17
Chyba już wiem
zamiast
leczenie: '0.5'

daj

leczenie: 0.5
 

Tak samo z online, itp. ' ' jest używane do tekstu np.
test: 'testuje'

a np. w booleanach (test: false), albo tasiemiec: '3' jest zwykły integer(number), więc nie trzeba.

Bardzo dziękuje :D

PS: Obyś nie miał tasiemca jak zjesz jabłuszko ::D

Odnośnik do komentarza
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

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

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