iArcadia Débutant
Messages : 24 Localisation : Charente-Maritime (17)
| Sujet: [Résolu][8.1] Var qui ne prend pas la valeur d'un string_delete Mar 14 Jan 2014 - 19:23 | |
| Bonsoir les CBNAniens. Je voudrais faire un script qui récupère des info provenant d'un fichier exterieur. J'ai un objet "obj_test" : - Code:
-
str = get_player_information(); global.playerName = ' ' - Code:
-
draw_text(100,100,'str : ' + string(str)); draw_text(100,140,'var : ' + global.playerName); Un script "get_player_information" - Code:
-
/* * script : get_player_information() */
var fileadr, file, temp_all, temp_copy, temp_delete,index; fileadr = get_open_filename("Fichier d'informations (*.info)|*.info","*.info");
if (fileadr != '') { file = file_text_open_read(fileadr); file_text_readln(file); temp_all = file_text_read_string(file); temp_all = string_delete(temp_all,1,1); // Delete the '.' character. index = string_pos('=',temp_all); // Get the '=' separator character between the field name and its value. temp_copy = string_copy(temp_all,1,index-1); // Get the field name. switch (temp_copy) { case 'name': global.playerName = string_delete(temp_all,1,index); show_message('switch: ok'); // si message s'affiche, le switch est bon. } return string_delete(temp_all,1,index); } Un fichier exterieur "file.info" : - Code:
-
[Global Information] .name=test Le script me retourne bien ce que je veux, mais un peu plus haut, que je fais le "global.playerName = string_delete(temp_all,1,index);", global.playerName est toujours égal à ' '. Des suggestions ? Et merci d'avance. EDIT :Bon bah là ça craint carrément, j'ai corrigé mon problème moi-même... Je cherchais des trucs trop compliqués depuis presque 2 heures, alors quand échangeant les lignes dans le create de mon objet, ça marche. Sur ce, problème résolu. |
|