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.

things.lua 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. filename = nil
  2. loaded = false
  3. function init()
  4. connect(g_game, { onClientVersionChange = load })
  5. end
  6. function terminate()
  7. disconnect(g_game, { onClientVersionChange = 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.getClientVersion()
  17. local datPath, sprPath
  18. if filename then
  19. datPath = resolvepath('/things/' .. filename)
  20. sprPath = resolvepath('/things/' .. filename)
  21. else
  22. datPath = resolvepath('/things/' .. version .. '/Tibia')
  23. sprPath = resolvepath('/things/' .. version .. '/Tibia')
  24. end
  25. local errorMessage = ''
  26. if not g_things.loadDat(datPath) then
  27. errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
  28. end
  29. if not g_sprites.loadSpr(sprPath) then
  30. errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
  31. end
  32. loaded = (errorMessage:len() == 0)
  33. if errorMessage:len() > 0 then
  34. local messageBox = displayErrorBox(tr('Error'), errorMessage)
  35. addEvent(function() messageBox:raise() messageBox:focus() end)
  36. disconnect(g_game, { onClientVersionChange = load })
  37. g_game.setClientVersion(0)
  38. g_game.setProtocolVersion(0)
  39. connect(g_game, { onClientVersionChange = load })
  40. end
  41. end