ULX

Author Topic: What does this piece of code do?  (Read 99 times)

0 Members and 1 Guest are viewing this topic.

Offline iitiago

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
What does this piece of code do?
« on: September 27, 2019, 05:12:02 PM »
I'm learning lua so I'm studying gmod lua addons and found this piece of code. What does this do exactly? and what does it return?
Code: [Select]
local function hasAccess(ply)
if ulx then
return ply:query("ulx seeasay")
end

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2708
  • Karma: 424
    • |G4P| Gman4President
Re: What does this piece of code do?
« Reply #1 on: September 27, 2019, 05:38:22 PM »
ply:query is checking ULib to see if the player (represented by ply here) has the "ulx seeasay" permission flag.
The rest of the code is just wrapping our permission check function inside of another function, presumably so they can support multiple admin mods if needed.

Offline iitiago

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: What does this piece of code do?
« Reply #2 on: September 27, 2019, 06:07:56 PM »
ply:query is checking ULib to see if the player (represented by ply here) has the "ulx seeasay" permission flag.
The rest of the code is just wrapping our permission check function inside of another function, presumably so they can support multiple admin mods if needed.

Thank you so much!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8030
  • Karma: 382
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: What does this piece of code do?
« Reply #3 on: September 27, 2019, 07:05:25 PM »
litiago, and if it's not obvious, 'query' is not a standard Lua, or Gmod lua function.
It's part of our Ulysses Library (ULib)
Documented here - https://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#ucl.query
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming