tibia-client/modules/game_tibiafiles/tibiafiles.lua

44 lines
1.2 KiB
Lua
Raw Normal View History

filename = 'Tibia'
loaded = false
function init()
connect(g_game, { onProtocolVersionChange = load })
2012-07-31 06:09:55 +02:00
end
function terminate()
disconnect(g_game, { onProtocolVersionChange = load })
2012-07-18 09:49:44 +02:00
end
function setFileName(name)
filename = name
end
function isLoaded()
return loaded
end
2012-07-26 08:10:28 +02:00
function load()
local version = g_game.getProtocolVersion()
local datPath = resolvepath(version .. '/' .. filename .. '.dat')
local sprPath = resolvepath(version .. '/' .. filename .. '.spr')
local errorMessage = ''
2012-07-26 08:10:28 +02:00
if not g_things.loadDat(datPath) then
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
2012-07-26 08:10:28 +02:00
end
if not g_sprites.loadSpr(sprPath) then
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
end
loaded = (errorMessage:len() == 0)
if errorMessage:len() > 0 then
local messageBox = displayErrorBox(tr('Error'), errorMessage)
addEvent(function() messageBox:raise() messageBox:focus() end)
disconnect(g_game, { onProtocolVersionChange = load })
g_game.setprotocolVersion(0)
connect(g_game, { onProtocolVersionChange = load })
2012-07-26 08:10:28 +02:00
end
end