Advertisement
constantin-net

prompt hystory

Aug 5th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local function history_check_load(id, max)
  2.     if id and id ~= ""
  3.         and not data.history[id] then
  4.     data.history[id] = { max = 50, table = {} }
  5.  
  6.     if max then
  7.             data.history[id].max = max
  8.     end
  9.  
  10.     local f = io.open(id, "r")
  11.  
  12.     -- Read history file
  13.     if f then
  14.             for line in f:lines() do
  15.                 if util.table.hasitem(data.history[id].table, line) == nil then
  16.                         table.insert(data.history[id].table, line)
  17.                         if #data.history[id].table >= data.history[id].max then
  18.                            break
  19.                         end
  20.                 end
  21.             end
  22.             f:close()
  23.     end
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement