No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tibiafiles.lua 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. filename = 'Tibia'
  2. loaded = false
  3. function init()
  4. connect(g_game, { onProtocolVersionChange = load })
  5. end
  6. function terminate()
  7. disconnect(g_game, { onProtocolVersionChange = load })
  8. end
  9. function setFileName(name)
  10. filename = name
  11. end
  12. function isLoaded()
  13. return loaded
  14. end
  15. function load()
  16. local version = g_game.getProtocolVersion()
  17. local datPath = resolvepath(version .. '/' .. filename .. '.dat')
  18. local sprPath = resolvepath(version .. '/' .. filename .. '.spr')
  19. local errorMessage = ''
  20. if not g_things.loadDat(datPath) then
  21. errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
  22. end
  23. if not g_sprites.loadSpr(sprPath) then
  24. errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
  25. end
  26. loaded = (errorMessage:len() == 0)
  27. if errorMessage:len() > 0 then
  28. local messageBox = displayErrorBox(tr('Error'), errorMessage)
  29. addEvent(function() messageBox:raise() messageBox:focus() end)
  30. disconnect(g_game, { onProtocolVersionChange = load })
  31. g_game.setProtocolVersion(0)
  32. connect(g_game, { onProtocolVersionChange = load })
  33. end
  34. end