2012-08-10 00:54:03 +02:00
|
|
|
filename = 'Tibia'
|
2012-08-15 01:58:25 +02:00
|
|
|
loaded = false
|
2012-08-10 00:54:03 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2012-12-28 12:05:45 +01:00
|
|
|
connect(g_game, { onProtocolVersionChange = load })
|
2012-07-31 06:09:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function terminate()
|
2012-12-28 12:05:45 +01:00
|
|
|
disconnect(g_game, { onProtocolVersionChange = load })
|
2012-07-18 09:49:44 +02:00
|
|
|
end
|
|
|
|
|
2012-08-10 00:54:03 +02:00
|
|
|
function setFileName(name)
|
|
|
|
filename = name
|
|
|
|
end
|
|
|
|
|
2012-08-15 01:58:25 +02:00
|
|
|
function isLoaded()
|
|
|
|
return loaded
|
|
|
|
end
|
|
|
|
|
2012-07-26 08:10:28 +02:00
|
|
|
function load()
|
2012-12-28 12:05:45 +01:00
|
|
|
local version = g_game.getProtocolVersion()
|
2012-08-10 00:54:03 +02:00
|
|
|
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
|
2012-08-10 00:54:03 +02:00
|
|
|
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
|
2012-08-15 01:58:25 +02:00
|
|
|
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
|
2012-08-10 00:54:03 +02:00
|
|
|
end
|
|
|
|
|
2012-08-15 01:58:25 +02:00
|
|
|
loaded = (errorMessage:len() == 0)
|
|
|
|
|
2012-08-10 00:54:03 +02:00
|
|
|
if errorMessage:len() > 0 then
|
2012-08-15 01:58:25 +02:00
|
|
|
local messageBox = displayErrorBox(tr('Error'), errorMessage)
|
|
|
|
addEvent(function() messageBox:raise() messageBox:focus() end)
|
|
|
|
|
2012-12-28 12:05:45 +01:00
|
|
|
disconnect(g_game, { onProtocolVersionChange = load })
|
|
|
|
g_game.setprotocolVersion(0)
|
|
|
|
connect(g_game, { onProtocolVersionChange = load })
|
2012-07-26 08:10:28 +02:00
|
|
|
end
|
2012-07-18 10:34:17 +02:00
|
|
|
end
|