Skip to content

Instantly share code, notes, and snippets.

@lennyRBLX
Last active May 10, 2019 01:39
Show Gist options
  • Save lennyRBLX/c20de70810eac2a7b82827a8a7e10a81 to your computer and use it in GitHub Desktop.
Save lennyRBLX/c20de70810eac2a7b82827a8a7e10a81 to your computer and use it in GitHub Desktop.
Keyword Generator; Prints out all of the possible combinations out of the "keywords" table
local keywords = {"test", "keyword", "2", "one", "hello", "world", "!"}
local posted = {}
function table.find(array, tofind)
if not type(array) == "table" then return end
for i,v in pairs(array) do
if i == tofind or v == tofind then
return i
end
end
end
if #keywords > 0 then
for i,v in pairs(keywords) do
if posted[i] then
if keywords[i + 1] then
print(v .. ' ' .. keywords[i + 1])
posted[#posted + 1] = v .. ' ' .. keywords[i + 1]
end
else
print(v)
posted[i] = v
end
for x,c in pairs(posted) do
for i = 0, #keywords * #keywords do
local chosen = math.random(1, #keywords)
if not table.find(posted, v .. ' ' .. tostring(keywords[chosen])) and not table.find(posted, v .. ' ' .. tostring(keywords[i - 1])) then
if keywords[i - 1] == nil or keywords[x] == nil then
print(v .. ' ' .. tostring(keywords[chosen]))
posted[#posted + 1] = v .. ' ' .. tostring(keywords[chosen])
else
print(v .. ' ' .. tostring(keywords[i - 1]))
print(v .. ' ' .. tostring(keywords[chosen]))
posted[#posted + 1] = v .. ' ' .. tostring(keywords[i - 1])
posted[#posted + 1] = v .. ' ' .. tostring(keywords[chosen])
end
elseif table.find(posted, v .. ' ' .. tostring(keywords[chosen])) or table.find(posted, v .. ' ' .. tostring(keywords[i - 1])) then
if not table.find(posted, c .. ' ' .. tostring(keywords[chosen])) and not table.find(posted, c .. ' ' .. tostring(keywords[i - 1])) then
if keywords[i - 1] == nil or keywords[x] == nil then
print(c .. ' ' .. tostring(keywords[chosen]))
posted[#posted + 1] = c .. ' ' .. tostring(keywords[chosen])
else
print(c .. ' ' .. tostring(keywords[i - 1]))
print(c .. ' ' .. tostring(keywords[chosen]))
posted[#posted + 1] = c .. ' ' .. tostring(keywords[i - 1])
posted[#posted + 1] = c .. ' ' .. tostring(keywords[chosen])
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment