Lua error unpack() too many results to unpack

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Lua error unpack() too many results to unpack

by addi » Thu Mar 03, 2016 08:56

hi,

since Minetest have a http api and can handle the JSON format, I decided to write a library for my skin Db.
If its finished, It should download and save the skin files to the hdd.

As current state everything works great, until I try to fetch the following skin:
http://minetest.fensta.bplaced.net/#!pa ... ,filter:19

the response looks good, and the final png size of it should also look also good (2.8 Kb)

but if I convert the Base64 of the image file I get the error unpack() too many results to unpack.

the function to decode gets called here: https://bitbucket.org/adrido/skindb-dri ... nit.lua-23
and the error happens here:
https://bitbucket.org/adrido/skindb-dri ... 64.lua-281

for the pages 1-11 everything works great, only page 12 makes trouble. (currently I fetching only 1 skin per page, to make debugging easier)
I think its not the file size itself, because Sam_I is 4 Kb big and this works good.

If I overwrite the unpack function to
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function unpack (t, i)
     i = i or 1
      if t
[i] ~= nil then
        return t
[i], unpack(t, i + 1)
      end
    end

it works fine.

Is there a limitation to the unpack() function by minetest? Can it removed or changed somehow?

I found an alternative Base64decoding library, which seems to be pretty fast, but it requires lua 5.2 or a modern version of LuaJit, so I cannot use it.
Will Minetest update lua to Lua 5.2 or 5.3 on some day?
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Lua error unpack() too many results to unpack

by addi » Thu Mar 03, 2016 12:17

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function unpack (t, i)
         i = i or 1
          if t
[i] ~= nil then
            return t
[i], unpack(t, i + 1)
          end
        end

this worked not as great as I thought before... sometimes this produced a stack-overflow.

so I wrote this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function get_str(t)
    local str = "";
    for i,c in ipairs(t) do
        if
( c ~= nil ) then
            str 
= str..string.char(c)
        end
    end
    return str
;
end

but sadly its horrible slow ... :-(
does someone know a way which is a bit faster?
or is there an faster way to append a char to a string in lua?
 

User avatar
rnd
Member
 
Posts: 136
Joined: Sun Dec 28, 2014 12:24
IRC: ac_minetest
In-game: rnd

Re: Lua error unpack() too many results to unpack

by rnd » Thu Mar 03, 2016 12:53

http://lua-users.org/wiki/TableLibraryTutorial
table.concat(table [, sep [, i [, j]]])
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Lua error unpack() too many results to unpack

by addi » Thu Mar 03, 2016 13:37

table.concat(t,"") does not produce a valid *.png file :-(
Maybe because t contains about 1000 number values that have to converted into a char first. sadly lua isnt C :-(

but thanks for the help.
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Lua error unpack() too many results to unpack

by addi » Thu Mar 03, 2016 16:53

Due the limitations of lua I tried to do some optimizations on the skinDb itself.
I could optimize the progress time of 1 skin from ~1300 ms to ~77ms. Its still a long lua progress duration, but its much faster now.
Ill apply this optimizations to the other skins too.
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Lua error unpack() too many results to unpack

by addi » Fri Mar 04, 2016 09:14

The optimisations on the side of Skin DB speed up the total compressing time for all skins from 90 seconds to 70 seconds, which is still slow.
So I tried LuaJit, which speed up that very much. The processing time for 663 Skins takes now 20 seconds! (Still slow, but acceptable)
I think ill deploy my installers with LuaIit now.

If someone is interested into the profiling data, they are in attachment.
Attachments
skins-processing-times.zip
(26.39 KiB) Downloaded 59 times
 

red-001
Member
 
Posts: 126
Joined: Tue Jan 26, 2016 20:15
GitHub: red-001
IRC: red-001

Re: Lua error unpack() too many results to unpack

by red-001 » Fri Aug 26, 2016 10:18

Is this still being worked on?
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Lua error unpack() too many results to unpack

by addi » Fri Aug 26, 2016 12:16

since https://github.com/minetest/minetest/pull/3919 is merged now, this could speed it up much.

But due the discussions viewtopic.php?f=5&t=15387 and https://github.com/minetest/minetest_game/issues/1235 Im not sure if the Minetest SkinDb or at least Minetest skins have a future :-(
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Lua error unpack() too many results to unpack

by azekill_DIABLO » Tue Aug 30, 2016 13:28

:[
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Lua error unpack() too many results to unpack

by Byakuren » Tue Aug 30, 2016 23:10

You could run the conversion tool on the skins in the DB.
Every time a mod API is left undocumented, a koala dies.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 19 guests

cron