Quantcast
Channel: marchのBLOG
Viewing all articles
Browse latest Browse all 20

ソース(1):【日本語対応メッセージボード v05】

$
0
0
>【日本語対応メッセージボード Japanese-MessageBoard v05】 のソースです。 このオブジェクトは1つの親と複数の子の2種類から構成されています。 親プリムでユーザとのやりとりを行い、 子プリムで文字を表示しています。 仕様メモ: ・チャンネルは、いくつかの中から選択する。  たまたま重なったら移動する。という程度の自由度。 ・メニューの説明文字列は日本語のみ、ボタンは英語のみ。 ・タッチしてリッスンチャンネルを開けた後に、チャンネル番号を変えた場合は、  もう一度タッチしてリッスンチャンネルを開けなければメッセージを変更できない。これは仕様。 ・グループモードの場合、オーナーであっても別グループがActiveの場合は、  タッチ等ができない。これは仕様。 【工夫】 ・書き換え中は透明にして、書き換えを見せない(デバッグ中以外は) ・リセット時のデフォルト文字列は、途中に空白に見えるひらがな・カタカナを入れて  ロード時間をかせぐ  「-・-・-・-・-・-・-・-・-・-・」  -・- - - - - - - - - 」  U+002D 「-」  U+30FB (UTF-8:E3 83 BB) 「・」本当の中点 (ひらがな・カタカナ)  U+FF00 (UTF-8:EF BC 80) マッピング無し (全角英数字・半角カタカナ)  U+25AA (UTF-8:E2 96 AA) 「BLACK SMALL SQUARE」 ◆記号や●記号  U+26BF (UTF-8:E2 9A BF) マッピング無し ★記号や♪記号 urlEscapedString2List 関数は、 listenで受け取った文字列を、1文字ずつのリストにします。 RFC 2279 (3629 ではなく)を見ながら勉強がてら書いたものですが、 他のスクリプトにも転用できるんじゃないかと思います。 一部のデバッグ用スクリプトも残してありますので、参考までに。 以下は親プリムのスクリプトです。 ライセンスは Creative Commons Attribution-Share Alike 3.0 Unported License http://creativecommons.org/licenses/by/3.0/ です。 //v4: add dialog. //v5:change dialog. //initial message. //"irasshaimase." string INITIAL_MESSAGE = "-%E3%83%BB-%E3%83%BB-%E3%83%BB-%E3%83%BB-%EF%BC%80-%E3%83%BB-%E2%96%AA-%E3%83%BB-%E3%83%BB-%E2%9A%BF"; // integer channelGather = 7; integer CHANNEL_DIALOG = 42521; // dialog channel integer LHandleGather; integer LHandleDialog; float LISTEN_GATHER_TIMEOUT = 90.0; //gather channel timeout(sec.) //for dialog string B_PRINT_MODE = "USER"; string B_CHANGE_MODE_ALL = "ALL"; string B_CHANGE_MODE_GROUP = "GROUP"; string B_CHANGE_MODE_OWNER = "OWNER"; // //string B_CHANGE_CHANNEL = "CHANGE_CHANNNE"; string B_MODIFY_MESSAGE = "MESSAGE"; // string B_PRINT_COLOR = "COLOR"; string B_CHANGE_COLOR_RED = "RED"; string B_CHANGE_COLOR_GREEN = "GREEN"; string B_CHANGE_COLOR_BLUE = "BLUE"; string B_CHANGE_COLOR_YELLOW = "YELLOW"; //kiiro string B_CHANGE_COLOR_MAGENTA = "MAGENTA"; //murasaki string B_CHANGE_COLOR_CYAN = "CYAN"; //mizuiro string B_CHANGE_COLOR_WHITE = "WHITE"; string B_CHANGE_COLOR_BLACK = "BLACK"; // string B_PRINT_CHANNEL = "CHANNEL"; string B_CHANGE_CHANNEL_7 = "7"; string B_CHANGE_CHANNEL_10 = "10"; string B_CHANGE_CHANNEL_17 = "17"; // string B_HELP = "HELP"; string B_RESET = "RESET"; string B_DEBUG_INFO = "DEBUG_INFO"; string B_CLOSE = "CLOSE"; //string B_PRINT_NOTIFY_WRITE = "NOTIFY_WRITE"; //string B_CHANGE_NOTIFY_WRITE_TRUE = "NOTIFY_WRITE_TRUE"; //string B_CHANGE_NOTIFY_WRITE_FALSE = "NOTIFY_WRITE_FALSE"; // integer MODE_ALL = 1; integer MODE_GROUP = 2; integer MODE_OWNER = 3; integer isPublicMode = TRUE; integer modifyMode = MODE_ALL; //integer isNotifyWrite = FALSE; //for DEBUG integer startTime; integer isDebugMode = FALSE; // //misc functions. // //-------- //see http : // wiki.secondlife.com/wiki/XTEA_Strong_Encryption_Implementation //-------- //Function: ord //Returns the index of an ASCII character integer ord(string chr) { string ASCII = " !\"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; if(llStringLength(chr) != 1) return -1; if(chr == " ") return 32; return llSubStringIndex(ASCII, chr); } integer atoi(string str) { integer i; string chr; integer num = 0; //Define character string [0-F] for use in building the num. string characters = "0123456789ABCDEF"; str = llToUpper(str); //not care overflow! for(i = 0; i < llStringLength(str); i++) { chr = llGetSubString(str, i, i); num = num * 16 + llSubStringIndex(characters, chr); } //llOwnerSay("atoi(" + str + ")=" + (string)num); return num; } // //unicode process functions. // list urlEscapedString2List(string escapedStr) { integer i; string chr; list resultList = []; integer len; integer num1; integer num2; integer num3; integer num4; len = llStringLength(escapedStr); i = 0; while( i < len) { chr = llGetSubString(escapedStr, i, i); if(chr != "%") { resultList = resultList + ord(chr); // not atoi i = i + 1; //process 1 charactor. } else { // get first escaped num. num1 = atoi(llGetSubString(escapedStr, i+1, i+1)) * 16 + atoi(llGetSubString(escapedStr, i+2, i+2)); i = i + 3; //process 3 charactor. // get octet type. if((num1 & 0x80) == 0) //0xxxxxxx -> 1 octet.(ex. %20, etc..) { //0000 0000 to 0000 007F(U+0000 to U+007F) resultList = resultList + num1; } else if((num1 & 0x20) == 0) //110xxxxx 10xxxxxx -> 2 octet. { //00000080 to 000007FF num2 = atoi(llGetSubString(escapedStr, i+1, i+1)) * 16 + atoi(llGetSubString(escapedStr, i+2, i+2)); i = i + 3; //process 3 charactor. resultList = resultList + (integer)(((num1 & 0x1F)

Viewing all articles
Browse latest Browse all 20

Trending Articles