Aller au contenu
  • 0

Loop blocks avec {_direction}


Question

Posté(e)

Bonjour avez-vous une méthode pour faire en sorte qu'on puisse mettre une variable de type direction dans un "loop blocks", car :

loop blocks between the block at the player and the block 2 north the player marche très bien

MAIS

loop blocks between the block at the player and the block 2 {_direction} the player ne marche pas

 

exemple :

command /aa:
   trigger:
       set {_direction} to a random element out of "up" and "down" and "north" and "south" and "east" and "west"
       loop blocks between the block at the player and the block 2 {_direction} the player:
           broadcast "%loop-block%"

 

SPOIL ALERTE : Le problème semble plus compliqué qu'il parait l'être :confused:.

 

Je cherche à réduire la taille de mon code pour qu'il ne prenne que quelques lignes (je l'ai déjà écris mais il est trop imposant) et si une solution est trouvé cela me permettra de passer de +50 lignes à 10 lignes.

Skript version : Skript 2.2-fixes-V9b (=v1.5)

 

merci

8 réponses à cette question

Messages recommandés

  • 0
Posté(e)

Essaye-ça :

 

evaluate "loop blocks between the block at the player and the block 2 {_direction} the player:"

  • 0
Posté(e)

J'ai dis que le problème n'était pas aussi simple que ça :p J'ai déjà essayé le evaluate et ça ne marche évidement pas.

test et tu verra une erreur indentation error ou there's no loop that mathes 'loop-block'

  • 0
Posté(e)

déjà essayé, ne marche pas.

Si seulement

loop blocks between the block at the player and the block 2 {_direction} the player:

ne donnait pas d'erreur ce serait tellement plus simple :'(

  • 0
Posté(e)

Ah bah rt x)

 

Avec "block at the player" tu veux loop quel bloc ?

  • 0
Posté(e)

Marche parfaitement (désolé ça fait longtemps que j'ai pas fait de Skript) :

 

function getBlocks(p: player, rayon: number=2) :: items:
   set {_dir} to a random element out of "up", "down", "north", "east", "south" and "west"
   {_dir} is "up":
       loop blocks within (location of block at {_p}) to (position x-pos of {_p}, (y-pos of {_p} + {_rayon}), z-pos of {_p} of the world of {_p}):
           add location of loop-block to {_results::*}
   {_dir} is "down":
       loop blocks within (location of block at {_p}) to (position x-pos of {_p}, (y-pos of {_p} - {_rayon}), z-pos of {_p} of the world of {_p}):
           add location of loop-block to {_results::*}
   {_dir} is "north":
       loop blocks within (location of block at {_p}) to (location of block {_rayon} north of {_p}):
           add location of loop-block to {_results::*}
   {_dir} is "east":
       loop blocks within (location of block at {_p}) to (location of block {_rayon} north of {_p}):
           add location of loop-block to {_results::*}
   {_dir} is "south":
       loop blocks within (location of block at {_p}) to (location of block {_rayon} north of {_p}):
           add location of loop-block to {_results::*}
   {_dir} is "west":
       loop blocks within (location of block at {_p}) to (location of block {_rayon} north of {_p}):
           add location of loop-block to {_results::*}
   loop {_results::*}:
       set {_return::%loop-index%} to block at loop-value
   return {_return::*}

command /aa:
   trigger:
       send "%getBlocks(player)%"

  • 0
Posté(e)

Merci de ta grosse proposition PsYZiik mais c'est justement "le contraire" de ton skript que je cherche à faire, tu as développé le code alors que je cherche à le factoriser pour réduire sa taille.

En faite ce que tu as codé c'est ce que j'ai déjà mais le code est trop long. J'ai trouvé une solution (qui n'est peut être pas le meilleur) à l'aide d'une Entité.

 

        set {_direction} to a random element out of "up" and "south" and "north" and "west" and "east" and "down"
       if "%{_direction}%" is "up":
           set {_loc} to location of block {@distance} meters up the loop-entity
       if "%{_direction}%" is "down":
           set {_loc} to location of block {@distance} meters down the loop-entity
       if "%{_direction}%" is "east":
           set {_loc} to location of block {@distance} meters east the loop-entity
       if "%{_direction}%" is "west":
           set {_loc} to location of block {@distance} meters west the loop-entity
       if "%{_direction}%" is "north":
           set {_loc} to location of block {@distance} meters north the loop-entity
       if "%{_direction}%" is "south":
           set {_loc} to location of block {@distance} meters south the loop-entity
       loop all Armor stands in radius 1 around the block at {_loc}:
           broadcast "%loop-block%"

 

 

Si vous avez des propositions encore plus courte et tout aussi fonctionnel je prend toujours :)

  • 0
Posté(e)
Bonjour avez-vous une méthode pour faire en sorte qu'on puisse mettre une variable de type direction dans un "loop blocks", car :

loop blocks between the block at the player and the block 2 north the player marche très bien

MAIS

loop blocks between the block at the player and the block 2 {_direction} the player ne marche pas

 

exemple :

command /aa:
   trigger:
       set {_direction} to a random element out of "up" and "down" and "north" and "south" and "east" and "west"
       loop blocks between the block at the player and the block 2 {_direction} the player:
           broadcast "%loop-block%"

 

SPOIL ALERTE : Le problème semble plus compliqué qu'il parait l'être :confused:.

 

Skript version : Skript 2.2-fixes-V9b (=v1.5)

 

merci

Désolé mais tu ne l'as pas précisé dans ta demande. Je ne fais ce que tu demandes c'est tout. Pense à préciser la prochaine fois.

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