Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: iitiago on September 27, 2019, 05:12:02 PM

Title: What does this piece of code do?
Post by: iitiago 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
Title: Re: What does this piece of code do?
Post by: MrPresident 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.
Title: Re: What does this piece of code do?
Post by: iitiago 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!
Title: Re: What does this piece of code do?
Post by: JamminR 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