some tips for ur lua code to have better performance
#1.1
instead each time calling global functions u can cache them into local ones
-- bad
local player = getPlayer()
-- good
local getPlayer = getPlayer -- here we caching `getPlayer` function so script won't call it from _G but from local scope => it's faster
local player = getPlayer()
#1.2
in addition u can cache class function
-- bad
local item_module = item:getModule()
local item_full_type = item:getFullType()
-- good
local item_base = __classmetatables[InventoryItem.class].__index
local item_getFullType = item_base.getFullType
local item_getModule = item_base.getModule
local item_full_type = item_getModule(item)
local item_module = item_getFullType(item)
#1.3
please cache textures too 
-- bad
drawTexture(getTexture("media/.../img1.png"), ...)
drawTexture(getTexture("media/.../img2.png"), ...)
-- good
local textures = {
[1] = getTexture("media/.../img1.png")
[2] = getTexture("media/.../img2.png")
}
drawTexture(textures[1], ...)
drawTexture(textures[2], ...)
#2
instead checking if ur table have some value u can use value as keys and just index the table by this value
-- bad
local tbl = {"1", "ab", "cd",}
for k,v in pairs(tbl) if v == "cd" then ... end
-- good
local tbl = {["1"] = true, ["ab"] = true, ["cd"] = true,}
if tbl["cd"] then .. end
-- u can use objects same way
local tbl = {[getSpecificPlayer(...)] = true, [getSquare(...)] = true}
if tbl[getPlayer()] then ... end
if tbl[getPlayer():getCurrentSquare()] then ... end
P.S. u must ALWAYS AVOID loops when u can use table with value as key
#3
DON'T USE PAIRS for sequence table
local tbl = {"a", 5, "7", "sdfsdf", "bla"}
-- full shit
for k,v in pairs(tbl) do ... end
-- not full shit but still bad
for k,v in ipairs(tbl) do ... end
-- good
for k = 1, #tbl do v = tbl[k] ... end