0
I need to access some data stored in a file .lua
in PHP.
This is the contents of the archive meu_arquivo.lua
:
tbl = {
[22004] = {
unidentifiedDisplayName = "Sapato",
unidentifiedResourceName = "»÷µé",
unidentifiedDescriptionName = {
"Item não identificado. Pode ser identificado com uma [Lupa]."
},
identifiedDisplayName = "Botas Temporais DES",
identifiedResourceName = "½Ã°£ÀǼÕÀçÁÖºÎÃ÷",
identifiedDescriptionName = {
"Botas incríveis que devem ter sido criadas há muito tempo, mas nunca foram usadas.",
"^0000ffDEX +35.^000000",
"Tipo: ^777777Calçado^000000",
"Defesa: ^77777725^000000",
"Peso: ^777777350^000000",
"Nível necessário: ^77777799^000000",
"Classes: ^777777Todas as classes^000000"
},
slotCount = 1,
ClassNum = 0
},
[22005] = {
unidentifiedDisplayName = "Sapato",
unidentifiedResourceName = "»÷µé",
unidentifiedDescriptionName = {
"Item não identificado. Pode ser identificado com uma [Lupa]."
},
identifiedDisplayName = "Botas Temporais SOR",
identifiedResourceName = "½Ã°£ÀÇÇà¿îºÎÃ÷",
identifiedDescriptionName = {
"Botas incríveis que devem ter sido criadas há muito tempo, mas nunca foram usadas.",
"^0000ffLUK +35.^000000",
"^0000ff+20 de Crítico.^000000",
"Tipo: ^777777Calçado^000000",
"Defesa: ^77777725^000000",
"Peso: ^777777350^000000",
"Nível necessário: ^77777799^000000",
"Classes: ^777777Todas as classes^000000"
},
slotCount = 1,
ClassNum = 0
}
}
Example:
I want to return the value of tbl > 22004 > unidentifiedDisplayName
that would be Sapato
as if it were an array(array) proper to PHP:
<?= $meu_arquivo['tbl']['22004']['unidentifiedDisplayName']; // mostra "Sapato" ?>
I don’t know the syntax/language of this file to point my research more accurately. My only reference is that the file is read via MOON by the original application (Game).
As much as it bears a resemblance to JSON, the function json_decode
didn’t work for this file.
Any help is welcome!
Dude, it worked great! Only thing I didn’t like was the need to tinker with PHP extensions/components (PEAR/PECL). It will make it a little difficult for hosting to add this. But it’s already worth the joinha!
– LipESprY
Glad I could help! maybe this Composer package is better for you then: https://github.com/koesie10/LuaSerializer (Capacity is limited to serialization only, but at least you do not need to install any extension)
– thiagoalessio
So, I ended up creating a class using regexp to do the service I need. It wasn’t generic: it’s very specific to my file. But it turned out to be all right. It’s very functional. But anyway, this package is 10 and totally dynamic. I’ll try it too!
– LipESprY