KaduRo Posted January 14, 2015 Share Posted January 14, 2015 السلام عليكم شباب محتاج مساعدة في كود بحث , مثلآ سكربت لأسامي الاسلحة , وكتبت اول حرف من السلاح , يطلع لي اسم السلاح كامل وهذا كود بسيط ومومضبوط بس لتوضيح الطلب table1 = { "Good" , "Bad " , "No" , "Yes" } function Name (v) v = tostring(v) n = string.match(table.concat(table1) , v) return v end outputChatBox(Name("G")) عند كتابة حرف G ابيه يظهر لي كلمة Good في الشات Link to comment
TAPL Posted January 14, 2015 Share Posted January 14, 2015 table1 = { "Good" , "Bad " , "No" , "Yes" } function Name (v) local v = tostring(v) if v then for _, word in ipairs(table1) do if word:lower():find(v:lower()) then return word end end end end outputChatBox(Name("G")) Link to comment
KaduRo Posted January 14, 2015 Author Share Posted January 14, 2015 طيب إذا ماعليك امر , حاب اطلع اسمين او اكثر مشتركين بحرف مثلآ ممكن الطريقة ؟ Link to comment
TAPL Posted January 14, 2015 Share Posted January 14, 2015 table1 = { "Good" , "Bad " , "No" , "Yes" } function Name (v) local v = tostring(v) if v then local string = "" for _, word in ipairs(table1) do if word:lower():find(v:lower()) then string = #string > 0 and string.." "..word or word end end return string end end outputChatBox(Name("o")) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now