View difference between Paste ID: Mk7JJqTK and 2nUUtTsB
SHOW: | | - or go back to the newest paste.
1
local screen = peripheral.find("monitor")
2
screen.setCursorPos(1,1)
3
screen.clear()
4
local dfpwm = require("cc.audio.dfpwm")
5
local old_term = term.redirect(screen)
6
local image = paintutils.loadImage("coffee.nfp")
7
paintutils.drawImage(image, screen.getCursorPos())
8
term.redirect(old_term)
9
screen.setBackgroundColor(colors.brown)
10
screen.setTextScale(0.5)
11
screen.setCursorPos(1,1)
12
screen.setTextColor(colors.yellow)
13
screen.write("Coffee Machine")
14
screen.setCursorPos(2,2)
15
screen.setTextColor(colors.yellow)
16
screen.write("By Playerbrand1")
17
local on = true
18
local speaker = peripheral.find("speaker")
19
local barrel1 = peripheral.wrap("minecraft:barrel_66")
20
local barrel2 = peripheral.wrap("minecraft:barrel_68")
21
local barrel3 = peripheral.wrap("minecraft:barrel_67")
22
local coffee = false
23
while true do
24
    for slot, item in pairs(barrel2.list()) do
25
        coffee = false
26
        if item.name == "herbalbrews:coffee" then
27
            coffee = true
28
        end
29
    end
30
    if coffee == true then
31
        screen.setCursorPos(2,5)
32
        screen.setTextScale(0.8)
33
        screen.write("Insert 1 Diamond for 16 coffee cups")
34
        for slot, item in pairs(barrel1.list()) do
35
            if item.name == "minecraft:diamond" and coffee == true then
36
                print("bought 1 coffee")
37
                barrel1.pushItems(peripheral.getName(barrel3),slot,1)
38
                for slot, item in pairs(barrel2.list()) do
39
		local counter = 0
40
                    if item.name == "herbalbrews:coffee" then
41
			counter = 1
42
                        barrel2.pushItems(peripheral.getName(barrel1),slot,16)
43
                        screen.clearLine()
44
                        screen.setTextColor(colors.blue)
45
                        screen.setCursorPos(5,5)
46
                        screen.write("Thanks for purchasing")
47
                        screen.setCursorPos(7,5)
48
                        screen.setTextColor(colors.yellow)
49
                        local decoder = dfpwm.make_decoder()
50
                        for input in io.lines("voice.dfpwm", 16 * 1024) do
51
                          local decoded = decoder(input)
52
                          while not speaker.playAudio(decoded) do
53
                              os.pullEvent("speaker_audio_empty")
54
                          end
55
                        end
56
                        local DiscordHook = require("DiscordHook") local success, hook = DiscordHook.createWebhook("https://discord.com/api/webhooks/1204484867291746315/rLh0P-qabemINnDfkQE_qbjeDgOnDhXKJ_VXdpd4-kyT6fFpSUf04YKZWOkWErpQGEMf") if not success then error("Webhook connection failed! Reason: " .. hook) end hook.send("**Someone** has bought ***16x*** coffee for ***1*** diamond","Coffee Machien: Lane")
57
                        sleep(3)
58
                        os.reboot()
59
		    else
60
			if counter == 0 then coffee = false end
61
                    end
62
                end
63
            end
64
        end
65
        sleep(1)
66
        screen.clearLine()
67
        if on == true then
68
            on = false
69
            screen.setTextColor(colors.white)
70
        else
71
            screen.setTextColor(colors.yellow)
72
            on = true
73
        end
74
    elseif coffee == false then
75
  	screen.setCursorPos(1,5)
76
  	screen.clearLine()
77
  	screen.setTextColor(colors.red)
78
  	screen.write("We're out of coffee! We're so sorry!")
79
    end
80
end
81
82
83