function _GetWhitelist(name)
if not _whitelists[name] then
print('Unable to get whitelist ('..name..') - does not exist')
return false
end
local Whitelist = {}
Whitelist.__index = Whitelist
function Whitelist.new(wl)
local self = setmetatable({}, Whitelist)
self.name = wl.name or 'unknown'
self.roles = wl.roles or {}
self.players = wl.players or {}
self.duty = {}
function self:getName()
return self.name
end
function self:changeName(something)
self.name = something or 'unknown'
print(self.name)
end
return self
end
return Whitelist.new(_whitelists[name])
end
WL = _GetWhitelist('police')
print(WL) -- print the object reference
local wl_name = WL:getName()
print('Created whitelist: '..wl_name)
WL:changeName('testing')
print('Changed whitelist name to: '..WL:getName())
The print inside the changeName() function prints the correct value, but the following WL:getName() always returns the orignal value, is there a way I can update the self values? Any help would be appreciated, first time using lua classes like this :)
Tried to update the values inside self, but they didn't update when I called the getName() function again.