This is a script i made to get info about files that aren't being used.
Create a file on data/talkactions/scripts called getfiles.lua and paste:
Paste this on talkactions.xml:
And you'll see something like this on console/log-file:
Enjoy and post bugs, criticism and ideas here
- For now is working with normal script-folders (actions, talkactions, movements, creaturescripts, globalevents, spells, weapons).
- For now is working checking files in the scripts-folder (For now is not checking if scripts-folder contains more folders and check files inside that folder) so it will works with spells and weapons only if the scripts are not in folders.
- You need to install Lfs (LuaFileSystem) downloading it here:http://luaforge.net/frs/download.php/3933/luafilesystem-1.4.2-win32-lua51.zip and pasting it on your server folder (where the executable is)
Create a file on data/talkactions/scripts called getfiles.lua and paste:
Lua:
require "lfs"
local serverDir = "J:\\Users\\Eduardo\\Server\\"
local files =
{
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\talkactions\\scripts", xml = "data/talkactions/talkactions.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\creaturescripts\\scripts", xml = "data/creaturescripts/creaturescripts.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\spells\\scripts", xml = "data/spells/spells.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\weapons\\scripts", xml = "data/weapons/weapons.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\actions\\scripts", xml = "data/actions/actions.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\globalevents\\scripts", xml = "data/globalevents/globalevents.xml", ext = ".lua"},
{dir = serverDir .. "cryingdamson6pl1-gui\\data\\movements\\scripts", xml = "data/movements/movements.xml", ext = ".lua"}
}
local config =
{
printResults = true,
saveResults = false,
logFile = "not_in_use_files.txt"
}
function onSay(cid, words, param)
local _files, _dir = {}, {}
for i = 1, #files do
table.insert(_files, {})
table.insert(_dir, {})
end
local m_type, getType, getFile, m_file, m_ext
local lastAdded
for t_ = 1, #files do
local file = files[t_].xml
local openFile = io.open(file, "r")
local files, files_ = {}, {}
if openFile ~= nil then
for line in io.lines(file) do
if line:find('event=".*".*') and line:find('value=".*".*') then
getFile = string.match(line, 'value=".*".*')
getType = string.match(line, 'event=".*".*')
m_type = string.sub(getType, string.find(getType, '="') + 2, string.find(getType, '" ') - 1)
m_file = string.sub(getFile, string.find(getFile, '="') + 2, (string.find(getFile, '"/') or string.find(getFile, '">') or string.find(getFile, '" ')) - 1)
m_ext = string.sub(m_file, string.len(m_file) - 3, string.len(m_file))
m_file = string.sub(m_file, 0, string.len(m_file) - 4)
if m_ext == ".lua" and m_type == "script" and m_file:lower() ~= lastAdded then
table.insert(_files[t_], m_file)
lastAdded = m_file
end
end
end
openFile:close()
end
end
for t_ = 1, #files do
for file in lfs.dir(files[t_].dir) do
if lfs.attributes(file, "mode") == "directory" then
for l in lfs.dir(files[t_].dir .. file) do
local fil = string.sub(l, 0, string.len(l) -4)
local ext = string.sub(l, string.len(l) - 3, string.len(l))
if ext == ".lua" then
table.insert(_dir[t_], fil)
end
end
end
end
end
local t = {}
local txt = ""
for i = 1, #_files do
txt = txt .. "\n\n[!] --> Loading " .. files[i].dir
for s = 1, #_dir[i] do
if not isInArray(_files[i], _dir[i][s]) then
txt = txt .. "\n[!][!] --> File " .. _dir[i][s] .. ".lua is not in use."
t[i] = (t[i] or 0) + 1
end
end
txt = txt .. "\n[!] --> Total of " .. (t[i] or 0) .. " files are not in use."
end
if config.printResults then
print(txt)
end
if config.saveResults then
local f = io.open("data/logs/" .. config.logFile, "a+")
if f ~= nil then
f:write("[" .. os.date() .. "]\n" .. txt .. "\n\n")
f:close()
end
end
return true
end
Paste this on talkactions.xml:
XML:
<talkaction words="/getfiles" event="script" value="getfiles.lua"/>
And you'll see something like this on console/log-file:
Code:
[04/28/11 17:47:17]
[!] --> Loading data/talkactions/talkactions.xml
[!][!] --> File absorb.lua is not in use.
[!][!] --> File bless.lua is not in use.
[!][!] --> File createteleport.lua is not in use.
[!][!] --> File fly - copia.lua is not in use.
[!][!] --> File flydown.lua is not in use.
[!][!] --> File flyup.lua is not in use.
[!][!] --> File kill.lua is not in use.
[!][!] --> File kuchiyoseNoJutsu.lua is not in use.
[!][!] --> File map.lua is not in use.
[!][!] --> File messages.lua is not in use.
[!][!] --> File xmas.lua is not in use.
[!] --> Total of 11 files are not in use.
[!] --> Loading data/creaturescripts/creaturescripts.xml
[!][!] --> File achievements.lua is not in use.
[!][!] --> File conjure.lua is not in use.
[!][!] --> File death.lua is not in use.
[!][!] --> File debug.lua is not in use.
[!][!] --> File effect.lua is not in use.
[!][!] --> File gainexp.lua is not in use.
[!][!] --> File hotkey.lua is not in use.
[!][!] --> File killQuest.lua is not in use.
[!][!] --> File playerdeath.lua is not in use.
[!][!] --> File questNpc_creatureevent.lua is not in use.
[!][!] --> File reportbug.lua is not in use.
[!][!] --> File reset.lua is not in use.
[!][!] --> File st.lua is not in use.
[!][!] --> File svargrond.lua is not in use.
[!][!] --> File svargrond_think - copia.lua is not in use.
[!] --> Total of 15 files are not in use.
[!] --> Loading data/spells/spells.xml
[!] --> Total of 0 files are not in use.
[!] --> Loading data/weapons/weapons.xml
[!] --> Total of 0 files are not in use.
[!] --> Loading data/actions/actions.xml
[!][!] --> File annihilator.lua is not in use.
[!][!] --> File chazorai.lua is not in use.
[!] --> Total of 2 files are not in use.
[!] --> Loading data/globalevents/globalevents.xml
[!][!] --> File demonOak.lua is not in use.
[!] --> Total of 1 files are not in use.
[!] --> Loading data/movements/movements.xml
[!][!] --> File arena_reward.lua is not in use.
[!][!] --> File swimming.lua is not in use.
[!][!] --> File water.lua is not in use.
[!][!] --> File waterwalking.lua is not in use.
[!] --> Total of 4 files are not in use.
Enjoy and post bugs, criticism and ideas here
Last edited: