View difference between Paste ID: FbcG9G6b and GBbNYUnp
SHOW: | | - or go back to the newest paste.
1
local collectorFee = 10     -- How many credits you want as fee when people collect their diamonds/gold
2-
------------------------------------------------------------------
2+
3-
-- run this program on a turtle with on the right a disk drive and the back of the turtle a chest
3+
4-
-- This program is made for my slotmachiene and futere games.
4+
local credsPerDia = 25
5-
-- to use this install this under the name startup
5+
local credsPerGld = 25     -- Make sure this variable is defined
6-
------------------------------------------------------------------
6+
7-
--        manual
7+
local playerName = nil  -- Declare playerName
8-
--
8+
9-
-- place a turtle with on the left a disk drive en behind a chest 
9+
10-
-- (you can place any block above the chest to stop people from opening it)
10+
11-
-- you can also change te fee for when people withdraw there diamonds
11+
12-
-- here you can also change flopp's to Mcards
12+
13-
-------------------------------------------------------------------
13+
14
    data = (tostring(math.random(1, 163456)).."11066011"..tostring(creds).."11077011"..tostring(math.random(1, 163456)))
15-
local collectorFee = 10     --how many credits you want as fee when people collect there dia
15+
16
    Card.close()
17
    disk.setLabel("right", (playerName or "Unknown") .. "'s Casino Card - " .. tostring(creds) .. " Credits")  -- Use "Unknown" if playerName is nil
18-
---------------------------------------
18+
19
20
function Pkey()
21
    local event, key = os.pullEvent("key")
22-
local credsPerDia = 20
22+
23
        conf = true
24-
----------------------------------
24+
25
end
26
27
function wait()
28
    sleep(1)
29
end
30
31
function turn()
32
    turtle.turnLeft()
33
    turtle.turnLeft()
34-
    disk.setLabel("right", tostring(creds).."$")
34+
35
36
function readCard()
37
    if not fs.exists("disk/") then
38
        os.reboot()
39
    end
40
    if not fs.exists("disk/creds.lua") then
41
        term.setCursorPos(10, 7)
42
        print("This isn't a Casino Card")
43
        term.setCursorPos(8, 8)
44
        print("Do you want to make it a Casino Card?")
45
        term.setCursorPos(12, 10)
46
        write(" Yes     |No|")
47
        confi = false
48
        while confi == false do
49
            term.setCursorPos(12, 10)
50
            local event, key, isHeld = os.pullEvent("key")
51
            if key == keys.left then
52
                write("|Yes|     No ")
53
                confirm = true
54
            elseif key == keys.right then
55
                write(" Yes     |No|")
56
                confirm = false
57
            elseif key == keys.enter then
58-
        print("This isn't a Mcard")
58+
59
            end
60-
        print("Do you wan't to make it a Mcard?")
60+
61
        
62-
        write(" Yes     >No<")
62+
63
        if confirm == true then
64
            term.setCursorPos(10, 6)
65
            write("Enter your name: ")
66
            term.setCursorPos(10, 7)
67
            playerName = read()  -- Prompt for player name
68-
                write(">Yes<     No ")
68+
69
            Card.write("0987498011066011011077011")
70
            Card.close()
71-
                write(" Yes     >No<")
71+
            disk.setLabel("right", (playerName or "Unknown") .. "'s Casino Card - 0 Credits")
72
        else
73
            term.setCursorPos(8, 8)
74
            while fs.exists("disk/") do
75
                term.setCursorPos(8, 8)
76
                write("Please remove your Card.")
77
                sleep(0.5)
78
            end
79
        end
80
    end
81
    local Card = fs.open("disk/creds.lua", "r")
82
    data = Card.readAll()
83-
            disk.setLabel("right", "0$")
83+
84
    a, b = string.find(data, "11066011")
85
    c, d = string.find(data, "11077011")
86
    creds = tonumber(string.sub(data, b + 1, c - 1))
87
end
88-
                write("please remove your disk")
88+
89-
                sleep(0,5)
89+
90
    paintutils.drawFilledBox(1, 1, 39, 13, colors.green)
91
    while not fs.exists("disk/") do
92
        term.clear()
93
        paintutils.drawFilledBox(1, 1, 39, 13, colors.green)
94
        term.setCursorPos(10, 6)
95
        term.write("[Please Insert Casino Card]")
96
        sleep(1)
97
    end
98-
    creds = tonumber(string.sub(data, b+1, c-1))
98+
99
end
100
101
function count_dia()
102
    current_count = 0
103
    for i = 1, 16 do
104
        if turtle.getItemCount(i) > 0 then
105
            local slot = turtle.getItemDetail(i)
106
            if slot.name == "minecraft:diamond" or slot.name == "minecraft:gold_ingot" then
107-
        term.write("{please insert card}")
107+
108
            end
109
        end
110
    end
111
    final_count = current_count
112
    for i = 1, 16 do
113
        if turtle.getItemCount(i) > 0 then
114-
    for i=1,16 do
114+
115
            if slot.name ~= "minecraft:diamond" and slot.name ~= "minecraft:gold_ingot" then
116
                turtle.select(i)
117-
            if slot.name == "minecraft:diamond" then
117+
118
            end
119
        end
120
    end
121
    creds_rtrn = final_count * credsPerDia
122
end
123-
    for i=1,16 do
123+
124
function count_gld()
125
    current_count = 0
126-
            if slot.name ~= "minecraft:diamond" then
126+
    for i = 1, 16 do
127
        if turtle.getItemCount(i) > 0 then
128
            local slot = turtle.getItemDetail(i)
129
            if slot.name == "minecraft:gold_ingot" then
130
                current_count = current_count + slot.count
131
            end
132
        end
133
    end
134
    final_count = current_count
135
    for i = 1, 16 do
136
        if turtle.getItemCount(i) > 0 then
137
            local slot = turtle.getItemDetail(i)
138
            if slot.name ~= "minecraft:gold_ingot" then
139-
    write(" withdraw     >deposit<")
139+
140
                turtle.drop()
141
            end
142-
        term.write("you currently have: "..creds.."$")
142+
143
    end
144
    creds_rtrn = final_count * credsPerGld
145
end
146
147
function wdORdp()
148
    local action = "deposit"
149-
            write(">withdraw<     deposit ")
149+
150
    term.setCursorPos(8, 10)
151
    term.clear()
152-
            write(" withdraw     >deposit<")
152+
    write(" Withdraw     |Deposit|")
153
    while enter == false do
154
        term.setCursorPos(9, 8)
155
        term.write("You currently have: " .. creds .. " Credits")
156
        term.setCursorPos(8, 10)
157-
            return action;
157+
158
        if not fs.exists("disk/creds.lua") then
159
            os.reboot()
160
        end
161
        if key == keys.left then
162
            write("|Withdraw|     Deposit ")
163
            action = "withdraw"
164
        elseif key == keys.right then
165
            write(" Withdraw     |Deposit|")
166
            action = "deposit"
167
        end
168
        if key == keys.enter then
169
            enter = true
170
            return action
171
        end
172
    end
173
end
174-
            term.write("do you want to deposit")
174+
175
function transaction()
176-
            term.write("|"..final_count.."| dia")
176+
177
178
    if action == "deposit" then
179-
            term.setCursorPos(10,10)
179+
180-
            term.write("|"..creds_rtrn.."| creds?")
180+
181
            if not fs.exists("disk/creds.lua") then
182
                os.reboot()
183
            end
184-
		current_count = 0
184+
185-
        for i=1,16 do
185+
186-
            
186+
187-
			if turtle.getItemCount(i) > 0 then
187+
            term.write("Do you want to deposit?")
188-
				turtle.select(i)
188+
189-
            	local slot = turtle.getItemDetail(i)
189+
            term.write("|" .. final_count .. "| Diamonds/Gold")  -- Changed here
190-
				if slot.name == "minecraft:diamond" then
190+
191-
            		current_count = current_count + slot.count
191+
192-
            	end
192+
            term.setCursorPos(10, 10)
193-
			end
193+
            term.write("|" .. creds_rtrn .. "| Credits")
194-
			turtle.drop()
194+
195
        end
196
        turn()
197
        current_count = 0
198-
		final_count = current_count
198+
        for i = 1, 16 do
199-
		creds_rtrn = final_count * credsPerDia
199+
            if turtle.getItemCount(i) > 0 then
200
                turtle.select(i)
201-
		
201+
                local slot = turtle.getItemDetail(i)
202-
	
202+
                if slot.name == "minecraft:diamond" or slot.name == "minecraft:gold_ingot" then
203
                    current_count = current_count + slot.count
204
                end
205
            end
206
            turtle.drop()
207
        end
208
        turn()
209
        final_count = current_count
210
        creds_rtrn = final_count * credsPerDia
211
        creds = creds + creds_rtrn
212-
        term.write("do you want to withdraw")
212+
213
    end
214-
        term.write("|"..diawit.."| dia")
214+
    
215
    if action == "withdraw" then
216
        paintutils.drawFilledBox(1, 1, 51, 19, colors.green)
217-
        term.setCursorPos(10,10)
217+
218-
        term.write("|"..creds_rtrn.."| creds")
218+
219
        term.clear()
220
        term.setCursorPos(10, 4)
221
        term.write("Do you want to withdraw?")
222
        term.setCursorPos(10, 6)
223
        term.write("|" .. diawit .. "| Diamonds/Gold")  -- Changed here
224
        term.setCursorPos(10, 8)
225
        term.write("for")
226-
                    diawit = diawit -1
226+
        term.setCursorPos(10, 10)
227
        term.write("|" .. creds_rtrn .. "| Credits")
228
        conf = false
229
        while conf == false do
230-
                term.write("do you want to withdraw")
230+
231
            local event, key = os.pullEvent("key")
232-
                term.write("|"..diawit.."| dia")
232+
233
                diawit = diawit + 1
234
                if ((diawit * credsPerDia) + collectorFee) > creds then
235-
                term.setCursorPos(10,10)
235+
                    diawit = diawit - 1
236-
                term.write("|"..diawit * credsPerDia.."| creds")
236+
237-
            elseif key == keys.down and creds_rtrn > 0 then
237+
238-
                diawit = diawit - 1
238+
239-
                
239+
                term.write("Do you want to withdraw?")
240
                term.setCursorPos(10, 6)
241
                term.write("|" .. diawit .. "| Diamonds/Gold")  -- Changed here
242-
                term.write("do you want to withdraw")
242+
243
                term.write("for")
244-
                term.write("|"..diawit.."| dia")
244+
                term.setCursorPos(10, 10)
245
                term.write("|" .. (diawit * credsPerDia) .. "| Credits")
246
            elseif key == keys.enter then
247-
                term.setCursorPos(10,10)
247+
248-
                term.write("|"..diawit * credsPerDia.."| creds")
248+
249
        end
250
        if creds >= ((diawit * credsPerDia) + collectorFee) then
251
            creds = creds - (diawit * credsPerDia) - collectorFee
252-
            
252+
            for i = 1, diawit do
253-
            
253+
                turtle.select(1)  -- Assuming diamond/gold is in the first slot
254
                turtle.drop()
255
            end
256
            writeCard()
257-
        local beforecreds = creds
257+
258-
        creds = creds - creds_rtrn - collectorFee
258+
259
end
260
261-
        term.write("See you soon!")
261+
while true do
262
    insert_card()
263
    readCard()
264-
        turtle.select(1)
264+
265-
        stacks = diawit / 64
265+
266-
        while stacks >= 1 do
266+
        print("This isn't a Casino Card")
267-
            turtle.suck(64)
267+
268-
            stacks = stacks-1
268+
        goto continue
269
    end
270-
        local succes = turtle.suck(stacks*64)
270+
    action = wdORdp()
271-
        if succes == false then
271+
    transaction()
272-
            for i=1,16 do
272+
    ::continue::
273
end
274