|
无聊中,看见之前有一些陆续零散的文章,自己研究一下。见下文:
例如#var aa "s|nu|sd|kill bing|su|e"
#var bb "kill bing"
#var cc 5
1,numitems
#fu numitems {%numwords(%1,"|")}
用法:@numitems(@aa)
注:无。。。太简单了
2,ismember
#fu ismember {%eval(%ismember(%1,%2)*(%numwords(%word(%concat("|")%replace(%2,"|","||")%concat("|"),1,%concat("|")%1%concat("|")),"||")+1))}
用法:@ismember(@bb,@aa)
注:会返回元素位置
优点适用替换"|"为"||",然后计算|@bb|的位置,防止e,eu之类的相近元素干扰计数
3,item
#fu item {%if(%2<1,"",%word(%1,%2,"|"))}
用法:@item(@aa,@cc)
注:无。。。太简单了,模仿zmud721中,负数和0均是显示空的
4,delnitem
#fu delnitem {%exec(fuction_delnitem=%1;fuction_delnitem_before="";#loop %eval(%2-1) {fuction_delnitem_before=@fuction_delnitem_before|%word(@fuction_delnitem,1,"|");fuction_delnitem=%delitem(%word(@fuction_delnitem,1,"|"),@fuction_delnitem)};fuction_delnitem=%delitem(%word(@fuction_delnitem,1,"|"),@fuction_delnitem);fuction_delnitem=||@fuction_delnitem_before|@fuction_delnitem||;fuction_delnitem=%replace(%replace(@fuction_delnitem,"|||","||"),"||","|");fuction_delnitem_before=%eval(%len(@fuction_delnitem)-2);fuction_delnitem=%copy(@fuction_delnitem,2,@fuction_delnitem_before))%if((%2<1 or %2>%numwords(%1,"|")),%1,%if(%2=1,%delitem(%word(%1,1,"|"),%1),@fuction_delnitem))}
%if((%2<1 or %2>%numwords(%1,"|")),%1,%if(%2=1,%delitem(%word(%1,1,"|")),@fuction_delnitem))
用法:@delnitem(@aa,@cc)
注:这个比较麻烦,主要是比如你e在一个list中可能有多个e,你要找到你要的位置有点繁琐。
这个我用@aa 50个元素,#loop 50 {#echo @delnitem(@aa,%random(1,50))}
实验过效果还可以
方法就是根据@cc的数目循环@cc次数,前面有一个list,后面剩一个list相加
其他函数暂时没有想到。
顺便推销一下的中文数值转换阿拉伯数字函数:
5,trans
#fu trans {%eval(%replace(%replace(%concat("(0+"%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%1,"零","*0+"),"十","*10+"),"百","*100+"),"千","*1000+"),"万","+0)*10000+(0+"),"亿","+0)*100000000+(0+"),"六","6"),"一","1"),"二","2"),"三","3"),"四","4"),"五","5"),"七","7"),"八","8"),"九","9")"+0)"),"++","+"),"+*","+"))}
用法:@trans(十一亿三千零六万零七百零二)
1130060702
注:可以上亿哦
另外cmud zmud462通用,我调整好了语法
北大侠客行MUD,中国最好的MUD |
|