SHOW:
|
|
- or go back to the newest paste.
| 1 | usernamesetup = "tomtrein" | |
| 2 | ||
| 3 | turtleid = 116 | |
| 4 | settings = {}
| |
| 5 | ||
| 6 | num = 0 | |
| 7 | ||
| 8 | showcard = function() | |
| 9 | shell.run("delete", "disk/money")
| |
| 10 | term.setCursorPos(1, 18) | |
| 11 | term.clearLine() | |
| 12 | term.write('press enter to view current balance')
| |
| 13 | term.setCursorPos(1, 19) | |
| 14 | term.clearLine() | |
| 15 | term.write('After vieving press ctrl and enter to continue')
| |
| 16 | read() | |
| 17 | shell.run("cp", "helpcard", "disk/money")
| |
| 18 | shell.run("textedit", "disk/money")
| |
| 19 | term.clear() | |
| 20 | term.setCursorPos(1, 19) | |
| 21 | term.write('choose a pin code, 4 digits only')
| |
| 22 | - | if not settings[4]==nill then |
| 22 | + | |
| 23 | - | order = settings[4]=="true" |
| 23 | + | |
| 24 | ponies=false | |
| 25 | - | order = false |
| 25 | + | |
| 26 | local event, key = os.pullEvent("key")
| |
| 27 | if key>1 and key<11 then | |
| 28 | amount = key-1 | |
| 29 | ponies = true | |
| 30 | end | |
| 31 | end | |
| 32 | code = code..amount | |
| 33 | term.setCursorPos(16, 10) | |
| 34 | term.setBackgroundColor(colors.lightBlue) | |
| 35 | term.write(code) | |
| 36 | end | |
| 37 | stringcode = math.random(9)..math.random(9)..math.random(9)..math.random(9).."200"..math.random(9)..math.random(9)..math.random(9)..math.random(9) | |
| 38 | file = fs.open("disk/temp", "w")
| |
| 39 | file.writeLine(stringcode) | |
| 40 | - | while not disk.hasData(settings[1]) do |
| 40 | + | |
| 41 | - | os.queueEvent("randomEvent")
|
| 41 | + | |
| 42 | - | os.pullEvent() |
| 42 | + | |
| 43 | ||
| 44 | shell.run("delete", "disk/money")
| |
| 45 | ||
| 46 | shell.run("cp", "disk/temp", "disk/money")
| |
| 47 | ||
| 48 | shell.run("delete", "disk/temp")
| |
| 49 | ||
| 50 | term.clear() | |
| 51 | term.setCursorPos(1, 18) | |
| 52 | term.write('the encrypted code is:')
| |
| 53 | ||
| 54 | file = fs.open("disk/money", "r")
| |
| 55 | stringcode = print(file.readLine()) | |
| 56 | file.close() | |
| 57 | ||
| 58 | term.clearLine() | |
| 59 | term.setCursorPos(1, 19) | |
| 60 | term.write('press enter to continue')
| |
| 61 | read() | |
| 62 | end | |
| 63 | ||
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | ||
| 68 | ||
| 69 | ||
| 70 | ||
| 71 | ||
| 72 | ||
| 73 | ||
| 74 | ||
| 75 | ||
| 76 | ||
| 77 | ||
| 78 | ||
| 79 | ||
| 80 | ||
| 81 | ||
| 82 | ||
| 83 | ||
| 84 | ||
| 85 | ||
| 86 | ||
| 87 | ||
| 88 | file = fs.open("settings", "r")
| |
| 89 | istrue = true | |
| 90 | i = 0 | |
| 91 | while istrue do | |
| 92 | i = i+1 | |
| 93 | string1 = file.readLine() | |
| 94 | if string1==nill then | |
| 95 | istrue = false | |
| 96 | break | |
| 97 | end | |
| 98 | string2 = file.readLine() | |
| 99 | settings[i] = string2 | |
| 100 | end | |
| 101 | ||
| 102 | file.close() | |
| 103 | ||
| 104 | turtleid = tonumber(settings[3]) | |
| 105 | ||
| 106 | banking = function() | |
| 107 | term.setTextColor(colors.black) | |
| 108 | term.setBackgroundColor(colors.white) | |
| 109 | term.clear() | |
| 110 | local image = paintutils.loadImage("bank")
| |
| 111 | paintutils.drawImage(image, 1, 1) | |
| 112 | term.setCursorPos(16, 8) | |
| 113 | term.write("Please input card")
| |
| 114 | term.setCursorPos(1, 18) | |
| 115 | term.clearLine() | |
| 116 | term.write('click please input card')
| |
| 117 | term.setCursorPos(1, 19) | |
| 118 | term.clearLine() | |
| 119 | term.write('to input virtual card')
| |
| 120 | ||
| 121 | ponies = true | |
| 122 | while ponies do | |
| 123 | local event, button, x, y = os.pullEvent( "mouse_click" ) | |
| 124 | if y==8 then | |
| 125 | showcard() | |
| 126 | ponies = false | |
| 127 | end | |
| 128 | end | |
| 129 | ||
| 130 | ||
| 131 | term.setTextColor(colors.black) | |
| 132 | term.setBackgroundColor(colors.white) | |
| 133 | term.clear() | |
| 134 | local image = paintutils.loadImage("bank")
| |
| 135 | paintutils.drawImage(image, 1, 1) | |
| 136 | term.setCursorPos(16, 8) | |
| 137 | term.write("Please enter code")
| |
| 138 | code = "" | |
| 139 | for i=1, 4 do | |
| 140 | ponies=false | |
| 141 | while not ponies do | |
| 142 | local event, key = os.pullEvent("key")
| |
| 143 | if key>1 and key<11 then | |
| 144 | amount = key-1 | |
| 145 | ponies = true | |
| 146 | end | |
| 147 | end | |
| 148 | code = code..amount | |
| 149 | paintutils.drawImage(image, 1, 1) | |
| 150 | term.setCursorPos(16, 10) | |
| 151 | term.setBackgroundColor(colors.lightBlue) | |
| 152 | term.write(code) | |
| 153 | end | |
| 154 | ||
| 155 | shell.run("delete", "disk/temp")
| |
| 156 | shell.run("cp", "disk/money", "disk/temp")
| |
| 157 | ||
| 158 | file = fs.open("disk/temp", "r")
| |
| 159 | stringcode = file.readLine() | |
| 160 | file.close() | |
| 161 | shell.run("delete", "disk/temp")
| |
| 162 | ||
| 163 | stringcode = string.sub(stringcode, 5, -5) | |
| 164 | ||
| 165 | file = fs.open("disk/temp", "w")
| |
| 166 | file.writeLine(stringcode) | |
| 167 | file.close() | |
| 168 | ||
| 169 | shell.run("decrypt", "disk/temp", code)
| |
| 170 | ||
| 171 | file = fs.open("disk/temp", "r")
| |
| 172 | stringcode = tonumber(file.readLine()) | |
| 173 | file.close() | |
| 174 | ||
| 175 | ||
| 176 | shell.run("delete", "disk/temp")
| |
| 177 | ||
| 178 | if stringcode == nill then | |
| 179 | return "n" | |
| 180 | else | |
| 181 | ||
| 182 | stringcode = stringcode - price | |
| 183 | ||
| 184 | if stringcode < 0 then | |
| 185 | return "n" | |
| 186 | else | |
| 187 | ||
| 188 | stringcode = math.random(9)..math.random(9)..math.random(9)..math.random(9)..stringcode..math.random(9)..math.random(9)..math.random(9)..math.random(9) | |
| 189 | ||
| 190 | file = fs.open("disk/temp", "w")
| |
| 191 | - | thitemchosen = toprint |
| 191 | + | |
| 192 | file.close() | |
| 193 | ||
| 194 | shell.run("crypt", "disk/temp", code, "f")
| |
| 195 | ||
| 196 | shell.run("delete", "disk/money")
| |
| 197 | ||
| 198 | shell.run("cp", "disk/temp", "disk/money")
| |
| 199 | ||
| 200 | shell.run("delete", "disk/temp")
| |
| 201 | ||
| 202 | return "y" | |
| 203 | end | |
| 204 | end | |
| 205 | end | |
| 206 | ||
| 207 | ||
| 208 | ||
| 209 | ||
| 210 | ||
| 211 | ||
| 212 | ||
| 213 | ||
| 214 | ||
| 215 | ||
| 216 | ||
| 217 | ||
| 218 | ||
| 219 | ||
| 220 | ||
| 221 | term.setTextColor(colors.black) | |
| 222 | term.setBackgroundColor(colors.white) | |
| 223 | term.clear() | |
| 224 | local image = paintutils.loadImage("recipe")
| |
| 225 | paintutils.drawImage(image, 13, 5) | |
| 226 | ||
| 227 | term.setBackgroundColor(colors.white) | |
| 228 | term.setCursorPos(14, 6) | |
| 229 | term.write("Username")
| |
| 230 | term.setCursorPos(14, 9) | |
| 231 | term.write("Purchase")
| |
| 232 | term.setCursorPos(29, 9) | |
| 233 | term.write("*")
| |
| 234 | term.setCursorPos(14, 11) | |
| 235 | term.write("Cost:")
| |
| 236 | ||
| 237 | list = fs.open("items", "r")
| |
| 238 | ||
| 239 | term.setCursorPos(1, 19) | |
| 240 | term.clearLine() | |
| 241 | term.write('click on the blue inputs in order.')
| |
| 242 | ||
| 243 | intrue = true | |
| 244 | while intrue do | |
| 245 | local event, button, x, y = os.pullEvent( "mouse_click" ) | |
| 246 | if y==7 and x>14 and x<28 then | |
| 247 | term.setCursorPos(1, 19) | |
| 248 | term.clearLine() | |
| 249 | term.write('type in your username. Press enter to finish.')
| |
| 250 | paintutils.drawLine(15,7,27,7,colors.lightBlue) | |
| 251 | term.setBackgroundColor(colors.lightBlue) | |
| 252 | term.setCursorPos(14, 7) | |
| 253 | user = read() | |
| 254 | if user == usernamesetup then | |
| 255 | shell.run("fg")
| |
| 256 | end | |
| 257 | if user == settings[2] then | |
| 258 | shell.run("menu")
| |
| 259 | end | |
| 260 | term.setCursorPos(1, 19) | |
| 261 | term.clearLine() | |
| 262 | term.write('click the item box.')
| |
| 263 | end | |
| 264 | if y==10 and x>14 and x<28 then | |
| 265 | term.setCursorPos(1, 19) | |
| 266 | term.clearLine() | |
| 267 | term.write('Use the up arrow to select item, enter to select')
| |
| 268 | term.setBackgroundColor(colors.lightBlue) | |
| 269 | term.setCursorPos(15,10) | |
| 270 | term.write("go up")
| |
| 271 | ponies=false | |
| 272 | while not ponies do | |
| 273 | local event, key = os.pullEvent("key")
| |
| 274 | if key == keys.enter then | |
| 275 | ponies = true | |
| 276 | end | |
| 277 | if key == keys.up then | |
| 278 | paintutils.drawLine(15,10,27,10,colors.lightBlue) | |
| 279 | term.setCursorPos(15,10) | |
| 280 | num = num+1 | |
| 281 | toprint = list.readLine() | |
| 282 | cost = list.readLine() | |
| 283 | if cost == nill or toprint == nill then | |
| 284 | list.close() | |
| 285 | list = fs.open("items", "r")
| |
| 286 | toprint = list.readLine() | |
| 287 | cost = list.readLine() | |
| 288 | num = 1 | |
| 289 | end | |
| 290 | term.write(toprint) | |
| 291 | end | |
| 292 | end | |
| 293 | term.setCursorPos(1, 19) | |
| 294 | term.clearLine() | |
| 295 | term.write('click the * box')
| |
| 296 | end | |
| 297 | if y==10 and x==29 then | |
| 298 | term.setCursorPos(1, 19) | |
| 299 | term.clearLine() | |
| 300 | term.write('choose quantity from 1 to 9')
| |
| 301 | term.setCursorPos(29, 10) | |
| 302 | ponies=false | |
| 303 | while not ponies do | |
| 304 | local event, key = os.pullEvent("key")
| |
| 305 | if key>1 and key<11 then | |
| 306 | amount = key-1 | |
| 307 | paintutils.drawLine(29,10,29,10,colors.lightBlue) | |
| 308 | term.setBackgroundColor(colors.lightBlue) | |
| 309 | term.setCursorPos(29, 10) | |
| 310 | term.write(amount) | |
| 311 | ponies = true | |
| 312 | paintutils.drawLine(15,12,22,12,colors.lightBlue) | |
| 313 | term.setCursorPos(15,12) | |
| 314 | price = tonumber(cost)*amount | |
| 315 | amount2020 = amount | |
| 316 | term.write(price) | |
| 317 | end | |
| 318 | end | |
| 319 | term.setCursorPos(1, 19) | |
| 320 | term.clearLine() | |
| 321 | term.write('press the green box to finish')
| |
| 322 | end | |
| 323 | if y==13 and x>32 and x<37 then | |
| 324 | if price == nill and user == nill then | |
| 325 | else | |
| 326 | intrue = false | |
| 327 | end | |
| 328 | end | |
| 329 | end | |
| 330 | ||
| 331 | if banking()=="y" then | |
| 332 | term.setBackgroundColor(colors.white) | |
| 333 | term.clear() | |
| 334 | local image = paintutils.loadImage("bank-ok")
| |
| 335 | term.setCursorPos(1,1) | |
| 336 | paintutils.drawImage(image, 1, 1) | |
| 337 | else | |
| 338 | term.setBackgroundColor(colors.white) | |
| 339 | term.clear() | |
| 340 | local image = paintutils.loadImage("bank-bad")
| |
| 341 | term.setCursorPos(1,1) | |
| 342 | paintutils.drawImage(image, 1, 1) | |
| 343 | os.sleep(3) | |
| 344 | os.reboot() | |
| 345 | end | |
| 346 | ||
| 347 | if not fs.exists("money") then
| |
| 348 | file = fs.open("money", "w")
| |
| 349 | file.writeLine("0")
| |
| 350 | file.close() | |
| 351 | end | |
| 352 | ||
| 353 | file = fs.open("money", "r")
| |
| 354 | money = tonumber(file.readLine()) | |
| 355 | if money==nill then | |
| 356 | money=price | |
| 357 | else | |
| 358 | money = money+price | |
| 359 | end | |
| 360 | file.close() | |
| 361 | shell.run("delete", "money")
| |
| 362 | ||
| 363 | file = fs.open("money", "w")
| |
| 364 | file.writeLine(money) | |
| 365 | file.close() | |
| 366 | ||
| 367 | rednet.open("top")
| |
| 368 | rednet.send(turtleid, amount2020) | |
| 369 | os.sleep(0.5) | |
| 370 | rednet.send(turtleid, num) | |
| 371 | os.sleep(1) | |
| 372 | os.reboot() |