魔力宝贝

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

[GP] item_msg_Pretreatment.lua--道具msg预处理

[复制链接]
发表于 前天 03:27 | 显示全部楼层 |阅读模式
Global_Reg.RegInit("item_msg_pre_init");

function item_msg_pre_init()
        NL.RegMakeItemString(nil,"item_msg_pre")
        return 0;
end



function item_msg_pre(CharIndex, ItemPos, ItemIndex, ItemString)
        --print("\n"..ItemString)
        ItemString=ItemString_pre(CharIndex, ItemPos, ItemIndex, ItemString)
        local msg = Split(ItemString,"|")
       
        --print("\n"..msg[1])
        --msg[4] = string.gsub(msg[4],"\\S"," ")
        --msg[4] = string.gsub(msg[4],"\\\\","\\")
        local fixmsg = msg[4]
        local newmsg = ""
        local endmsg = ""
        if fixmsg then
                if string.find(fixmsg,"①") then
                        --print(fixmsg)
                        local b= string.find(fixmsg,"②")
                        if b then
                                local c=string.sub(fixmsg,1,b-1)
                                local d=string.sub(fixmsg,b-1,-1)
                                fixmsg=c.." "..d
                                --print(fixmsg)
                        end
                       
                        local b= string.find(fixmsg,"③")
                        if b then
                                local c=string.sub(fixmsg,1,b-1)
                                local d=string.sub(fixmsg,b-1,-1)
                                fixmsg=c.." "..d
                                --print(fixmsg)
                        end
                       
                        local b= string.find(fixmsg,"④")
                        if b then
                                local c=string.sub(fixmsg,1,b-1)
                                local d=string.sub(fixmsg,b-1,-1)
                                fixmsg=c.." "..d
                                --print(fixmsg)
                        end
                end
                newmsg = newmsg..fixmsg
        end
        if newmsg~="" then
               
                local long2 = tablength(msg)
               
                if long2>0 then
                        for i=1,long2 do
                                if i==4 then
                                        endmsg=endmsg..newmsg.."|"
                                elseif i~=long2 then
                                        endmsg=endmsg..msg[i].."|"
                                else
                                        endmsg=endmsg..msg[i]
                                end
                        end
                end
                --endmsg = string.gsub(endmsg,"\\c",",")
                --endmsg = string.gsub(endmsg,"\\n","\n")
                --print("\n"..endmsg)
                return endmsg
        end
       
    return nil
end

function paiban_item_msg(str,num)
        str = tostring(str)
        for i =string.len(str),num do
                str=str.." "
        end
        return str
end

回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-12 12:57 , Processed in 0.119540 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表