Le "and" bit à bit n'existe pas ?

Parlez de tout ce qui est lié à Trackmania 2.

Moderator: French Moderator

Post Reply
User avatar
SurferIX
Posts: 79
Joined: 10 May 2011, 16:14
Contact:

Le "and" bit à bit n'existe pas ?

Post by SurferIX »

Bonjour,

J'avance petit à petit dans le ManiaScript mais là je vois que le "and" bit à bit n'existe pas ?
J'aimerais passer une variable qui a 4 bits ( = NESO) et si un est actif, alors poser un bloc en conséquence.
Du genre :

Code: Select all

if (Var && 1) {
  // Bit Nord actif => tracer nord
}

if (Var && 2) {
  // Bit Est actif => tracer est
}
if (Var && 4) {
  // Bit Sud actif => tracer sud
}
if (Var && 8) {
  // Bit West actif => tracer West
}
http://olivierpons.fr
Mon dernier framework hautes performances : http://www.papdevis.fr
User avatar
jonthekiller
Translator
Translator
Posts: 4629
Joined: 15 Jun 2010, 11:07
Location: In Maniaplanet Alpha
Contact:

Re: Le "and" bit à bit n'existe pas ?

Post by jonthekiller »

Dans la documentation en cours d'écriture il y a ceci pour les opérations booléennes.

Code: Select all

Var1 && (!Var2 || Var3)
Image
User avatar
SurferIX
Posts: 79
Joined: 10 May 2011, 16:14
Contact:

Re: Le "and" bit à bit n'existe pas ?

Post by SurferIX »

Bonjour,

Avec ton exemple, comment pourrais-je l'adapter au mien ? Et où, éventuellement, pourrais-je lire la documentation en cours d'élaboration ? As-tu un lien ? Merci !

Olivier
http://olivierpons.fr
Mon dernier framework hautes performances : http://www.papdevis.fr
User avatar
jonthekiller
Translator
Translator
Posts: 4629
Joined: 15 Jun 2010, 11:07
Location: In Maniaplanet Alpha
Contact:

Re: Le "and" bit à bit n'existe pas ?

Post by jonthekiller »

La documentation est dans la partie beta donc seulement les béta testeurs peuvent la voir pour le moment. Il me semble que m4rcel en a commencé une aussi et j'en ai trouvé une autre en anglais : http://forum.maniaplanet.com/viewtopic.php?f=279&t=4294
Image
titi59
Posts: 26
Joined: 15 Jun 2010, 11:07

Re: Le "and" bit à bit n'existe pas ?

Post by titi59 »

Je ne pense pas qu'elle fasse un jour son apparition nativement, étant donné que ce n'est pas une fonction "fondamentale" (face à la comparaison booléenne j'entends).
Après, ce n'est pas non plus une fonction très difficile à programmer ;) .
krial057
Posts: 57
Joined: 13 Nov 2010, 20:15

Re: Le "and" bit à bit n'existe pas ?

Post by krial057 »

Bonjour,
j'ai écrit quelques solutions dans le forum Anglais, si tu ne comprends pas trop bien l'Anglais, je peux te le traduire en francais ou allemand (ou Luxembourgeois xD ):
http://forum.maniaplanet.com/viewtopic. ... 689#p59014
User avatar
SurferIX
Posts: 79
Joined: 10 May 2011, 16:14
Contact:

Re: Le "and" bit à bit n'existe pas ?

Post by SurferIX »

Merci, et j'ai répondu sur le forum en Anglais, et je réponds ici en Français :

J'ai posé la question sur Stackoverflow, et la réponse a été donnée ici.

Voici ma fonction qui fonctionne :

Code: Select all

Void PlaceNESW(Integer X, Integer Y, Integer Z, Integer Val)
{
  PB("ArenaSimpleBase", X, Y, Z, ::CardinalDirections::North);
  declare Boolean ValBitN = ((Val / 1 ) % 2) > 0;
  declare Boolean ValBitE = ((Val / 2 ) % 2) > 0;
  declare Boolean ValBitS = ((Val / 4 ) % 2) > 0;
  declare Boolean ValBitW = ((Val / 8 ) % 2) > 0;
  if (ValBitN) {
    PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
  }
  if (ValBitE) {
    PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
  }
  if (ValBitS) {
    PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
  }
  if (ValBitW) {
    PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
  }
}
L'objectif est de poser un carré à un endroit, et s'il y a une ouverture vers le nord, poser un carre au nord, une à l'est, poser à l'est etc, mais il faut que la fonction soit ultra courte, et qu'il puisse y avoir plusieurs ouvertures. Donc rien de mieux que des bits.

J'appelle ma fonction ainsi :

Code: Select all

  PlaceNESW(25, CoordYBaseSol+2, 27, 15); // NESW
  PlaceNESW(25, CoordYBaseSol+2, 25, 1); // N
  PlaceNESW(25, CoordYBaseSol+2, 23, 10); // EW
http://olivierpons.fr
Mon dernier framework hautes performances : http://www.papdevis.fr
Post Reply

Return to “Trackmania 2”

Who is online

Users browsing this forum: No registered users and 1 guest