Aller au contenu
  • 0

Problème variable list contains


Question

Posté(e)

Bonjour, dans ma variable {mine::%player%::* il y a "A" et "B"

 

Le problème c'est que sa ne veut pas afficher ce que je veut

           if {mine::%player%::*} is "A":
               format slot 0 of player with stone named "&c&lA" with lore "&aGratuit" to run [execute player command "/mine a"]
           else:
               format slot 0 of player with wool:14 named "&c&lA" with lore "&aGratuit" to be unstealable
           if {mine::%player%::*} is "B":
               format slot 1 of player with stone named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to run [execute player command "/mine b"]
           else:
               format slot 1 of player with wool:14 named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to be unstealable

Ca affiche des laines rouge alors qu'il y a A et B dans la variable mais quand j'enleve B le 1er format slot marche et met de la stone

6 réponses à cette question

Messages recommandés

  • 0
Posté(e)

Il faut faire un loop pour regarder ce qu'il y a dans une liste de variables:

     loop {mine::%player%::*}: #On regarde tous les trucs qu'il y a dedans un par un
        if loop-value is "A": #si le morceau de {mine::%player%::*} qu'on analyse contient "A",
          format slot 0 of player with stone named "&c&lA" with lore "&aGratuit" to run [execute player command "/mine a"]
        else:
          format slot 0 of player with wool:14 named "&c&lA" with lore "&aGratuit" to be unstealable
        if loop-value is "B":
          format slot 1 of player with stone named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to run [execute player command "/mine b"]
        else:
          format slot 1 of player with wool:14 named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to be unstealable      

 

Si tu veux je peux t'expliquer un peut comment fonctionnent les variables de liste...

EDIT: je vais le faire maintenant:

 

Comment ranger des trucs dans une liste?

On peu ajouter n'importe quoi dedans:

- add "texte au hazard" to {liste::*}

- add {variable a la con} to {liste::*}

- add arg 1 to {liste::*}

 

Si on utilise "set" au lieu de "add" ca marche aussi, mais si on fait ca:

- set {liste::*} to "texte au hazard"

on n'aura qu'un truc dans la liste

Si on fait ca par contre:

- set {liste::*} to {deuxiemeliste::*} #idéal pour avoir une copie d'une liste, on peut la bidouiller sans endomager l'originale

 

- set {liste::fhrase1} to "je ne suis pas un héros"

oui, on peut donner un nom spécial à chaque index d'une liste. Par défaut, quand on fais:

- add "texte au hazard" to {liste::*}

par défaut, "texte au hazard" sera rangé dans {liste::1} si il y a rien dans la liste. Sinon ce sera {liste::2} ou {liste::3} etc... On peu utiliser des noms spéciaux pour pouvoir les réutiliser ailleurs:

- if {liste::fhrase1} is "je ne suis pas un héros":

- then set player's gamemode to creative

Regarder ce qu'il y a dans une liste:

- if {liste::lol} contains "hey"...

- if "%{liste::*}%" contains "hey" #Attention, mettre les guillemets! ca aura le même effet qu'un loop

Le reste plus tard

  • 0
Posté(e)

Merci pour ta réponse, ducoup j'a fait ce code là:

               if loop-value is "A":
                   format slot 0 of player with stone named "&c&lA" with lore "&aGratuit" to run [execute player command "/mine a"]
               else:
                   format slot 0 of player with wool:14 named "&c&lA" with lore "&aGratuit" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "B":
                   format slot 1 of player with stone named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to run [execute player command "/mine b"]
               else:
                   format slot 1 of player with wool:14 named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "C":
                   format slot 2 of player with stone named "&c&lC" with lore "&7Prix: &c{@MoneyMineC}" to run [execute player command "/mine c"]
               else:
                   format slot 2 of player with wool:14 named "&c&lC" with lore "&7Prix: &c{@MoneyMineC}" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "D":
                   format slot 3 of player with stone named "&c&lD" with lore "&7Prix: &c{@MoneyMineD}" to run [execute player command "/mine d"]
               else:
                   format slot 3 of player with wool:14 named "&c&lD" with lore "&7Prix: &c{@MoneyMineD}" to be unstealable

Mais sur ces 4 format slot ça ne met que l'avant dernier en stone alors que dans ma variable {mine::%player%::*} il y a A B et C donc sa ne prend que le dernier donc C. Mais je veut aussi que ça affiche pour le A et le B

  • 0
Posté(e)
function ListContain(list: texts, container: text) :: boolean:
   if {_list::*} does not contain {_container}:
       return false
   else:
       return true

if ListContain({mine::%player%::*}, "A") is true:
   # ...
if ListContain({mine::%player%::*}, "B") is true:
   # ...

  • 0
Posté(e)
Merci pour ta réponse, ducoup j'a fait ce code là:

               if loop-value is "A":
                   format slot 0 of player with stone named "&c&lA" with lore "&aGratuit" to run [execute player command "/mine a"]
               else:
                   format slot 0 of player with wool:14 named "&c&lA" with lore "&aGratuit" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "B":
                   format slot 1 of player with stone named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to run [execute player command "/mine b"]
               else:
                   format slot 1 of player with wool:14 named "&c&lB" with lore "&7Prix: &c{@MoneyMineB}" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "C":
                   format slot 2 of player with stone named "&c&lC" with lore "&7Prix: &c{@MoneyMineC}" to run [execute player command "/mine c"]
               else:
                   format slot 2 of player with wool:14 named "&c&lC" with lore "&7Prix: &c{@MoneyMineC}" to be unstealable

           loop {mine::%player%::*}:
               if loop-value is "D":
                   format slot 3 of player with stone named "&c&lD" with lore "&7Prix: &c{@MoneyMineD}" to run [execute player command "/mine d"]
               else:
                   format slot 3 of player with wool:14 named "&c&lD" with lore "&7Prix: &c{@MoneyMineD}" to be unstealable

Mais sur ces 4 format slot ça ne met que l'avant dernier en stone alors que dans ma variable {mine::%player%::*} il y a A B et C donc sa ne prend que le dernier donc C. Mais je veut aussi que ça affiche pour le A et le B

Comment A B et C sont mis dans ta liste? parce que je pense que c'est la facon dont tu les a mis dedans qui va pas, ton code est bon cette fois :/

  • 0
Posté(e)
Merci PsYZiiK ta solution fonctionne.

Et Black_Eyes dans ma variable c'est larqué comme ça : A, B, C and D

et je les add: add "A" to {mine::%player%::*}

Bah tant que sa solution marche :'D

×
×
  • 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.