Post your best Lua script examples here

User avatar
By jankop
#45430 I need to convert a simple function LoadBuff() to module, because of length. Somehow I fail. Can you help me, please?

Code: Select allbuff1=""

function LoadBuff()
local buff2 = "String no.1"
buff1 = "String no.2"..buff2
buff2=nil
collectgarbage()
end

LoadBuff()
print(buff1)
User avatar
By TerryE
#45638 You don't need to convert this to a module. How will this help?

What you do need to do is to use the cloud builder to create an up to date dev build of the firmware which will almost treble the amount of free RAM. Just make sure that you only include the modules that you are going to need.
User avatar
By jankop
#45640 Minimum version of Lua I am using long ago, but it does not solve my problem. I'm processing very long strings and Lua has got big problems. Therefore, I must resort to unconventional solutions.
But thank you for your response.
User avatar
By TerryE
#45727 If you are building up long strings using the .. operator then you are doing this the wrong way. It is more memory efficient to store them in an array and use table.concat to build up the final string in one go. Read up on how Lua stores strings internally. My FAQ has a link to the standard Lua unofficial FAQ which discusses this.