Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to use alternatives in match tables? [Intermediate knowledge]

Asked by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

I’m not sure if I correctly worded the question above, please let me know if so, but I’m trying to make a admin for my Chat, and I came across an issue, it’s even weirder to explain but I did write and example of where I’m getting at. The formation of the string mud looks like so ;Print:Console(Hi), ; is the Prefix, :Console Is the extension type; Usually each command would have different uses, they would be defined on :. The () are a classic parameter setup, just for fun I guess;) I’m not one to jump to conclusions but I believe in order to properly grasp this example below, you may need decent knowledge in Lua, or math.

local m = ";Print:Console(Hi)"
local p = [[;]]
local c = {
   "Print";
}; 
local cb = {
   ["Print"] = ":Console" or ":Hello()" --// my question, restricts to ":Console" only, better way to do this?
}; 
if (m:sub(1,1) == p) then
   if (m:sub(#p,#c[1]+1) == p..c[1]) then
      if (m:sub(#c[1]+2,#m-4) == cb[c[1]]) then pC = true
         if (pC) then
            mp = m:sub((#p+#c[1]+#cb[c[1]]+2), #m-1)
            print(mp)
         end
      elseif (m:sub(#c[1]+2,#m) == cb[c[1]]) then
         print("Hello World!")
      end
   end
end

Please help me out! it may be hard to understand all together so feel free to ask any questions at all!

I’m not sure about the formatting if able, so I presumed or

Answer this question