[lua] Long function

Viewer

copydownloadembedprintName: Long function
  1. function GetPlayerAppPerms()
  2.     local apps = {}
  3.     local playerJob, playerGang = PlayerData.job.name, PlayerData.gang.name
  4.     for _, app in pairs(Config.Apps) do
  5.         local hasAccess = false
  6.         local converted = {
  7.             name = app.app,
  8.             icon = app.icon,
  9.             text = app.name,
  10.             color = app.color,
  11.             background = app.background,
  12.             useimage = app.useimage
  13.         }
  14.         if app.default and not hasAccess then
  15.             apps[#apps + 1] = converted
  16.             hasAccess = true
  17.         end
  18.         if app.job then
  19.             if type(app.job) == 'table' then
  20.                 for i = 1, #app.job do
  21.                     if app.job[i] == playerJob then
  22.                         apps[#apps + 1] = converted
  23.                         hasAccess = true
  24.                     end
  25.                 end
  26.             else
  27.                 if app.job == playerJob then
  28.                     apps[#apps + 1] = converted
  29.                     hasAccess = true
  30.                 end
  31.             end
  32.         end
  33.         if app.gang and not hasAccess then
  34.             if type(app.gang) == 'table' then
  35.                 for i = 1, #app.gang do
  36.                     if app.gang[i] == playerGang then
  37.                         apps[#apps + 1] = converted
  38.                         hasAccess = true
  39.                     end
  40.                 end
  41.             else
  42.                 if app.gang == playerGang then
  43.                     apps[#apps + 1] = converted
  44.                     hasAccess = true
  45.                 end
  46.             end
  47.         end
  48.         if app.item and not hasAccess then
  49.             if type(app.item) == 'table' then
  50.                 for i = 1, #app.item do
  51.                     if haveItem(app.item[i]) then
  52.                         apps[#apps + 1] = converted
  53.                         hasAccess = true
  54.                     end
  55.                 end
  56.             else
  57.                 if haveItem(app.item) then
  58.                     apps[#apps + 1] = converted
  59.                     hasAccess = true
  60.                 end
  61.             end
  62.         end
  63.     end
  64.     return apps
  65. end

Editor

You can edit this paste and save as new:


File Description
  • Long function
  • Paste Code
  • 30 Jun-2022
  • 2.11 Kb
You can Share it: