Aller au contenu

Vérifier si le joueur a besoin de manger ou non


Messages recommandés

Posté(e)

Hello, j'aimerais savoir quel est le code pour verifier si le joueur est full dans sa "hunger"

Exemple:

on right click holding a bread:
# Verifier si le joueur a besoin de manger ou non
   apply saturation 1 to player for 1 seconds
   remove 1 of tool from tool
   play raw sound "random.eat" at player with pitch 1 volume 1

 

Je pense que c'est une ligne du genre..

if player's health is not equal to player's max health:

Posté(e)

J'ai trouvé ceci, mais c'est trop long :/

on right click holding a bread:
   if player's hunger = 0:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 0.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 1:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 1.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 2:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 2.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 3:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 3.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 4:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 4.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 5.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 6:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 6.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 7:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 7.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 8:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 8.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 9:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player
on right click holding a bread:
   if player's hunger = 9.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player

Posté(e)

Sinon beaucoup plus simple ;) :

on right click holding a bread:
   if player's hunger <= 9.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player

 

Cette alternative résume tout ce que tu as noté avant :)

  • J'aime 2
Posté(e)
Sinon beaucoup plus simple ;) :

on right click holding a bread:
   if player's hunger <= 9.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 1 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 1 tick
       remove saturation from player

 

Cette alternative résume tout ce que tu as noté avant :)

Merci à toi, mais j'ai mis dans un seul monde sauf que je peut le faire dans n'importe quel monde :/

on right click holding a bread:
   if player is in "island-0":
   if player's hunger <= 9.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 4 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 2 tick
       remove saturation from player

Posté(e)
Merci à toi, mais j'ai mis dans un seul monde sauf que je peut le faire dans n'importe quel monde :/

on right click holding a bread:
   if player is in "island-0":
   if player's hunger <= 9.5:
       cancel event
       remove 1 of tool from tool
       apply saturation 4 to player for 0.5 seconds
       play raw sound "random.eat" at player with pitch 1 volume 1
       wait 2 tick
       remove saturation from player

Tu dois mettre une tabulation après la ligne de ta condition de verification du monde ^^.

  • J'aime 1
Posté(e)

Comme l'a dit kumakuma215 tu dois mettre des tabulations après une condition ce qui donnerait ceci :

on right click holding a bread:
   if player is in "island-0":
       if player's hunger <= 9.5:
           cancel event
           remove 1 of tool from tool
           apply saturation 4 to player for 0.5 seconds
           play raw sound "random.eat" at player with pitch 1 volume 1
           wait 2 tick
           remove saturation from player

Et si la ligne ' if player is in "island-0": ' ne marche toujours pas mais cela m'étonnerait, remplace la par ' if player's world is "island-o": ' ;)

Posté(e)
Comme l'a dit kumakuma215 tu dois mettre des tabulations après une condition ce qui donnerait ceci :

on right click holding a bread:
   if player is in "island-0":
       if player's hunger <= 9.5:
           cancel event
           remove 1 of tool from tool
           apply saturation 4 to player for 0.5 seconds
           play raw sound "random.eat" at player with pitch 1 volume 1
           wait 2 tick
           remove saturation from player

Et si la ligne ' if player is in "island-0": ' ne marche toujours pas mais cela m'étonnerait, remplace la par ' if player's world is "island-o": ' ;)

Effectivement, j'avais oublié un tab ><

Merci.

×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.