local function cTrue(val) return val and val ~= 0 and val ~= '' and val ~= {} end local function allTrue(tbl) if type(tbl) ~= 'table' then return false end local check = true for i = 1, #tbl do if not cTrue(tbl[i]) then check = false break end end return check end local function valid(u) return u and u.valid end local function playerValid(p, inv) if cTrue(inv) then return valid(p) and valid(p.player) end return valid(p) and valid(p.mo) end local function strsplit(str, sep) local result = {} local start = 1 while true do local pos = string.find(str, sep, start, true) if not pos then table.insert(result, string.sub(str, start)) break end table.insert(result, string.sub(str, start, pos - 1)) start = pos + #sep end return result end local function strmerge(tbl, sep) if type(tbl) ~= 'table' then return '' end local str = '' local sp = sep or '' for i = 1, #tbl do if i == #tbl then str = str..tbl[i] else str = str..tbl[i]..sp end end return str end local mann = { boy = true, m = true, man = true, male = true } local ironman = { f = true, female = true, girl = true, woman = true } local enby = { n = true, nb = true, enby = true, nonbinary = true, ['non-binary'] = true } COM_AddCommand('pronouns', function(p, arg, gra) if playerValid(p) then if cTrue(arg) then local file = io.openlocal('client/pronouns.dat','w+') if mann[arg:lower()] == true then p.pronouns = {'he', 'him', 'his'} if file then file:write(strmerge(p.pronouns, '/')) file:close() end CONS_Printf(p, 'You now have male pronouns.') end if ironman[arg:lower()] == true then p.pronouns = {'she', 'her', 'hers'} if file then file:write(strmerge(p.pronouns, '/')) file:close() end CONS_Printf(p, 'You now have female pronouns.') end if enby[arg:lower()] == true then p.pronouns = {'they', 'them', 'their'} if file then file:write(strmerge(p.pronouns, '/')) file:close() end CONS_Printf(p, 'You now have nonbinary pronouns.') end if arg:lower() == 'custom' then if not cTrue(gra) then CONS_Printf(p,'Usage: pronouns custom SUBJECT/OBJECT/POSSESSIVE | Sets custom pronouns.') return end local pr = strsplit(gra:lower(), '/') if #pr < 3 then CONS_Printf(p, 'A subject, object and possesive pronoun are required.') CONS_Printf(p, '(In the form of \"SUBJECT/OBJECT/POSSESSIVE\")') return end p.pronouns = pr if file then file:write(strmerge(p.pronouns, '/')) file:close() end CONS_Printf(p, 'You now have custom pronouns. ('..strmerge(pr, '/')..')') end else CONS_Printf(p,'Usage: pronouns pronouns> | Sets your pronouns.') CONS_Printf(p,'Built-in genders: male, female, nonbinary') CONS_Printf(p,'Your current pronouns are: '..strmerge(p.pronouns, '/')) end else CONS_Printf(p, 'You need to be in a level to use this.') end end, COM_LOCAL) addHook('PreThinkFrame', function() for p in players.iterate do if not playerValid(p) then continue end if type(p.pronouns) == 'table' then continue end local file = io.openlocal('client/pronouns.dat') if file then local pronouns = file:read('*a') p.pronouns = strsplit(pronouns, '/') file:close() else p.pronouns = {'they', 'them', 'theirs'} end CONS_Printf(p, 'Pronouns loaded!') end end)