SHOW:
|
|
- or go back to the newest paste.
1 | local manager = peripheral.find("inventoryManager") -- Finds the peripheral if one is connected | |
2 | ||
3 | if manager == nil then error("inventoryManager not found") end | |
4 | ||
5 | -- Functions Start | |
6 | ||
7 | term.clear() | |
8 | ||
9 | local check = fs.open(manager.getOwner(),"r") | |
10 | print("balance:" ..check.readAll()) | |
11 | check.close() | |
12 | ||
13 | function withd() | |
14 | local withdraw = fs.open(manager.getOwner(),"r") | |
15 | local data = tonumber(withdraw.readAll()) | |
16 | withdraw.close() | |
17 | ||
18 | local withdraw2 = fs.open(manager.getOwner(),"w") | |
19 | withdraw2.write(data - withdrawamount) | |
20 | withdraw2.close() | |
21 | end | |
22 | function depo() | |
23 | local deposit = fs.open(manager.getOwner(),"r") | |
24 | local data = tonumber(deposit.readAll()) | |
25 | deposit.close() | |
26 | ||
27 | local deposit2 = fs.open(manager.getOwner(),"w") | |
28 | deposit2.write(data + depositamount) | |
29 | deposit2.close() | |
30 | end | |
31 | function mainmenu() | |
32 | print ("1. withdraw") | |
33 | print ("2. deposit") | |
34 | print ("3. send") | |
35 | end | |
36 | ||
37 | ||
38 | ||
39 | mainmenu() | |
40 | ||
41 | -- main loop | |
42 | while true do | |
43 | ||
44 | local event, key = os.pullEvent("key") | |
45 | ||
46 | if key == keys.one then | |
47 | term.clear() | |
48 | term.setCursorPos(1,1) | |
49 | print("1. Copper Block") | |
50 | print("2. Zinc Block") | |
51 | print("3. Brass Block") | |
52 | print("4. Diamond Block") | |
53 | print("5. Netherite Block") | |
54 | local event2, key2 = os.pullEvent("key") | |
55 | if key2 == keys.one then | |
56 | term.clear() | |
57 | term.setCursorPos(1,1) | |
58 | print("How many?") | |
59 | local amount = read() | |
60 | local copper = tonumber(amount) | |
61 | - | if key3 == keys.one then manager.addItemToPlayer("DOWN", copper, -1, "create:copper_block") end |
61 | + | |
62 | - | if key3 == keys.two then manager.addtemFromPlayer("DOWN", copper, -1, "thermal:copper_block") end |
62 | + | |
63 | - | if key3 == keys.three then manager.addItemToPlayer("DOWN", copper, -1, "mysticalworld:copper_block") end |
63 | + | |
64 | print ("2. Thermal") | |
65 | print ("3. Mystical") | |
66 | ||
67 | if key3 == keys.one then taken = manager.addItemToPlayer("DOWN", copper, -1, "create:copper_block") | |
68 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
69 | end | |
70 | if key3 == keys.two then taken = manager.addItemToPlayer("DOWN", copper, -1, "thermal:copper_block") | |
71 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
72 | - | manager.addItemToPlayer("DOWN", zinc, -1, "create:zinc_block") |
72 | + | end |
73 | if key3 == keys.three then taken = manager.addItemToPlayer("DOWN", copper, -1, "mysticalworld:copper_block") | |
74 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
75 | end | |
76 | ||
77 | withdrawamount = copper * .5 | |
78 | withd() | |
79 | elseif key2 == keys.two then | |
80 | term.clear() | |
81 | - | manager.addItemToPlayer("DOWN", brass, -1, "create:brass_block") |
81 | + | |
82 | print("How many?") | |
83 | local amount = read() | |
84 | local zinc = tonumber(amount) | |
85 | taken = manager.addItemToPlayer("DOWN", zinc, -1, "create:zinc_block") | |
86 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
87 | depositamount = zinc * 1 | |
88 | withdraw() | |
89 | elseif key2 == keys.three then | |
90 | - | manager.addItemToPlayer("DOWN", diamond, -1, "minecraft:diamond_block") |
90 | + | |
91 | term.setCursorPos(1,1) | |
92 | print("How many?") | |
93 | local amount = read() | |
94 | local brass = tonumber(amount) | |
95 | taken = manager.addItemToPlayer("DOWN", brass, -1, "create:brass_block") | |
96 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
97 | withdrawamount = brass * 2 | |
98 | withd() | |
99 | - | manager.addItemToPlayer("DOWN", netherite, -1, "minecraft:diamond_block") |
99 | + | |
100 | term.clear() | |
101 | term.setCursorPos(1,1) | |
102 | print("How many?") | |
103 | local amount = read() | |
104 | local diamond = tonumber(amount) | |
105 | taken = manager.addItemToPlayer("DOWN", diamond, -1, "minecraft:diamond_block") | |
106 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
107 | withdrawamount = diamond * 3 | |
108 | withd() | |
109 | elseif key2 == keys.five then | |
110 | term.clear() | |
111 | term.setCursorPos(1,1) | |
112 | print("How many?") | |
113 | local amount = read() | |
114 | local netherite = tonumber(amount) | |
115 | taken = manager.addItemToPlayer("DOWN", netherite, -1, "minecraft:diamond_block") | |
116 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
117 | withdrawamount = netherite * 5 | |
118 | withd() | |
119 | end | |
120 | end | |
121 | ||
122 | if key == keys.two then | |
123 | term.clear() | |
124 | term.setCursorPos(1,1) | |
125 | - | if key3 == keys.one then manager.removeItemFromPlayer("DOWN", copper, -1, "create:copper_block") end |
125 | + | |
126 | - | if key3 == keys.two then manager.removeItemFromPlayer("DOWN", copper, -1, "thermal:copper_block") end |
126 | + | |
127 | - | if key3 == keys.three then manager.removeItemFromPlayer("DOWN", copper, -1, "mysticalworld:copper_block") end |
127 | + | |
128 | print("4. Diamond Block") | |
129 | print("5. Netherite Block") | |
130 | local event2, key2 = os.pullEvent("key") | |
131 | ||
132 | if key2 == keys.one then | |
133 | term.clear() | |
134 | term.setCursorPos(1,1) | |
135 | print("How many?") | |
136 | - | manager.removeItemFromPlayer("DOWN", zinc, -1, "create:zinc_block") |
136 | + | |
137 | local copper = tonumber(amount) | |
138 | print ("What kind?") | |
139 | print ("1. Create") | |
140 | print ("2. Thermal") | |
141 | print ("3. Mystical") | |
142 | local event3, key3 = os.pullEvent("key") | |
143 | ||
144 | if key3 == keys.one then taken = manager.removeItemFromPlayer("DOWN", copper, -1, "create:copper_block") | |
145 | - | manager.removeItemFromPlayer("DOWN",brass, -1, "create:brass_block") |
145 | + | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end |
146 | end | |
147 | if key3 == keys.two then taken = manager.removeItemFromPlayer("DOWN", copper, -1, "thermal:copper_block") | |
148 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
149 | end | |
150 | if key3 == keys.three then taken = manager.removeItemFromPlayer("DOWN", copper, -1, "mysticalworld:copper_block") | |
151 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
152 | end | |
153 | ||
154 | - | manager.removeItemFromPlayer("DOWN", diamond, -1, "minecraft:diamond_block") |
154 | + | |
155 | depo() | |
156 | elseif key2 == keys.two then | |
157 | term.clear() | |
158 | term.setCursorPos(1,1) | |
159 | print("How many?") | |
160 | local amount = read() | |
161 | local zinc = tonumber(amount) | |
162 | taken = manager.removeItemFromPlayer("DOWN", zinc, -1, "create:zinc_block") | |
163 | - | manager.removeItemFromPlayer("DOWN", netherite, -1, "minecraft:diamond_block") |
163 | + | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end |
164 | depositamount = zinc * 1 | |
165 | depo() | |
166 | - | end |
166 | + | |
167 | - | |
167 | + | |
168 | - | end |
168 | + | |
169 | print("How many?") | |
170 | - | |
170 | + | |
171 | local brass = tonumber(amount) | |
172 | taken = manager.removeItemFromPlayer("DOWN",brass, -1, "create:brass_block") | |
173 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
174 | depositamount = brass * 2 | |
175 | depo() | |
176 | elseif key2 == keys.four then | |
177 | term.clear() | |
178 | term.setCursorPos(1,1) | |
179 | print("How many?") | |
180 | local amount = read() | |
181 | local diamond = tonumber(amount) | |
182 | taken = manager.removeItemFromPlayer("DOWN", diamond, -1, "minecraft:diamond_block") | |
183 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
184 | depositamount = diamond * 3 | |
185 | depo() | |
186 | elseif key2 == keys.five then | |
187 | term.clear() | |
188 | term.setCursorPos(1,1) | |
189 | print("How many?") | |
190 | local amount = read() | |
191 | local netherite = tonumber(amount) | |
192 | taken = manager.removeItemFromPlayer("DOWN", netherite, -1, "minecraft:diamond_block") | |
193 | if taken == 0 then print ("Invalid Request") sleep(3) os.shutdown() end | |
194 | depositamount = netherite * 5 | |
195 | depo() | |
196 | end | |
197 | end | |
198 | ||
199 | if key == keys.three then | |
200 | ||
201 | term.clear() | |
202 | term.setCursorPos(1,1) | |
203 | print("Enter Username:") | |
204 | user = read() | |
205 | print("Enter Amount:") | |
206 | ||
207 | local sendamount = tonumber(read()) | |
208 | ||
209 | local send = fs.open(manager.getOwner(),"r") | |
210 | local senddata = tonumber(send.readAll()) | |
211 | ||
212 | ||
213 | local send2 = fs.open(manager.getOwner(),"w") | |
214 | send2.write(senddata - sendamount) | |
215 | ||
216 | ||
217 | local send3 = fs.open(user,"r") | |
218 | local senddata2 = tonumber(send3.readAll()) | |
219 | ||
220 | ||
221 | local send4 = fs.open(user,"w") | |
222 | send4.write(senddata2 + sendamount) | |
223 | ||
224 | send.close() | |
225 | send2.close() | |
226 | send3.close() | |
227 | send4.close() | |
228 | ||
229 | ||
230 | ||
231 | ||
232 | end | |
233 | end |