-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameSelector.lua
More file actions
146 lines (133 loc) · 2.79 KB
/
NameSelector.lua
File metadata and controls
146 lines (133 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
local FirstNames = {
"Alex",
"Frank",
"Bruce",
"Daniel",
"David",
"Jason",
"John",
"Joseph",
"Mike",
"Tank",
"Terrance",
"Robert",
"Richard",
"Donald"
}
local LastNames = {
"Mason",
"Woods",
"Harris",
"Clarke",
"Lynch",
"Hudson",
"Kennedy",
"Bowman",
"Harper",
"Dempsey",
"Brooks",
"Roberts",
"Jackson"
}
local menu = {"print ns","add custom n","add f n","add l n","clear f ns","clear l ns","delete f n","delete l n","stop"}
local busy = false
local function PrintFirstName(value)
for count = 1, value do
if #FirstNames ~= 0 then
print(FirstNames[math.random(1,#FirstNames)])
else print(" ")
end
end
end
local function PrintLastName(value)
for count = 1, value do
if #LastNames ~= 0 then
print(LastNames[math.random(1,#LastNames)])
else print(" ")
end
end
end
local function PrintNames(value)
for count = 1,value do
PrintFirstName(1)
PrintLastName(1)
print()
end
end
function InsertLName()
io.write("Insert any Last Name: ")
print()
local lastName = io.read()
table.insert(LastNames, lastName)
return lastName
end
function InsertFName()
io.write("Insert any First Name: ")
print()
local firstName = io.read()
table.insert(FirstNames, firstName)
return firstName
end
local function CustomName()
local name = tostring(InsertFName())..(" ")..tostring(InsertLName())
print("Added Custom Name Succesfully. Result: ".. name)
return name
end
function is_numeric(x)
if tonumber(x) ~= nil then
return true
end
return false
end
local function printContent(tab)
for i,v in ipairs(tab) do
print(i,v)
print()
end
end
local function DeleteN(tab)
for i,v in ipairs(tab) do
print(i,v)
end
io.write("Which name would you like to delete? Enter Number")
local choice = io.read()
print()
if is_numeric(nchoice) then
table.remove(tab,choice)
else print("not valid number")
end
end
while not busy do
busy = true
print()
io.write("What do you want to do?")
print()
printContent(menu)
local choice = io.read()
print()
if choice == "print ns" then
io.write("Enter Number")
print()
value = io.read()
print()
PrintNames(value)
elseif choice == "add custom n" then
CustomName()
elseif choice == "add f n" then
InsertFName()
elseif choice == "add l n" then
InsertLName()
elseif choice == "stop" then
break
elseif choice == "clear f ns" then
FirstNames = {}
elseif choice == "clear l ns" then
LastNames = {}
elseif choice == "delete f n" then
DeleteN(FirstNames)
elseif choice == "delete l n" then
DeleteN(LastNames)
else print("Not Valid Command")
end
busy = false
end