Quando tu troca a linguagem do cliente ele faz um reload nos modulos, o reload é basicamente executar a função terminate e depois a init.
Há erros nessas funções, mas sem postar os modulos é impossivel que alguem lhe ajude.
Quando tu troca a linguagem do cliente ele faz um reload nos modulos, o reload é basicamente executar a função terminate e depois a init.
Há erros nessas funções, mas sem postar os modulos é impossivel que alguem lhe ajude.
info
Grupo: Conde
Registrado: 12/04/15
Posts: 655
Reputação: +65
Gênero: Masculino
Char no Tibia: Developer Berg

Quando tu troca a linguagem do cliente ele faz um reload nos modulos, o reload é basicamente executar a função terminate e depois a init.
Há erros nessas funções, mas sem postar os modulos é impossivel que alguem lhe ajude.
Malz rs, eu esqueci de postar, olha ai
SOUNDS_CONFIG = {
soundChannel = SoundChannels.Music,
checkInterval = 500,
folder = 'music/',
noSound = 'No sound file for this area.',
}
SOUNDS = {
-- PVP
{fromPos = {x=933, y=1025, z=13}, toPos = {x=952, y=1043, z=13}, priority = 1, sound="Balada.ogg"},
{fromPos = {x=1014, y=996, z=13}, toPos = {x=1030, y=1011, z=13}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=953, y=1016, z=13}, toPos = {x=990, y=1047, z=13}, priority = 1, sound="Pvp.ogg"},
{fromPos = {x=945, y=990, z=13}, toPos = {x=996, y=1015, z=13}, priority = 1, sound="Batalha.ogg"},
{fromPos = {x=989, y=1174, z=13}, toPos = {x=999, y=1182, z=13}, priority = 2, sound="Batalha.ogg"},
{fromPos = {x=958, y=1116, z=13}, toPos = {x=1020, y=1178, z=13}, priority = 1, sound="Batalha.ogg"},
{fromPos = {x=1018, y=1037, z=13}, toPos = {x=1044, y=1058, z=13}, priority = 1, sound="Batalha.ogg"},
{fromPos = {x=1054, y=1039, z=13}, toPos = {x=1071, y=1059, z=13}, priority = 1, sound="Pvp.ogg"},
{fromPos = {x=1089, y=821, z=13}, toPos = {x=1131, y=907, z=13}, priority = 1, sound="Batalha.ogg"},
{fromPos = {x=991, y=1023, z=13}, toPos = {x=1008, y=1043, z=13}, priority = 1, sound="CP.ogg"},
-- CITYS
-- Saffron City
{fromPos = {x=1087, y=1010, z=0}, toPos = {x=1111, y=1052, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1057, y=1016, z=0}, toPos = {x=1100, y=1058, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1034, y=1024, z=0}, toPos = {x=1090, y=1068, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1006, y=1036, z=0}, toPos = {x=1080, y=1080, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1043, y=1024, z=0}, toPos = {x=1076, y=1109, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1010, y=1030, z=0}, toPos = {x=1076, y=1087, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1068, y=1010, z=0}, toPos = {x=1073, y=1110, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1057, y=1015, z=0}, toPos = {x=1062, y=1115, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1009, y=1034, z=0}, toPos = {x=1118, y=1039, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=995, y=1058, z=0}, toPos = {x=1080, y=1074, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1030, y=1029, z=0}, toPos = {x=1042, y=1099, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1022, y=1029, z=0}, toPos = {x=1076, y=1096, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1018, y=1029, z=0}, toPos = {x=1076, y=1092, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=998, y=1056, z=0}, toPos = {x=1080, y=1077, z=7}, priority = 1, sound="Saffron.ogg"},
{fromPos = {x=1007, y=1036, z=0}, toPos = {x=1076, y=1086, z=7}, priority = 1, sound="Saffron.ogg"},
-- Saffron CP
{fromPos = {x=1045, y=1040, z=7}, toPos = {x=1063, y=1058, z=7}, priority = 2, sound="CP.ogg"},
-- Saffron Mark
{fromPos = {x=1021, y=1069, z=7}, toPos = {x=1029, y=1078, z=7}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1021, y=1069, z=6}, toPos = {x=1029, y=1078, z=6}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1021, y=1069, z=5}, toPos = {x=1029, y=1078, z=5}, priority = 8, sound="Mark Shop.ogg"},
-- Saffron GYM
{fromPos = {x=1091, y=1039, z=7}, toPos = {x=1096, y=1044, z=7}, priority = 3, sound="Gym Enter.ogg"},
{fromPos = {x=1088, y=1041, z=7}, toPos = {x=1099, y=1057, z=7}, priority = 2, sound="Gym Battle.ogg"},
-- Cerulean City
{fromPos = {x=1002, y=881, z=0}, toPos = {x=1094, y=941, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1049, y=869, z=0}, toPos = {x=1066, y=943, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1071, y=889, z=0}, toPos = {x=1075, y=953, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=991, y=922, z=0}, toPos = {x=1097, y=931, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1008, y=916, z=0}, toPos = {x=1113, y=920, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1009, y=892, z=0}, toPos = {x=1101, y=924, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1031, y=934, z=0}, toPos = {x=1076, y=949, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1069, y=889, z=0}, toPos = {x=1094, y=944, z=7}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1081, y=850, z=0}, toPos = {x=1096, y=868, z=5}, priority = 1, sound="Cerulean.ogg"},
{fromPos = {x=1073, y=859, z=0}, toPos = {x=1087, y=883, z=5}, priority = 1, sound="Cerulean.ogg"},
-- Cerulean CP
{fromPos = {x=1053, y=895, z=7}, toPos = {x=1071, y=913, z=7}, priority = 2, sound="CP.ogg"},
-- Cerulean Mark
{fromPos = {x=1077, y=933, z=7}, toPos = {x=1086, y=940, z=7}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1077, y=933, z=6}, toPos = {x=1086, y=940, z=6}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1077, y=933, z=5}, toPos = {x=1086, y=940, z=5}, priority = 8, sound="Mark Shop.ogg"},
-- Cerulean GYM
{fromPos = {x=1091, y=905, z=7}, toPos = {x=1095, y=909, z=7}, priority = 3, sound="Gym Enter.ogg"},
{fromPos = {x=1087, y=894, z=7}, toPos = {x=1100, y=908, z=7}, priority = 2, sound="Gym Battle.ogg"},
-- Lavender City
{fromPos = {x=1190, y=1029, z=0}, toPos = {x=1248, y=1078, z=7}, priority = 1, sound="Lavender.ogg"},
-- Lavender CP
{fromPos = {x=1192, y=1031, z=7}, toPos = {x=1210, y=1049, z=7}, priority = 2, sound="CP.ogg"},
-- Lavender Mark
{fromPos = {x=1221, y=1047, z=7}, toPos = {x=1230, y=1055, z=7}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1221, y=1047, z=6}, toPos = {x=1230, y=1055, z=6}, priority = 8, sound="Mark Shop.ogg"},
-- Lavender Cave De Choque
{fromPos = {x=1212, y=1032, z=7}, toPos = {x=1220, y=1040, z=7}, priority = 5, sound="Cave De Choque.ogg"},
-- Vermilion City
{fromPos = {x=1032, y=1202, z=0}, toPos = {x=1107, y=1299, z=7}, priority = 1, sound="Vermilion.ogg"},
-- Vermilion CP
{fromPos = {x=1065, y=1229, z=7}, toPos = {x=1083, y=1247, z=7}, priority = 2, sound="CP.ogg"},
-- Vermilion Mark
{fromPos = {x=1038, y=1205, z=7}, toPos = {x=1046, y=1214, z=7}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1038, y=1205, z=6}, toPos = {x=1046, y=1214, z=6}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=1038, y=1205, z=5}, toPos = {x=1046, y=1214, z=5}, priority = 8, sound="Mark Shop.ogg"},
-- Vermilion GYM
{fromPos = {x=1028, y=1269, z=7}, toPos = {x=1033, y=1274, z=7}, priority = 3, sound="Gym Enter.ogg"},
{fromPos = {x=1012, y=1263, z=7}, toPos = {x=1033, y=1281, z=7}, priority = 2, sound="Gym Battle.ogg"},
-- Celadon City
{fromPos = {x=855, y=1077, z=0}, toPos = {x=918, y=1141, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=919, y=1090, z=0}, toPos = {x=920, y=1136, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=921, y=1095, z=0}, toPos = {x=922, y=1137, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=923, y=1099, z=0}, toPos = {x=924, y=1135, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=925, y=1102, z=0}, toPos = {x=926, y=1133, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=927, y=1103, z=0}, toPos = {x=928, y=1132, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=929, y=1103, z=0}, toPos = {x=930, y=1130, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=931, y=1103, z=0}, toPos = {x=932, y=1131, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=933, y=1104, z=0}, toPos = {x=934, y=1126, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=935, y=1106, z=0}, toPos = {x=936, y=1125, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=1030, y=1029, z=0},toPos = {x=1042, y=1099, z=6},priority = 1, sound="Celadon.ogg"},
{fromPos = {x=937, y=1109, z=0}, toPos = {x=938, y=1124, z=6}, priority = 1, sound="Celadon.ogg"},
{fromPos = {x=939, y=1111, z=0}, toPos = {x=941, y=1118, z=6}, priority = 1, sound="Celadon.ogg"},
-- Celadon CP
{fromPos = {x=858, y=1092, z=6}, toPos = {x=866, y=1103, z=6}, priority = 2, sound="CP.ogg"},
-- Celadon Mark
{fromPos = {x=869, y=1130, z=6}, toPos = {x=879, y=1137, z=6}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=869, y=1130, z=5}, toPos = {x=879, y=1137, z=5}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=869, y=1130, z=4}, toPos = {x=879, y=1137, z=4}, priority = 8, sound="Mark Shop.ogg"},
{fromPos = {x=869, y=1130, z=3}, toPos = {x=879, y=1137, z=3}, priority = 8, sound="Mark Shop.ogg"},
-- Celadon GYM
{fromPos = {x=852, y=1112, z=6}, toPos = {x=856, y=1116, z=6}, priority = 3, sound="Gym Enter.ogg"},
{fromPos = {x=842, y=1110, z=6}, toPos = {x=856, y=1118, z=6}, priority = 2, sound="Gym Battle.ogg"},
-- Celadon Game Corner
{fromPos = {x=885, y=1080, z=6}, toPos = {x=895, y=1092, z=6}, priority = 5, sound="Game Corner.ogg"},
{fromPos = {x=885, y=1080, z=5}, toPos = {x=895, y=1092, z=5}, priority = 5, sound="Game Corner.ogg"},
-- Fuchsia City
{fromPos = {x=1158, y=1314, z=0}, toPos = {x=1237, y=1374, z=7}, priority = 1, sound="Fuchsia.ogg"},
{fromPos = {x=1238, y=1315, z=0}, toPos = {x=1252, y=1348, z=7}, priority = 1, sound="Fuchsia.ogg"},
{fromPos = {x=1247, y=1321, z=0}, toPos = {x=1260, y=1333, z=7}, priority = 1, sound="Fuchsia.ogg"},
{fromPos = {x=1213, y=1307, z=0}, toPos = {x=1237, y=1313, z=6}, priority = 28, sound="Fuchsia.ogg"},
-- Fuchsia CP
{fromPos = {x=1208, y=1319, z=7}, toPos = {x=1221, y=1328 , z=7}, priority = 2, sound="CP 2.ogg"},
-- Fuchsia Mark
{fromPos = {x=1223, y=1361, z=4}, toPos = {x=1232, y=1369, z=7}, priority = 8, sound="Mark Shop.ogg"},
-- Fuchsia GYM
{fromPos = {x=1199, y=1376, z=7}, toPos = {x=1205, y=1380, z=7}, priority = 3, sound="Gym Enter.ogg"},
{fromPos = {x=1189, y=1367, z=7}, toPos = {x=1201, y=1385, z=7}, priority = 2, sound="Gym Battle.ogg"},
-- Fuchsia Praia
{fromPos = {x=1221, y=1303, z=7}, toPos = {x=1240, y=1314, z=7}, priority = 10, sound="Passaros com agua.ogg"},
-- CAVES
-- Lavender
-- Lavender Cave De Choque
{fromPos = {x=1212, y=1032, z=7}, toPos = {x=1220, y=1040, z=7}, priority = 5, sound="Cave De Choque.ogg"},
-- Lavender Floresta Passagem De Saffron Para Lavender
{fromPos = {x=1112, y=1024, z=7}, toPos = {x=1115, y=1027, z=7}, priority = 5, sound="Floresta.ogg"},
{fromPos = {x=1116, y=1023, z=7}, toPos = {x=1189, y=1068, z=7}, priority = 5, sound="Floresta.ogg"},
{fromPos = {x=1113, y=1046, z=7}, toPos = {x=1124, y=1065, z=7}, priority = 6, sound="Floresta.ogg"},
-- Lavender Cave De Choque Andar 8
{fromPos = {x=1113, y=1009, z=8}, toPos = {x=1179, y=1058, z=8}, priority = 5, sound="Cave De Choque.ogg"},
{fromPos = {x=1180, y=993, z=8}, toPos = {x=1255, y=1055, z=8}, priority = 5, sound="Cave De Choque.ogg"},
{fromPos = {x=1256, y=988, z=8}, toPos = {x=1367, y=1051, z=8}, priority = 5, sound="Cave De Choque.ogg"},
{fromPos = {x=1368, y=968, z=8}, toPos = {x=1404, y=1041, z=8}, priority = 5, sound="Cave De Choque.ogg"},
{fromPos = {x=1405, y=950, z=8}, toPos = {x=1430, y=997, z=8}, priority = 5, sound="Cave De Choque.ogg"},
{fromPos = {x=1364, y=982, z=8}, toPos = {x=1367, y=987, z=8}, priority = 6, sound="Cave De Choque.ogg"},
{fromPos = {x=1431, y=955, z=8}, toPos = {x=1433, y=963, z=8}, priority = 6, sound="Cave De Choque.ogg"},
{fromPos = {x=1384, y=881, z=7}, toPos = {x=1452, y=971, z=7}, priority = 6, sound="Cave De Choque.ogg"},
{fromPos = {x=1453, y=881, z=7}, toPos = {x=1467, y=925, z=7}, priority = 7, sound="Cave De Choque.ogg"},
{fromPos = {x=1447, y=926, z=7}, toPos = {x=1456, y=972, z=7}, priority = 8, sound="Cave De Choque.ogg"},
{fromPos = {x=1395, y=895, z=5}, toPos = {x=1457, y=962, z=6}, priority = 9, sound="Cave De Choque.ogg"},
-- Lavender Cave Fantasma
{fromPos = {x=1225, y=1066, z=8}, toPos = {x=1308, y=1117, z=8}, priority = 5, sound="Cave Gengar.ogg"},
{fromPos = {x=1261, y=1031, z=9}, toPos = {x=1341, y=1097, z=9}, priority = 6, sound="Cave Gengar.ogg"},
{fromPos = {x=1271, y=1008, z=9}, toPos = {x=1315, y=1030, z=9}, priority = 6, sound="Perigo Gengar.ogg"},
} ----------
-- Sound
local rcSoundChannel
local showPosEvent
local playingSound
-- Design
soundWindow = nil
soundButton = nil
function toggle()
if soundButton:isOn() then
soundWindow:close()
soundButton:setOn(false)
else
soundWindow:open()
soundButton:setOn(true)
end
end
function onMiniWindowClose()
soundButton:setOn(false)
end
function init()
for i = 1, #SOUNDS do
SOUNDS[i].sound = SOUNDS_CONFIG.folder .. SOUNDS[i].sound
end
connect(g_game, { onGameStart = onGameStart,
onGameEnd = onGameEnd })
rcSoundChannel = g_sounds.getChannel(SOUNDS_CONFIG.soundChannel)
-- rcSoundChannel:setGain(value/COUNDS_CONFIG.volume)
soundButton = modules.client_topmenu.addRightGameToggleButton('soundButton', tr('Sound Info') .. '', '/images/audio', toggle)
soundButton:setOn(true)
soundWindow = g_ui.loadUI('rcsound', modules.game_interface.getRightPanel())
soundWindow:disableResize()
soundWindow:setup()
if(g_game.isOnline()) then
onGameStart()
end
end
function terminate()
disconnect(g_game, { onGameStart = onGameStart,
onGameEnd = onGameEnd })
onGameEnd()
soundWindow:destroy()
soundButton:destroy()
end
function onGameStart()
stopSound()
toggleSoundEvent = addEvent(toggleSound, SOUNDS_CONFIG.checkInterval)
end
function onGameEnd()
stopSound()
removeEvent(toggleSoundEvent)
end
function isInPos(pos, fromPos, toPos)
return
pos.x>=fromPos.x and
pos.y>=fromPos.y and
pos.z>=fromPos.z and
pos.x<=toPos.x and
pos.y<=toPos.y and
pos.z<=toPos.z
end
function toggleSound()
local player = g_game.getLocalPlayer()
if not player then return end
local pos = player:getPosition()
local toPlay = nil
for i = 1, #SOUNDS do
if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then
if(toPlay) then
toPlay.priority = toPlay.priority or 0
if((toPlay.sound~=SOUNDS[i].sound) and (SOUNDS[i].priority>toPlay.priority)) then
toPlay = SOUNDS[i]
end
else
toPlay = SOUNDS[i]
end
end
end
playingSound = playingSound or {sound='', priority=0}
if(toPlay~=nil and playingSound.sound~=toPlay.sound) then
g_logger.info("RC Sounds: New sound area detected:")
g_logger.info(" Position: {x=" .. pos.x .. ", y=" .. pos.y .. ", z=" .. pos.z .. "}")
g_logger.info(" Music: " .. toPlay.sound)
stopSound()
playSound(toPlay.sound)
playingSound = toPlay
elseif(toPlay==nil) and (playingSound.sound~='') then
g_logger.info("RC Sounds: New sound area detected:")
g_logger.info(" Left music area.")
stopSound()
end
toggleSoundEvent = scheduleEvent(toggleSound, SOUNDS_CONFIG.checkInterval)
end
function playSound(sound)
rcSoundChannel:enqueue(sound, 0)
setLabel(clearName(sound))
end
function clearName(soundName)
local explode = string.explode(soundName, "/")
soundName = explode[#explode]
explode = string.explode(soundName, ".ogg")
soundName = ''
for i = 1, #explode-1 do
soundName = soundName .. explode[i]
end
return soundName
end
function stopSound()
setLabel(SOUNDS_CONFIG.noSound)
rcSoundChannel:stop()
playingSound = nil
end
function setLabel(str)
soundWindow:recursiveGetChildById('currentSound'):getChildById('value'):setText(str)
end
Module name: Som Ataques description: author: Universe Pokemon website: UniversePokemon.com autoload: true autoload-priority: 1000 scripts: [ som ] sandboxed: true @onLoad: init() @onUnload: terminate()
dofile 'neededtranslations'
-- private variables
local defaultLocaleName = 'en'
local installedLocales
local currentLocale
function sendLocale(localeName)
local protocolGame = g_game.getProtocolGame()
if protocolGame then
protocolGame:sendExtendedOpcode(ExtendedIds.Locale, localeName)
return true
end
return false
end
function createWindow()
localesWindow = g_ui.displayUI('locales')
local localesPanel = localesWindow:getChildById('localesPanel')
local layout = localesPanel:getLayout()
local spacing = layout:getCellSpacing()
local size = layout:getCellSize()
local count = 0
for name,locale in pairs(installedLocales) do
local widget = g_ui.createWidget('LocalesButton', localesPanel)
widget:setImageSource('/images/flags/' .. name .. '')
widget:setText(locale.languageName)
widget.onClick = function() selectFirstLocale(name) end
count = count + 1
end
count = math.max(1, math.min(count, 3))
localesPanel:setWidth(size.width*count + spacing*(count-1))
addEvent(function() addEvent(function() localesWindow:raise() localesWindow:focus() end) end)
end
function selectFirstLocale(name)
if localesWindow then
localesWindow:destroy()
localesWindow = nil
end
if setLocale(name) then
g_modules.reloadModules()
end
end
-- hooked functions
function onGameStart()
sendLocale(currentLocale.name)
end
function onExtendedLocales(protocol, opcode, buffer)
local locale = installedLocales[buffer]
if locale and setLocale(locale.name) then
g_modules.reloadModules()
end
end
-- public functions
function init()
installedLocales = {}
installLocales('/locales')
local userLocaleName = g_settings.get('locale', 'false')
if userLocaleName ~= 'false' and setLocale(userLocaleName) then
pdebug('Using configured locale: ' .. userLocaleName)
else
setLocale(defaultLocaleName)
connect(g_app, { onRun = createWindow })
end
ProtocolGame.registerExtendedOpcode(ExtendedIds.Locale, onExtendedLocales)
connect(g_game, { onGameStart = onGameStart })
end
function terminate()
installedLocales = nil
currentLocale = nil
ProtocolGame.unregisterExtendedOpcode(ExtendedIds.Locale)
disconnect(g_app, { onRun = createWindow })
disconnect(g_game, { onGameStart = onGameStart })
end
function generateNewTranslationTable(localename)
local locale = installedLocales[localename]
for _i,k in pairs(neededTranslations) do
local trans = locale.translation[k]
k = k:gsub('\n','\\n')
k = k:gsub('\t','\\t')
k = k:gsub('\"','\\\"')
if trans then
trans = trans:gsub('\n','\\n')
trans = trans:gsub('\t','\\t')
trans = trans:gsub('\"','\\\"')
end
if not trans then
print(' ["' .. k .. '"]' .. ' = false,')
else
print(' ["' .. k .. '"]' .. ' = "' .. trans .. '",')
end
end
end
function installLocale(locale)
if not locale or not locale.name then
error('Unable to install locale.')
end
if _G.allowedLocales and not _G.allowedLocales[locale.name] then return end
if locale.name ~= defaultLocaleName then
local updatesNeeded = 0
for _i,k in pairs(neededTranslations) do
if locale.translation[k] == nil then
updatesNeeded = updatesNeeded + 1
end
end
if updatesNeeded > 0 then
pdebug('Locale \'' .. locale.name .. '\' is missing ' .. updatesNeeded .. ' translations.')
end
end
local installedLocale = installedLocales[locale.name]
if installedLocale then
for word,translation in pairs(locale.translation) do
installedLocale.translation[word] = translation
end
else
installedLocales[locale.name] = locale
end
end
function installLocales(directory)
dofiles(directory)
end
function setLocale(name)
local locale = installedLocales[name]
if locale == currentLocale then return end
if not locale then
pwarning("Locale " .. name .. ' does not exist.')
return false
end
if currentLocale then
sendLocale(locale.name)
end
currentLocale = locale
g_settings.set('locale', name)
if onLocaleChanged then onLocaleChanged(name) end
return true
end
function getInstalledLocales()
return installedLocales
end
function getCurrentLocale()
return currentLocale
end
-- global function used to translate texts
function _G.tr(text, ...)
if currentLocale then
if tonumber(text) then
-- todo: use locale information to calculate this. also detect floating numbers
local out = ''
local number = tostring(text):reverse()
for i=1,#number do
out = out .. number:sub(i, i)
if i % 3 == 0 and i ~= #number then
out = out .. ','
end
end
return out:reverse()
elseif tostring(text) then
local translation = currentLocale.translation[text]
if not translation then
if translation == nil then
if currentLocale.name ~= defaultLocaleName then
pdebug('Unable to translate: \"' .. text .. '\"')
end
end
translation = text
end
return string.format(translation, ...)
end
end
return text
end
local barPoke = nil
local icons = {}
-- Public functions
function init()
barPoke = g_ui.displayUI('barpoke', modules.game_interface.getRootPanel())
barPoke:setVisible(false)
connect(g_game, 'onTextMessage', getParams)
connect(g_game, { onGameEnd = hide } )
connect(g_game, { onGameStart = show } )
createIcons()
g_mouse.bindPress(barPoke, function() createMenu() end, MouseRightButton)
g_game.talk("/pokeread")
end
function terminate()
disconnect(g_game, { onGameEnd = hide })
disconnect(g_game, 'onTextMessage', getParams)
destroyIcons()
barPoke:destroy()
end
function getParams(mode, text)
if not g_game.isOnline() then return end
if mode == MessageModes.Failure then
if string.find(text, 'p#') then
atualizarBar(text)
end
end
end
function atualizarBar(text)
if not g_game.isOnline() then return end
local talk = "/goaction"
show()
cleanAllPokes()
local t = string.explode(text, ",")
local nums = tostring(#t)
if nums == '20' then
local x = 1
local x2 = 2
local x3 = 3
local x4 = 4
local x5 = 5
local x6 = 6
local idport = t[2]
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local poke2 = t[6]
local life2 = t[7]
local idport3 = t[8]
local poke3 = t[9]
local life3 = t[10]
local idport4 = t[11]
local poke4 = t[12]
local life4 = t[13]
local idport5 = t[14]
local poke5 = t[15]
local life5 = t[16]
local idport6 = t[17]
local poke6 = t[18]
local life6 = t[19]
local progress = icons['Icon'..x].progress
local progress2 = icons['Icon'..x2].progress
local progress3 = icons['Icon'..x3].progress
local progress4 = icons['Icon'..x4].progress
local progress5 = icons['Icon'..x5].progress
local progress6 = icons['Icon'..x6].progress
changeIconPoke(x, poke,life)
changeIconPoke(x2, poke2,life2)
changeIconPoke(x3, poke3,life3)
changeIconPoke(x4, poke4,life4)
changeIconPoke(x5, poke5,life5)
changeIconPoke(x6, poke6,life6)
--changeIconPoke(x, idport,life)
--changeIconPoke(x2, idport2,life2)
--changeIconPoke(x3, idport3,life3)
--changeIconPoke(x4, idport4,life4)
--changeIconPoke(x5, idport5,life5)
--changeIconPoke(x6, idport6,life6)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
progress2.onClick = function() g_game.talk(talk.." "..poke2.."")end
progress3.onClick = function() g_game.talk(talk.." "..poke3.."")end
progress4.onClick = function() g_game.talk(talk.." "..poke4.."")end
progress5.onClick = function() g_game.talk(talk.." "..poke5.."")end
progress6.onClick = function() g_game.talk(talk.." "..poke6.."")end
elseif nums == '17' then
local x = 1
local x2 = 2
local x3 = 3
local x4 = 4
local x5 = 5
local x6 = 6
local idport = t[2]
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local poke2 = t[6]
local life2 = t[7]
local idport3 = t[8]
local poke3 = t[9]
local life3 = t[10]
local idport4 = t[11]
local poke4 = t[12]
local life4 = t[13]
local idport5 = t[14]
local poke5 = t[15]
local life5 = t[16]
local progress = icons['Icon'..x].progress
local progress2 = icons['Icon'..x2].progress
local progress3 = icons['Icon'..x3].progress
local progress4 = icons['Icon'..x4].progress
local progress5 = icons['Icon'..x5].progress
changeIconPoke(x, poke,life)
changeIconPoke(x2, poke2,life2)
changeIconPoke(x3, poke3,life3)
changeIconPoke(x4, poke4,life4)
changeIconPoke(x5, poke5,life5)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
progress2.onClick = function() g_game.talk(talk.." "..poke2.."")end
progress3.onClick = function() g_game.talk(talk.." "..poke3.."")end
progress4.onClick = function() g_game.talk(talk.." "..poke4.."")end
progress5.onClick = function() g_game.talk(talk.." "..poke5.."")end
elseif nums == '14' then
local x = 1
local x2 = 2
local x3 = 3
local x4 = 4
local idport = t[2]
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local poke2 = t[6]
local life2 = t[7]
local idport3 = t[8]
local poke3 = t[9]
local life3 = t[10]
local idport4 = t[11]
local poke4 = t[12]
local life4 = t[13]
local progress = icons['Icon'..x].progress
local progress2 = icons['Icon'..x2].progress
local progress3 = icons['Icon'..x3].progress
local progress4 = icons['Icon'..x4].progress
changeIconPoke(x, poke,life)
changeIconPoke(x2, poke2,life2)
changeIconPoke(x3, poke3,life3)
changeIconPoke(x4, poke4,life4)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
progress2.onClick = function() g_game.talk(talk.." "..poke2.."")end
progress3.onClick = function() g_game.talk(talk.." "..poke3.."")end
progress4.onClick = function() g_game.talk(talk.." "..poke4.."")end
elseif nums == '11' then
local x = 1
local x2 = 2
local x3 = 3
local idport = t[2]
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local poke2 = t[6]
local life2 = t[7]
local idport3 = t[8]
local poke3 = t[9]
local life3 = t[10]
local progress = icons['Icon'..x].progress
local progress2 = icons['Icon'..x2].progress
local progress3 = icons['Icon'..x3].progress
changeIconPoke(x, poke,life)
changeIconPoke(x2, poke2,life2)
changeIconPoke(x3, poke3,life3)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
progress2.onClick = function() g_game.talk(talk.." "..poke2.."")end
progress3.onClick = function() g_game.talk(talk.." "..poke3.."")end
elseif nums == '8' then
local x = 1
local x2 = 2
local idport = t[2]
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local poke2 = t[6]
local life2 = t[7]
local progress = icons['Icon'..x].progress
local progress2 = icons['Icon'..x2].progress
changeIconPoke(x, poke,life)
changeIconPoke(x2, poke2,life2)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
progress2.onClick = function() g_game.talk(talk.." "..poke2.."")end
elseif nums == '5' then
local x = 1
local x2 = 2
local poke = t[3]
local life = t[4]
local idport2 = t[5]
local progress = icons['Icon'..x].progress
changeIconPoke(x, poke,life)
progress.onClick = function() g_game.talk(talk.." "..poke.."")end
end
--for i=2, #t-1 do
--x= i-1
--local poke = t[i]
--local progress = icons['Icon'..x].progress
--changeIconPoke(x, poke)
--progress.onClick = function() g_game.talk(talk.." "..t[i].."")
--end
--end
end
function FixTooltip(text)
barPoke:setHeight(isIn == 'H' and 316 or 55)
barPoke:setWidth(isIn == 'H' and 55 or 316)
local diste = 0
for j = 1, 7 do
local icon = icons['Icon'..j].icon
if isIn == 'H' then
icon:setMarginLeft(6)
icon:setMarginTop(diste)
diste = diste+45
else
icon:setMarginLeft(diste)
diste = diste+45
icon:setMarginTop(6)
end
end
local diste = 0
for j = 8, 13 do
local icon = icons['Icon'..j].icon
if isIn == 'H' then
icon:setMarginLeft(6)
diste = diste+43
icon:setMarginTop(diste)
else
icon:setMarginLeft(diste)
diste = diste+45
icon:setMarginTop(38)
end
end
end
function changeIconPoke(i, poke,life)
if not g_game.isOnline() then return end
local icon = icons['Icon'..i].icon
if string.find(string.lower(poke), "shiny") then
poke = poke:gsub("Shiny ", "")
elseif string.find(string.lower(poke), "giant") then
poke = poke:gsub("Giant ", "")
elseif string.find(string.lower(poke), "elite") then
poke = poke:gsub("Elite ", "")
elseif string.find(string.lower(poke), "ancient") then
poke = poke:gsub("Ancient ", "")
elseif string.find(string.lower(poke), "mega") then
poke = poke:gsub("Mega ", "")
elseif string.find(string.lower(poke), "crystal") then
poke = poke:gsub("Crystal ", "")
elseif string.find(string.lower(poke), "elder") then
poke = poke:gsub("Elder ", "")
elseif string.find(string.lower(poke), "royal") then
poke = poke:gsub("Royal ", "")
end
local image = "portraits/"..poke..".png"
icon:setImageSource(image)
local numer = tonumber(life)
local pokeid = tonumber(poke)
-- icon:setItemId(pokeid)
local icon2 = icons['Icon'..i+7].icon
if numer <= 30 then
icon2:setColor('#FF0000')
elseif numer <= 50 then
icon2:setColor('#00CED1')
elseif numer <= 70 then
icon2:setColor('#0000FF')
elseif numer <= 90 then
icon2:setColor('#00008B')
else
icon2:setColor('#000000')
end
--icon:setPercent(numer)
--icon:setPercent(life)
icon2:setText(life.."%")
--icon:setStyle('Item')
-- icon:setItem(poke)
end
function createIcons()
local d = 45
-- if d == 45 then
-- createIcons3()
--return true
--end
local image = "portraits/portait.png"
local image2 = "portraits/update.png"
local diste = 0
for i = 1, 7 do
local icon = g_ui.createWidget('IconPoke', barPoke)
local progress = g_ui.createWidget('Poke', barPoke)
icon:setId('Icon'..i)
progress:setId('Progress'..i)
icons['Icon'..i] = {icon = icon, progress = progress, dist = diste, event = nil}
icon:setMarginLeft(icons['Icon'..i].dist)
diste = diste+45
if i == 7 then
image = image2
end
icon:setImageSource(image)
--icon:setItemId(7605)
icon:setMarginTop(6)
if i == 7 then
--icon:setStyle('UIItem')
--icon:setVirtual(true)
--icon:setItemId(3423)
progress.onClick = function() g_game.talk("/pokeread otclient") end
end
progress:fill(icon:getId())
end
createIcons2()
end
function createIcons2()
local d = 45
local image = "portraits/percent.png"
local diste = 0
for i = 8, 13 do
local icon = g_ui.createWidget('IconPoke2', barPoke)
icon:setId('Icon'..i)
icons['Icon'..i] = {icon = icon, dist = diste, event = nil}
icon:setMarginLeft(icons['Icon'..i].dist)
diste = diste+45
icon:setImageSource(image)
--icon:setItemId(7605)
icon:setMarginTop(40)
end
end
function createIcons3()
local d = 45
local image = "portraits/percent.png"
local diste = 0
local icon3 = g_ui.createWidget('Item', barPoke)
icon3:setItemId(7605)
local icon4 = g_ui.createWidget('Item', icon3)
icon4:setItemId(7605)
icon4.onClick = function() g_game.talk(getServerId(7605)) end
local image = "portraits/portait.png"
icon4:setItemId(7605)
-- icon3.onClick = function() g_game.talk("dsds") end
end
function cleanAllPokes()
local image = "portraits/portait.png"
for i = 1, 6 do
local icon = icons['Icon'..i].icon
icon.onClick = function() end
icon:setImageSource(image)
icon:setText("")
local progress = icons['Icon'..i].progress
progress.onClick = function() g_game.talk("") end
local icon2 = icons['Icon'..i+7].icon
icon2:setText("")
end
end
function createMenu()
local menu = g_ui.createWidget('PopupMenu')
menu:addOption("Set "..(isIn == 'H' and 'Vertical' or 'Horizontal'), function() toggle() end)
menu:display()
end
function toggle()
if not barPoke:isVisible() then return end
barPoke:setVisible(false)
if isIn == 'H' then
isIn = 'V'
else
isIn = 'H'
end
FixTooltip()
show()
end
function hide()
barPoke:setVisible(false)
end
function show()
barPoke:setVisible(true)
end
-- End public functions
Module name: Up Pokemon Bar description: author: Pokemon Up website: www.universepokemon.com autoload: true autoload-priority: 1000 scripts: [ barpoke ] sandboxed: true @onLoad: init() @onUnload: terminate()
noSound = 'No sound file for this area.',
Ta dando erro porque faltou configurar o nome desse som ai
Essa função não existe no arquivo, basta remover a linha que contem 'destroyIcons()' que se encontra na função terminate. Isso vai remover o erro que tu citou, porem creio eu que tenha faltado essa função no module, tente ver se de onde tu copiou nao existe essa função que tu pode ter esquecidodestroyIcons
info
Grupo: Conde
Registrado: 12/04/15
Posts: 655
Reputação: +65
Gênero: Masculino
Char no Tibia: Developer Berg
Olá gente, queria a ajuda de vocês hoje para tirar alguns erros do meu otclient quando eu mudo de linguagem, tipo, eu deixo o otclient em Português, ai quando eu mudo para qual quer outra linguagem, exemplo ( Inglês ) da uns erros no otc, queria a ajuda de vcs para remover esses erros.
ERROR: Unable to unload module 'Som Ataques': LUA ERROR: /rc_sound/rcsound.lua:302: attempt to index a nil value stack traceback: [C]: ? /rc_sound/rcsound.lua:302: in function 'setLabel' /rc_sound/rcsound.lua:296: in function 'stopSound' /rc_sound/rcsound.lua:227: in function 'onGameEnd' /rc_sound/rcsound.lua:216: in function 'terminate' /game_som/som.otmod:13:[@onUnload]:1: in main chunk [C]: in function 'reloadModules' /client_locales/locales.lua:45: in function 'selectFirstLocale' /client_locales/locales.lua:29: in function </client_locales/locales.lua:29> ERROR: Unable to unload module 'Up Pokemon Bar': LUA ERROR: /game_barpoke/barpoke.lua:23: attempt to call global 'destroyIcons' (a nil value) stack traceback: [C]: in function 'destroyIcons' /game_barpoke/barpoke.lua:23: in function 'terminate' /game_barpoke/barpoke.otmod:13:[@onUnload]:1: in main chunk [C]: in function 'reloadModules' /client_locales/locales.lua:45: in function 'selectFirstLocale' /client_locales/locales.lua:29: in function </client_locales/locales.lua:29>Up