View difference between Paste ID: k6tN22dW and 8RTJyFx0
SHOW: | | - or go back to the newest paste.
1
-- vend.lua
2
local id = 95
3
local m = peripheral.wrap("top")
4-
function button(food,price)
4+
5-
m.setBackgroundColor(colors.lime)
5+
local account, name
6-
m.write(" ")
6+
7
function button(food, price)
8-
m.write(" "..food.." x64 "..price.." Diamonds")
8+
	m.setBackgroundColor(colors.lime)
9-
local x,y = m.getCursorPos()
9+
	m.write("  ")
10-
m.setCursorPos(2,y+2)
10+
	m.setBackgroundColor(colors.black)
11
	m.write(food .. " x64 " .. price .. " Diamonds")
12
	local x, y = m.getCursorPos()
13
	m.setCursorPos(2,y+2)
14
end
15
16
m.setBackgroundColor(colors.black)
17
m.clear()
18
m.setCursorPos(2,3)
19
button("Cooked Beef","10")
20
button("Pork","7")
21
m.setCursorPos(2,1)
22-
 for i = 1,100 do
22+
23-
 m.setCursorPos(i+17,1)
23+
24-
 m.write(" ")
24+
25-
 end
25+
	for i = 1,100 do
26-
 if fs.exists("disk/accountInfo.lua") then
26+
		m.setCursorPos(i+17,1)
27-
 print("Found Card")
27+
		m.write(" ")
28-
 account = fs.open("disk/accountInfo.lua","r")
28+
	end
29-
 local name = account.readLine()
29+
30-
 print(name)
30+
	if fs.exists("disk/accountInfo.lua") then
31-
 local num = bank.requestStatement("greenblock",name,id)
31+
		print("Found Card")
32-
 money = tonumber(num)
32+
		account = fs.open("disk/accountInfo.lua", "r")
33-
 print(money)
33+
		name = account.readLine()
34-
 m.setCursorPos(18,1)
34+
		account.close()
35-
 m.write("$")
35+
		print(name)
36-
 m.setCursorPos(19,1)
36+
		local num = bank.requestStatement("greenblock", name, id)
37-
 m.write(money)
37+
		money = tonumber(num)
38-
 else
38+
		print(money)
39-
 m.setCursorPos(18,1)
39+
		m.setCursorPos(18, 1)
40-
 m.write("Card Not Loaded")
40+
		m.write("$")
41-
 end
41+
		m.setCursorPos(19, 1)
42
		m.write(money)
43
44
	else
45
		m.setCursorPos(18, 1)
46
		m.write("Card Not Loaded")
47
	end
48
end
49-
function giveItem(Nom,price)
49+
50-
 if money >= price then
50+
51-
 local sum = money - price
51+
	button("Cooked Beef", "10")
52-
 rednet.send(91,"beef")
52+
	button("Pork", "7")
53-
 bank.sendTransaction("greenblock",account,sum,id)
53+
54-
 end
54+
55
function giveItem(Nom, price)
56
	if money >= price then
57
		local sum = money - price
58
		rednet.send(91,"beef")
59-
local event, button, bx, by = os.pullEvent()
59+
		bank.sendTransaction("greenblock", name, sum, id)
60-
getCash()
60+
	end
61
end
62-
if bx == 2 and by == 3 then
62+
63-
giveItem("beef",10)
63+
64-
elseif bx == 2 and by == 5 then
64+
65-
giveitem("pork",7)
65+
66
	local event, button, bx, by = os.pullEvent()
67
	getCash()
68
69
	if bx == 2 and by == 3 then
70
		giveItem("beef", 10)
71
72
	elseif bx == 2 and by == 5 then
73
		giveitem("pork", 7)
74
	end
75
end