Th1rust
(Ozzy)
#1
I want to check if a bunch of global variables ~= nil
, but its very ineffecient and repetitive to write out
if _G.a ~= nil and _G.b ~= nil and --[[repeat until your fingers hurt]]--
Could you instead do something like this?
if (_G.a and _G.b and _G.c) ~= nil then
Just iterate through the variables?
local isAllNil = true
for _, value in table_of_variables do
if value ~= nil then
isAllNil = false
break
end
end
if isAllNil then blah blah blah
P.S. Global state is evil.
1 Like
Neither:
if _G.a and _G.b and _G.c then
end
Also what @Pokemoncraft5290 said at the bottom
1 Like
Th1rust
(Ozzy)
#4
I’ll have to test this. I use global variables to avoid value instances, this script acts as a sort of value manager for the other’s. Thank you.
Th1rust
(Ozzy)
#5
So, when you use an if statement like that it doesn’t check for true and instead checks if it has a value or exists?
system
(system)
Closed
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.