Advertisement
Derek1017

Test

Jul 19th, 2015
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. local parameters = { ["you "] = { ["please "] = { ["listen"] = {}, ["look "] = { ["up"] = {}, ["down"] = {} },
  2.     ["eat"] = {} }, ["give "] = { ["up"] = {}, ["blood"] = {}, }, ["kindly"] = {} } }
  3.  
  4. local function tabCompletionFunction(shell, parNumber, curText, lastText)
  5.     -- Check that the parameters entered so far are valid:
  6.     local curParam = parameters
  7.     for i = 2, #lastText do
  8.         if curParam[lastText[i] .. " "] then
  9.             curParam = curParam[lastText[i] .. " "]
  10.         else
  11.             return {}
  12.         end
  13.     end
  14.  
  15.     -- Check for suitable words for the current parameter:
  16.     local results = {}
  17.     for word, _ in pairs(curParam) do
  18.         if word:sub(1, #curText) == curText then
  19.             results[#results + 1] = word:sub(#curText + 1)
  20.         end
  21.     end
  22.     return results
  23. end
  24.  
  25. shell.setCompletionFunction("would", tabCompletionFunction)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement