Francky Habercom |
Voir le profil public |
Trouver plus de messages par Francky Habercom |
Aller à la page... |
Notecard "SETTING"
Suivre Répondre |
|
Partager | Rechercher |
|
lancelot a fait un ptit truc sur son blog
![]() |
![]() |
|
Francky Habercom |
Voir le profil public |
Trouver plus de messages par Francky Habercom |
|
en fait elle ne contient que du string
Quand tu récupères les données il ne faut pas oublié de les transformer |
![]() |
|
|
Voilà le script que j'utilise :
Code:
string notecard_name = "configuration"; // name of notecard goes here // internals integer DEBUG = FALSE; integer line; key queryhandle; // to separate Dataserver requests key notecarduuid; init() { queryhandle = llGetNotecardLine(notecard_name, line = 0);// request line notecarduuid = llGetInventoryKey(notecard_name); } // Config data loaded from notecard, with some sane defaults integer channel = 1000; string email_address = "revolution.perenti@skidzpartz.com"; default { changed(integer change) { // We want to reload channel notecard if it changed if (change & CHANGED_INVENTORY) if(notecarduuid != llGetInventoryKey(notecard_name)) init(); } state_entry() { init(); } dataserver(key query_id, string data) { if (query_id == queryhandle) { if (data != EOF) { // not at the end of the notecard // yay! Parsing time // pesky whitespace data = llStringTrim(data, STRING_TRIM_HEAD); // is it a comment? if (llGetSubString (data, 0, 0) != "#") { integer s = llSubStringIndex(data, "="); if(~s)//does it have an "=" in it? { string token = llToLower(llStringTrim(llDeleteSubString(data, s, -1), STRING_TRIM)); data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM); //Insert your token parsers here. if (token == "email_address") email_address = data; else if (token == "channel") channel = (integer)data; } } queryhandle = llGetNotecardLine(notecard_name, ++line); if(DEBUG) llOwnerSay("Notecard Data: " + data); } else { if(DEBUG) llOwnerSay("Done Reading Notecard"); state configuration ; } } } } state configuration { state_entry() { llListen(channel, "", "", ""); llShout(0, "Channel set to " + (string)channel); llShout(0, "Email set to " + (string)email_address); } } la notecard doit être de la forme : nom_de_la donnée = donnée les données peuvent être dans n'importe quel ordre, incompléte ou surnuméraires; il peut y avoir des commentaires (sur des lignes séparées commençant par #). les nom_de_la_donnée doivent bien sur correpondre aux tokens programmés (en minuscules uniquement) dans les if et en tête du script dans les défault. Comme la souligner Lancelot, ne pas oublier de convertir le type suivant les besoins. je le trouve assez complet, pratique et léger. |
![]() |
|
Elenia Boucher |
Voir le profil public |
Trouver plus de messages par Elenia Boucher |
|
L'un des 2 wikis SL contient un exemple complet pour presque chaque fonction, parfois ça évite de chercher pendant 2 heures. ^^
|
![]() |
|
|
Pour convertir un string en integer utilise cette syntaxe :
ma_variable = (integer)ma_variable; |
![]() |
|
Sandrine repine |
Voir le profil public |
Trouver plus de messages par Sandrine repine |
Empereur / Impératrice
|
Cool, ca marche !!!
Il me manquait ca : integer montantVente = (integer)message; Merci Redpurple ![]() |
![]() |
|
Suivre Répondre |
Fil d'ariane
Connectés sur ce fil1 connecté (0 membre et 1 invité)
Afficher la liste détaillée des connectés
|