|
|
| Auteur | Message |
|---|
PhoenixD Utilisateur confirmé: Rang *

Inscrit le : 22 Aoû 2006 Messages : 283 Localisation : Bonne question! : ────────── : Projet Actuel : Kingdom Hearts :: Animaniac Avancement :
   (30/100)
| Sujet: Extraction d'un string Lun 31 Mar - 18:20 | |
| Bonjour à vous, Ex : votre string est de la forme : Yeah|Cool|Supeer|0.24654|3214 Une fois que vous l'aurez passer sous la machine ça vous donnera : chaine[0] : Yeah chaine[1] : Cool chaine[2] : Supeer chaine[3] : 0.24654 ....
Voici le script :
| Code: | // Argument0 : Texte // Argument1 : séparateur // Argument2 : Limite, 0 = aucune limite
limit = argument2; substr = argument1; str = argument0; nb = string_count(substr,str); if (limit == 0){ for (i = 0; i < nb; i+=1){
pos = string_pos(substr,str); chaine[i] = string_copy(str,1,pos-1); str = string_delete(str,1,pos); } }else{ if (nb >= limit){ for (i = 0; i < limit; i+=1){
pos = string_pos(substr,str); chaine[i] = string_copy(str,1,pos-1); str = string_delete(str,1,pos); } }else{ for (i = 0; i < nb; i+=1){
pos = string_pos(substr,str); chaine[i] = string_copy(str,1,pos-1); str = string_delete(str,1,pos); } } } chaine[i] = str; return i;
|
Nommez le scr_extraction_string;
Dans votre objet :
| Code: | scr_extraction_string(votre string,séparateur,votre limite); show_message(chaine[0]); show_message(chaine[1]); |
Remplacez "votre string" et "Séparateur", la limite est sois 0 pour aucune limite, ex : ma chaine est "Ma Super/Chaine de/La mort/qui tue", je met une limite de 2 ca va me retourné : Chaine[0] = "Ma Super"; Chaine[1] = "Chaine de"; Chaine[3] = "La mort/qui tue"; Le script retourne la taille du tableau.
Voilà, l'utilité de ce script réside surtout dans son utilisation en ligne, oui quand on veut faire passer plusieurs informations dans un message.
Dernière édition par PhoenixD le Ven 16 Mai - 22:32, édité 2 fois |
|
 | |
LorisDAMPERE Utilisateur confirmé: Rang ****

Age : 13 Inscrit le : 28 Jan 2007 Messages : 1202 Localisation : avec du citron svp : ────────── : Projet Actuel : apprendre a faire un jeu avec le redsheep Avancement :
   (80/100)
| Sujet: Re: Extraction d'un string Lun 31 Mar - 19:24 | |
| le titre m'a fait peur  je suis deja dehors  _________________
 [/intelligence] |
|
 | |
shm31 *Excellent utilisateur*

Age : 16 Inscrit le : 16 Jan 2006 Messages : 8410 Localisation : 2 bad for u m8 : ────────── : Projet Actuel : warhammer Avancement :
   (14/100)
| Sujet: Re: Extraction d'un string Lun 31 Mar - 22:31 | |
| débile. sinon bah bien joué PhoenixD _________________ Rambotioner : Night of the living abla : DONE I am an in the GM Quiz! |
|
 | |
PhoenixD Utilisateur confirmé: Rang *

Inscrit le : 22 Aoû 2006 Messages : 283 Localisation : Bonne question! : ────────── : Projet Actuel : Kingdom Hearts :: Animaniac Avancement :
   (30/100)
| Sujet: Re: Extraction d'un string Lun 31 Mar - 23:39 | |
| merci  |
|
 | |
master47 Utilisateur confirmé: Rang *****

Age : 16 Inscrit le : 16 Nov 2006 Messages : 1577 Localisation : Bruxelles, Belgique @ Louise Gallery : ────────── : Projet Actuel : PacWars Avancement :
   (35/100)
| Sujet: Re: Extraction d'un string Mar 1 Avr - 0:27 | |
| j'utilise deja ton script 
Je devais le faire moi-même, tu m'épargne l'écriture  _________________
| Spoiler: | | | Hahaha tu pensais que ça allait être interessant ?? bah nan t'as perdu ton temps pour rien |
 |
|
 | |
master47 Utilisateur confirmé: Rang *****

Age : 16 Inscrit le : 16 Nov 2006 Messages : 1577 Localisation : Bruxelles, Belgique @ Louise Gallery : ────────── : Projet Actuel : PacWars Avancement :
   (35/100)
| Sujet: Re: Extraction d'un string Mar 1 Avr - 14:02 | |
| Pfff ! ca fait deux heures que je me casse la tête pour savoir ce qui bug dans mon jeu mais en fait c juste que ton script est foireux quand on a que deux éléments
heureusement que gmlscripts est la pour rattrapper le coup lol 
| Citation: | /* ** Usage: ** size = explode_string(array,sep,data); ** ** Arguments: ** array name of a local array, string ** sep seperator character, string ** data array data, string ** ** Returns: ** size size of the array of data ** ** Notes: ** Converts a string of data with elements seperated ** by a delimiter into an array of strings. ** ** GMLscripts.com */ { var arr,sep,dat,len,ind,pos; arr = "chaine"; sep = "|"; dat = argument0 + sep; len = string_length(sep); ind = 0; repeat (string_count(sep,dat)) { pos = string_pos(sep,dat)-1; variable_local_array_set(arr,ind,string_copy(dat,1,pos)); dat = string_delete(dat,1,pos+len); ind += 1; } return ind; }
|
_________________
| Spoiler: | | | Hahaha tu pensais que ça allait être interessant ?? bah nan t'as perdu ton temps pour rien |
 |
|
 | |
robotic76 Utilisateur confirmé: Rang *****

Age : 15 Inscrit le : 20 Mai 2006 Messages : 2898 Localisation : Le Havre, Normandie : ────────── : Projet Actuel : Destroy to survive Avancement :
   (40/100)
| Sujet: Re: Extraction d'un string Mar 1 Avr - 14:04 | |
| bah ça arrive de se tromper  |
|
 | |
PhoenixD Utilisateur confirmé: Rang *

Inscrit le : 22 Aoû 2006 Messages : 283 Localisation : Bonne question! : ────────── : Projet Actuel : Kingdom Hearts :: Animaniac Avancement :
   (30/100)
| Sujet: Re: Extraction d'un string Mar 1 Avr - 15:17 | |
| Tin je me disais bien que j'avais oublié un truc xD Enfaite j'ai corrigé le script car oui quand tu as que deux ou qu'un seul élément ça bug. J'édite, il y'a juste un +1 a enlevé. |
|
 | |
master47 Utilisateur confirmé: Rang *****

Age : 16 Inscrit le : 16 Nov 2006 Messages : 1577 Localisation : Bruxelles, Belgique @ Louise Gallery : ────────── : Projet Actuel : PacWars Avancement :
   (35/100)
| Sujet: Re: Extraction d'un string Mar 1 Avr - 16:58 | |
| Thx  _________________
| Spoiler: | | | Hahaha tu pensais que ça allait être interessant ?? bah nan t'as perdu ton temps pour rien |
 |
|
 | |
PhoenixD Utilisateur confirmé: Rang *

Inscrit le : 22 Aoû 2006 Messages : 283 Localisation : Bonne question! : ────────── : Projet Actuel : Kingdom Hearts :: Animaniac Avancement :
   (30/100)
| Sujet: Re: Extraction d'un string Ven 16 Mai - 22:32 | |
| | Mise a jour du script. |
|
 | |
|