mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
Many changes
* IMPORTANT: dat/spr should now be placed in /data/things/ * Rename game_tibiafiles to game_things * Make battle list algorithm much faster * Split UITabBar into UITabBar and UIMoveableTabBar * Fix other minor issues
This commit is contained in:
1
modules/game_things/.gitignore
vendored
Normal file
1
modules/game_things/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
50
modules/game_things/things.lua
Normal file
50
modules/game_things/things.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
filename = nil
|
||||
loaded = false
|
||||
|
||||
function init()
|
||||
connect(g_game, { onProtocolVersionChange = load })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onProtocolVersionChange = load })
|
||||
end
|
||||
|
||||
function setFileName(name)
|
||||
filename = name
|
||||
end
|
||||
|
||||
function isLoaded()
|
||||
return loaded
|
||||
end
|
||||
|
||||
function load()
|
||||
local version = g_game.getProtocolVersion()
|
||||
|
||||
local datPath, sprPath
|
||||
if filename then
|
||||
datPath = resolvepath('/things/' .. filename)
|
||||
sprPath = resolvepath('/things/' .. filename)
|
||||
else
|
||||
datPath = resolvepath('/things/' .. version .. '/Tibia')
|
||||
sprPath = resolvepath('/things/' .. version .. '/Tibia')
|
||||
end
|
||||
|
||||
local errorMessage = ''
|
||||
if not g_things.loadDat(datPath) then
|
||||
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
|
||||
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 })
|
||||
end
|
||||
end
|
8
modules/game_things/things.otmod
Normal file
8
modules/game_things/things.otmod
Normal file
@@ -0,0 +1,8 @@
|
||||
Module
|
||||
name: game_things
|
||||
description: Contains things spr and dat
|
||||
reloadable: false
|
||||
sandboxed: true
|
||||
scripts: [things]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
Reference in New Issue
Block a user