Advertisement
fatboychummy

modu-Notes

Nov 4th, 2018
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. --[[
  2. {"notes","note"}
  3. ]]
  4.  
  5. return function (input,_,_,tell,dynaStore)
  6.   if input[2] == "read" then
  7.     tell("Current notes:")
  8.     if #dynaStore == 0 then
  9.       tell("None")
  10.     end
  11.     for i = 1,#dynaStore do
  12.       tell(tostring(i)..": "..dynaStore[i])
  13.     end
  14.   elseif input[2] == "write" then
  15.     local str = ""
  16.     for i = 3,#input do
  17.       str = str..input[i].. " "
  18.     end
  19.     str = str:sub(1,str:len()-1)
  20.     tell("saving '"..str.."'")
  21.     dynaStore[#dynaStore+1] = str
  22.   elseif input[2] == "remove" then
  23.     input[3] = tonumber(input[3])
  24.     if type(input[3]) ~= "number" then
  25.       tell("Expected index as third argument.")
  26.       return
  27.     end
  28.     table.remove(dynaStore,input[3])
  29.     tell("Removed note "..tostring(input[3]))
  30.   else
  31.     tell( "Unexpected command: "..tostring( input[ 2 ] ) )
  32.   end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement