Skip to content

Commit b8f4e60

Browse files
committed
added menu bar
1 parent 2d0059b commit b8f4e60

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

NameSelector.lua

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ local LastNames = {
3131
"Jackson"
3232
}
3333

34+
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"}
35+
3436
local busy = false
3537

3638
local function PrintFirstName(value)
@@ -45,7 +47,7 @@ end
4547
local function PrintLastName(value)
4648
for count = 1, value do
4749
if #LastNames ~= 0 then
48-
print(LastNames[math.random(1,#LastNames)])
50+
print(LastNames[math.random(1,#LastNames)])
4951
else print(" ")
5052
end
5153
end
@@ -88,10 +90,17 @@ function is_numeric(x)
8890
return false
8991
end
9092

91-
local function DeleteN(tab)
92-
for i,v in ipairs(tab) do
93+
local function printContent(tab)
94+
for i,v in ipairs(tab) do
9395
print(i,v)
96+
print()
9497
end
98+
end
99+
100+
local function DeleteN(tab)
101+
for i,v in ipairs(tab) do
102+
print(i,v)
103+
end
95104
io.write("Which name would you like to delete? Enter Number")
96105
local choice = io.read()
97106
print()
@@ -100,18 +109,20 @@ local function DeleteN(tab)
100109
else print("not valid number")
101110
end
102111
end
103-
112+
104113
while not busy do
105114
busy = true
106115
print()
107116
io.write("What do you want to do?")
108-
print()
117+
print()
118+
printContent(menu)
109119
local choice = io.read()
110120
print()
111121
if choice == "print ns" then
112122
io.write("Enter Number")
113123
print()
114-
value = io.read()
124+
value = io.read()
125+
print()
115126
PrintNames(value)
116127
elseif choice == "add custom n" then
117128
CustomName()
@@ -121,7 +132,7 @@ print()
121132
InsertLName()
122133
elseif choice == "stop" then
123134
break
124-
elseif choice == "clear f n" then
135+
elseif choice == "clear f ns" then
125136
FirstNames = {}
126137
elseif choice == "clear l ns" then
127138
LastNames = {}
@@ -132,4 +143,4 @@ print()
132143
else print("Not Valid Command")
133144
end
134145
busy = false
135-
end
146+
end

0 commit comments

Comments
 (0)