-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathff.lua
77 lines (65 loc) · 1.48 KB
/
ff.lua
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
--Create a global variable, your program should only contain one. We will tuck all other variables into this one.
ff = {}
ff.vend = function()
end
ff.fight = function()
end
ff.formatPrint = function(text,opt1,opt2,pad)
-- opt1 is for boarder
-- pad is Padding
local len = string.len(text)
local width = len + pad*2 -2
--Top of box
for i = 1, opt2, 1 do
io.write(" ")
end
io.write("+")
for i = 1, width, 1 do
io.write(opt1)
end
io.write("+\n")
--Middle
for i = 1, opt2, 1 do
io.write(" ")
end
io.write("|")
for i = 1, pad - 1, 1 do
io.write(" ")
end
io.write(text)
for i = 1, pad - 1, 1 do
io.write(" ")
end
io.write("|\n")
--Bottom
for i = 1, opt2, 1 do
io.write(" ")
end
io.write("+")
for i = 1, width, 1 do
io.write(opt1)
end
io.write("+\n")
--print(len)
end
ff.tablePrint = function (tbl)
print("testing")
for key, value in ipairs(tbl) do
if type(value) ~= "table" then
io.write("\n",key,": ",value)
else
ff.tablePrint(value)
end
end
end
-- Intialize a few variables
io.write("\n\n")
ff.formatPrint("Welcome!","=",10,10)
io.write("\n\nPlease enter the name of the player: ")
ff.player = {name = io.read(), money = 10, box = {"Apple","Milk","Sandwich"}}
ff.tablePrint(ff.player)
--Main Loop
while true do
print("Press enter to continue")
io.read()
end