Re: [闲聊] tmi-2 efun 与 simul_efun 简单说明

楼主: typers (Typer)   2014-07-08 17:23:17
: int strlen sizeof(string);
:
: 从上面可以发现 string 就跟“阵列”的概念是类似的,也就是
: 说如果一 string = "abcde", 它就类似({"a","b","c","d",e"})
: 这样的阵列排在一起的结果。
:
: strlen 就是计算字串的长度。strwidth 也相当于 strlen 只是
: 一般都用 strlen。
在启用 fluffos 的 USE_ICONV 选项后, strwidth 的行为将会与 strlen 不同
strlen("中文字") = 9 (UTF-8 的一个中文字占 3 个 byte, 故长度为 9)
strwidth("中文字") = 3
USE_ICONV 选项开启后, 所有 lib 的文件都必须以 UTF-8 作为文字编码格式
既然是要弄新的 lib, 小弟建议开启 USE_ICONV
: string *explode(string, string);
这个 efun 会因为 fluffos 的编译选项, 而有不同的行为
请问 L 大是以 /adm/etc/options.h.example 来编译 fluffos 吗?
: void move_object(object | string);
把 this_object() 移动到所给的参数里面
如 user 在 room 之间移动 或 物品在容器之间移动, 最终都是透过这个 efun
不过通常都不会直接使用 move_object()
而是会另外再包一层, 处理重量...之类的东西
: mixed *commands();
回传 this_object() 透过 add_action() 取得的指令资讯列表
可供 user 查询目前可使用那些特殊指令 (如某 room 或 item 才有的特殊指令)
: void set_living_name(string);
在小猫, npc 通常不使用此 efun
因为当名称一样时, find_living() 只找的到最后一个呼叫此 efun 的物件
除非特例, 不然不建议大量使用这个 efun
: livings 传回的就是所有被 set_living_name 且被加载的生物
livings() 应该是回传曾经呼叫过 enable_commands() 的物件
: int inherits(string, object default: F__THIS_OBJECT);
inherits(ROOM, this_object())
判断 this_object() 是否有继承 ROOM
: void replace_program(string);
以参数的程式区块取代 this_object() 的程式区块
可提高效能与节省内存, 但限制很多
以目前的环境来说, 应该不太需要使用这个 efun 了
: int set_encoding(string);
: string to_utf8(string, string);
: string utf8_to(string, string);
: int *str_to_arr(string);
: string arr_to_str(int *);
这几个 efun 是需要开启 USE_ICONV 选项之后才会有的
用途是处理文字编码格式
例如
utf8_to("中文", "Big-5") 可以将文字从 UTF-8 转换为 Big5
str_to_arr("中文") 会回传 ({ 20013, 25991, 0 }), 可用来判断是否为中文字
UTF-8 的中文范围为 0x4E00 ~ 0x9FA5

Links booklink

Contact Us: admin [ a t ] ucptt.com