Lua可以将字符串与图像名称匹配吗?

问题描述 投票:0回答:1

我拿到了这个脚本

door = script.Parent
function onChatted(msg, recipient, speaker) 
source = string.lower(speaker.Name) 
msg = string.lower(msg) 
-- thecharacter = script.Parent.TheCharacter
if (msg == string.match(File.name)) then 
door.CanCollide = false 
door.Transparency = 0.7 
wait(4) 
door.CanCollide = true 
door.Transparency = 0 
end 
end 
game.Players.ChildAdded:connect(function(plr)
plr.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, plr) end) 
end)

是否可以将用户消息与图像名称而不是字符进行匹配?

我是lua新手,似乎找不到任何关于此的信息。

image lua
1个回答
0
投票

如果在

msg
中您有文件名,并且在
File.name
中有文件的全名并且您想要缩短它,请尝试像这样提取名称:

string.match(File.name,"([^/]*)$")

它匹配:一个字符串,从末尾开始,然后捕获任何不是

/
的字符。

© www.soinside.com 2019 - 2024. All rights reserved.