Marum

Computercraft Bank Store Clerk v1

Jan 26th, 2020 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.22 KB | None | 0 0
  1. -----------------------Params
  2. local bankServerID = 15
  3. local modemSide = "left"
  4. local diskSide = "right"
  5. local chestSide = "bottom"
  6.  
  7. local text_error_noconnection = "Can't connect to server"
  8. --------------------------
  9. rednet.open(modemSide)
  10.  
  11. os.loadAPI("bankapi.lua")
  12. bankapi.setBankServerID(bankServerID)
  13. --------------------------
  14.  
  15. local owner = nil
  16. local catalog = {}
  17. local shopName = "Tienda"
  18.  
  19. if (not fs.exists("owner.txt")) then
  20. if (fs.exists("disk")) then
  21. local tempClientData = bankapi.getClientData()
  22. local f = fs.open("disk/mermegold.txt", "r")
  23. if (f ~= nil) then
  24. local key = f.readLine()
  25. if (tempClientData[key] ~= nil) then
  26. local cf = fs.open("owner.txt", "w")
  27. cf.writeLine(key)
  28. cf.close()
  29. bankapi.successScreen("Reclamaste esta maquina como dueño")
  30. else
  31. bankapi.errorScreen("Tarjeta invalida")
  32. end
  33. else
  34. bankapi.errorScreen("El Disquet ingresado no es tarjeta")
  35. end
  36. f.close()
  37. os.reboot()
  38. else
  39. bankapi.errorScreen("Inserte tarjeta para configurar")
  40. os.shutdown()
  41. end
  42. else
  43. local f = fs.open("owner.txt", "r")
  44. owner = f.readLine()
  45. f.close()
  46. end
  47.  
  48. local currentAccount = 0
  49.  
  50. if (fs.exists("disk")) then
  51. local f = fs.open("disk/mermegold.txt", "r")
  52. if (f ~= nil) then
  53. local value = f.readLine()
  54. if (value ~= nil) then
  55. local tempClientData = bankapi.getClientData()
  56. if (tempClientData[value] ~= nil) then
  57. currentAccount = value
  58. end
  59. end
  60. f.close()
  61. end
  62. else
  63. bankapi.errorScreen("Inserte una tarjeta")
  64. os.shutdown()
  65. end
  66.  
  67. local function loadShopName()
  68. local f = fs.open("shopname.txt", "r")
  69. if (f ~= nil) then
  70. local value = f.readLine()
  71. if (value ~= nil) then
  72. shopName = value
  73. end
  74. f.close()
  75. else
  76. local f = fs.open("shopname.txt", "w")
  77. f.writeLine("Tienda")
  78. f.close()
  79. end
  80. end
  81.  
  82. local function loadCatalog()
  83. local f = fs.open("catalog.txt", "r")
  84. if (f ~= nil) then
  85. catalog = {}
  86. local line = f.readLine()
  87. while line ~= nil do
  88. local lline = line
  89. local item = ""
  90. local damage = 0
  91. local count = 0
  92. local price = 0
  93. local name = ""
  94.  
  95. while lline ~= "" and lline ~= nil do
  96. if (lline == "item") then
  97. item = f.readLine()
  98. elseif (lline == "damage") then
  99. damage = tonumber(f.readLine())
  100. elseif (lline == "count") then
  101. count = tonumber(f.readLine())
  102. elseif (lline == "price") then
  103. price = tonumber(f.readLine())
  104. elseif (lline == "name") then
  105. name = f.readLine()
  106. end
  107. lline = f.readLine()
  108. end
  109.  
  110. if (catalog[item] == nil) then
  111. catalog[item] = {}
  112. end
  113. catalog[item][damage] = {
  114. ["count"] = count,
  115. ["price"] = price,
  116. ["name"] = name
  117. }
  118.  
  119. line = f.readLine()
  120. end
  121.  
  122. f.close()
  123. else
  124. local f = fs.open("catalog.txt", "w")
  125. f.close()
  126. end
  127. end
  128.  
  129. local function updateCatalog()
  130. local f = fs.open("catalog.txt", "w")
  131. for name, damagetypes in pairs(catalog) do
  132. print(name, damagetypes)
  133. for damage, detail in pairs(damagetypes) do
  134. print(damage, detail)
  135. for k, v in pairs(detail) do
  136. print(k, v)
  137. end
  138. f.writeLine("item")
  139. f.writeLine(name)
  140. f.writeLine("damage")
  141. f.writeLine(tostring(damage))
  142. f.writeLine("count")
  143. f.writeLine(tostring(detail.count))
  144. f.writeLine("name")
  145. f.writeLine(detail.name)
  146. f.writeLine("price")
  147. f.writeLine(tostring(detail.price))
  148. f.writeLine("")
  149. end
  150. end
  151. f.close()
  152. end
  153.  
  154. local function printWithPadding(x, leftText, rightText, newLine, color)
  155. local scrW, scrH = term.getSize()
  156. leftText = string.rep(" ", x-1)..leftText
  157. if (newLine == nil) then newLine = true end
  158. local space = string.len(leftText)+string.len(rightText)
  159. local padding = scrW-space
  160. local paddingText = ""
  161. if (padding > 0) then
  162. paddingText = string.rep(".", padding)
  163. else
  164. leftText = string.sub(leftText, 1, string.len(leftText)+padding-1)
  165. paddingText = "."
  166. end
  167. if (color == nil) then
  168. term.setTextColor(colors.white)
  169. else
  170. term.setTextColor(color)
  171. end
  172. term.write(leftText)
  173. term.setTextColor(colors.gray)
  174. term.write(paddingText)
  175. if (color == nil) then
  176. term.setTextColor(colors.white)
  177. else
  178. term.setTextColor(color)
  179. end
  180. term.write(rightText)
  181. if (newLine) then
  182. print("")
  183. end
  184. end
  185.  
  186. local function buy(previousEstimatedPrice)
  187. local scrW, scrH = term.getSize()
  188. term.setBackgroundColor(colors.gray)
  189. term.clear()
  190. term.setTextColor(colors.white)
  191. local text = "Registrando pago. Espere por favor..."
  192. term.setCursorPos(scrW/2-string.len(text)/2+1, scrH/2)
  193. term.write(text)
  194. local text = "Por favor no quite los items"
  195. term.setCursorPos(scrW/2-string.len(text)/2+1, scrH/2+1)
  196. term.write(text)
  197.  
  198. local buyingItems = {}
  199. for i=1, 16 do
  200. turtle.select(i)
  201. local detail = turtle.getItemDetail(i)
  202. turtle.dropDown()
  203. if (detail ~= nil) then
  204. local item = detail.name
  205. if (catalog[item] ~= nil) then
  206. local damage = detail.damage
  207. if detail.damage == nil then
  208. damage = 1
  209. end
  210. if (catalog[item][damage] ~= nil) then
  211. local product = catalog[item][damage]
  212.  
  213. if (buyingItems[item] == nil) then
  214. buyingItems[item] = {}
  215. end
  216. if (buyingItems[item][damage] == nil) then
  217. buyingItems[item][damage] = detail.count
  218. else
  219. buyingItems[item][damage] = buyingItems[item][damage]+detail.count
  220. end
  221. end
  222. end
  223. end
  224. end
  225.  
  226. local totalPrice = 0
  227.  
  228. local totalReceitDescription = shopName..": "
  229.  
  230. for item, damagetypes in pairs(buyingItems) do
  231. for damage, count in pairs(damagetypes) do
  232. local product = catalog[item][damage]
  233. local estimatedPrice = math.ceil(count*product.price/product.count)
  234. totalPrice = totalPrice+estimatedPrice
  235. totalReceitDescription = totalReceitDescription.." "..product.name.." x"..count.." ($"..estimatedPrice..") |"
  236. end
  237. end
  238.  
  239. bankapi.transaction(currentAccount, owner, totalPrice, totalReceitDescription)
  240.  
  241. if (previousEstimatedPrice ~= totalPrice) then
  242. bankapi.errorScreen("No quite los items mientras cuento")
  243. bankapi.errorScreen("No pagó por esos.")
  244. bankapi.errorScreen("Solo le corresponden los del cofre")
  245. bankapi.errorScreen("Por favor no lo haga de nuevo.")
  246. else
  247. bankapi.successScreen("¡Gracias por comprar en "..shopName.."!")
  248. bankapi.successScreen("Ya puede llevarse su compra del cofre")
  249. end
  250. end
  251.  
  252. local function logout()
  253. for i=1, 16 do
  254. local detail = turtle.getItemDetail(i)
  255. if (detail ~= nil) then
  256. bankapi.errorScreen("Por favor devuelva los items...")
  257. bankapi.errorScreen("...a su lugar antes de irse")
  258. disk.eject(diskSide)
  259. os.shutdown()
  260. return
  261. end
  262. end
  263. disk.eject(diskSide)
  264. bankapi.successScreen("¡Vuelva pronto!")
  265. os.shutdown()
  266. end
  267.  
  268. loadShopName()
  269. loadCatalog()
  270.  
  271. while true do -- Second while to allow the use of breaks as continues
  272. while true do
  273.  
  274. if (owner == currentAccount) then
  275. local command = bankapi.optionMenu(shopName, {
  276. [1] = {
  277. ["option"] = "help",
  278. ["text"] = "Ayuda"},
  279. [2] = {
  280. ["option"] = "name",
  281. ["text"] = "Configurar Nombre"},
  282. [3] = {
  283. ["option"] = "catalog",
  284. ["text"] = "Configurar catalogo"},
  285. [4] = {
  286. ["option"] = "forfeit",
  287. ["text"] = "Desasignar dueño"},
  288. [5] = {
  289. ["option"] = "logout",
  290. ["text"] = "Salir"},
  291. })
  292.  
  293. if (command == "help") then
  294. bankapi.textScreen({
  295. "Debes registrar los productos que",
  296. "quieras vender en esta terminal. ",
  297. "Puedes registrar, editar y eliminar",
  298. "mas de uno a la vez poniendo varios",
  299. "en el inventario.",
  300. "La cantidad de items que ingreses",
  301. "indica cada cuanto se cobra ese precio,",
  302. "por ejemplo poner 64 troncos hará que",
  303. "el precio que ingreses sea cada 64",
  304. "items."
  305. })
  306.  
  307. elseif (command == "name") then
  308. local newname = bankapi.inputTextScreen({"Ingresar el nombre del local"}, 1, 30)
  309. if (newname == nil) then break end
  310. shopName = newname
  311.  
  312. local f = fs.open("shopname.txt", "w")
  313. f.writeLine(shopName)
  314. f.close()
  315.  
  316. bankapi.successScreen("Local renombrado a "..shopName)
  317.  
  318. elseif (command == "catalog") then
  319.  
  320. while true do -- Sub menu
  321. local command = bankapi.optionMenu(shopName, {
  322. [1] = {
  323. ["option"] = "list",
  324. ["text"] = "Ver Catalogo"},
  325. [2] = {
  326. ["option"] = "add",
  327. ["text"] = "Registrar Producto/s"},
  328. [3] = {
  329. ["option"] = "edit",
  330. ["text"] = "Editar Producto/s"},
  331. [4] = {
  332. ["option"] = "remove",
  333. ["text"] = "Remover Producto/s"},
  334. [5] = {
  335. ["option"] = "back",
  336. ["text"] = "Volver"},
  337. })
  338.  
  339. if (command == "list") then
  340.  
  341. local firstLog = 0
  342. local currentLog = 0
  343. local scrW, scrH = term.getSize()
  344.  
  345. local catalogLength = 0
  346. for k, v in pairs(catalog) do
  347. catalogLength = catalogLength+1
  348. end
  349.  
  350. term.setBackgroundColor(colors.black)
  351. if (catalogLength > 0) then
  352. term.clear()
  353. term.setCursorPos(1,1)
  354.  
  355. for name, damagetypes in pairs(catalog) do
  356. for damage, detail in pairs(damagetypes) do
  357. term.setTextColor(colors.white)
  358. print(detail.name.." x"..detail.count.." = $"..detail.price)
  359. term.setTextColor(colors.gray)
  360. print(name.." (damage: "..damage..")")
  361.  
  362. local cursorx, cursory = term.getCursorPos()
  363. if (cursory > scrH-2) then
  364. term.setTextColor(colors.gray)
  365. term.setCursorPos(1, scrH-1)
  366. print("Apreta cualquier tecla para ver mas")
  367. os.pullEvent("key")
  368.  
  369. term.clear()
  370. term.setCursorPos(1,1)
  371. end
  372. end
  373. end
  374. else
  375. bankapi.errorScreen("No hay productos registrados")
  376. end
  377.  
  378. term.setTextColor(colors.white)
  379. term.setCursorPos(1, scrH-1)
  380. print("Apreta cualquier tecla para volver")
  381. os.pullEvent("key")
  382.  
  383. elseif (command == "add") then
  384. turtle.select(1)
  385. local steps = {
  386. "Productos y cantidades a registrar",
  387. "Nombre de estos productos",
  388. "Precio por los productos"
  389. }
  390. local count
  391. local breaking = false
  392. local totalItems
  393. repeat
  394. count = {}
  395. local accept = bankapi.confirmScreen({"Ingresa uno o mas productos en la", "cantidad que quieras registrar en", "el inventario, y luego presiona", "aceptar para continuar"}, {}, steps, 1)
  396. if (not accept) then
  397. breaking = true
  398. break
  399. end
  400. totalItems = 0
  401. for i=1, 16 do
  402. local itemCount = turtle.getItemCount(i)
  403. if (itemCount > 0) then
  404. count[i] = itemCount
  405. totalItems = totalItems+itemCount
  406. end
  407. end
  408. until totalItems > 0
  409. if (breaking) then break end
  410.  
  411. local detail = {}
  412. for i=1, 16 do
  413. local itemDetail = turtle.getItemDetail(i)
  414. if (itemDetail ~= nil) then
  415. detail[i] = itemDetail
  416. end
  417. end
  418.  
  419. local name = bankapi.inputTextScreen(steps, 2)
  420. if (name == nil) then break end
  421.  
  422. local price = bankapi.inputNumberScreen(steps, 3)
  423. if (price == nil) then break end
  424.  
  425. local displayName = nil
  426. local displayCount = nil
  427. local oneName = true
  428. local oneCount = true
  429. local set = false
  430. for k, v in pairs(detail) do
  431. if (not set) then
  432. displayName = v.name
  433. displayCount = v.count
  434. set = true
  435. else
  436. if (displayName ~= v.name) then
  437. oneName = false
  438. displayName = "<varios>"
  439. end
  440. if (displayCount ~= v.count) then
  441. oneCount = false
  442. displayCount = "<varios>"
  443. end
  444. end
  445. end
  446.  
  447. local confirmData = {
  448. ["Nombre"] = name,
  449. ["Producto"] = displayName,
  450. ["Cantidad"] = "x"..displayCount,
  451. ["Precio"] = "$"..price
  452. }
  453. local accept = bankapi.confirmScreen({"¿Quieres registrar estos productos?"}, confirmData)
  454. if (not accept) then break end
  455.  
  456. for k, v in pairs(detail) do
  457. if (catalog[v.name] == nil) then
  458. catalog[v.name] = {}
  459. end
  460. local damage = v.damage
  461. if v.damage == nil then
  462. damage = 1
  463. end
  464. catalog[v.name][damage] = {
  465. ["name"] = name,
  466. ["count"] = v.count,
  467. ["price"] = price
  468. }
  469. end
  470.  
  471. updateCatalog()
  472.  
  473. bankapi.successScreen("Producto registrado")
  474.  
  475. elseif (command == "edit") then
  476.  
  477. turtle.select(1)
  478. local steps = {
  479. "Producto a editar",
  480. "Nuevo nombre (vacio = no cambiar)",
  481. "Nuevo precio (vacio = no cambiar)"
  482. }
  483. local count
  484. local breaking = false
  485. local totalItems
  486. repeat
  487. count = {}
  488. local accept = bankapi.confirmScreen({"Ingresa un producto que quieras", "editar en el primer slot", "y luego presiona aceptar"}, {}, steps, 1)
  489. if (not accept) then
  490. breaking = true
  491. break
  492. end
  493. totalItems = 0
  494. for i=1, 16 do
  495. local itemCount = turtle.getItemCount(i)
  496. if (itemCount > 0) then
  497. count[i] = itemCount
  498. totalItems = totalItems+itemCount
  499. end
  500. end
  501. until totalItems > 0
  502. if (breaking) then break end
  503.  
  504. local detail = {}
  505. for i=1, 16 do
  506. local itemDetail = turtle.getItemDetail(i)
  507. if (itemDetail ~= nil) then
  508. detail[i] = itemDetail
  509. end
  510. end
  511.  
  512. local breaking = false
  513. for k, v in pairs(detail) do
  514. local damage = v.damage
  515. if v.damage == nil then
  516. damage = 1
  517. end
  518. if (catalog[v.name] == nil) then
  519. bankapi.errorScreen("'"..v.name.."' no esta registrado")
  520. breaking = true
  521. elseif (catalog[v.name][damage] == nil) then
  522. bankapi.errorScreen("'"..v.name.."' no esta registrado")
  523. breaking = true
  524. end
  525. end
  526. if (breaking) then break end
  527.  
  528. local displayName = nil
  529. local displayCount = nil
  530. local oneName = true
  531. local oneCount = true
  532. local set = false
  533. for k, v in pairs(detail) do
  534. if (not set) then
  535. displayName = v.name
  536. displayCount = v.count
  537. set = true
  538. else
  539. if (displayName ~= v.name) then
  540. oneName = false
  541. displayName = "<varios>"
  542. end
  543. if (displayCount ~= v.count) then
  544. oneCount = false
  545. displayCount = "<varios>"
  546. end
  547. end
  548. end
  549.  
  550. local displayDetail = {
  551. ["Nombre"] = displayName,
  552. ["Cantidad"] = displayCount
  553. }
  554.  
  555. local accept = bankapi.confirmScreen({"¿Quieres editar estos productos?"}, displayDetail)
  556. if (not accept) then break end
  557.  
  558. local editName = true
  559. local name = bankapi.inputTextScreen(steps, 2)
  560. if (name == nil) then break end
  561. if (name == "") then editName = false end
  562.  
  563. local editPrice = true
  564. local price = bankapi.inputNumberScreen(steps, 3)
  565. if (price == nil) then break end
  566. if (price == "") then editPrice = false end
  567.  
  568. local accept = bankapi.confirmScreen({"¿Quieres confirmar este cambio?"})
  569. if (not accept) then break end
  570. term.setBackgroundColor(colors.red)
  571. term.setTextColor(colors.black)
  572. print(540)
  573. for k, v in pairs(detail) do
  574. if (catalog[v.name] == nil) then
  575. catalog[v.name] = {}
  576. end
  577. local damage = v.damage
  578. if v.damage == nil then
  579. damage = 1
  580. end
  581. if (catalog[v.name][damage] == nil) then
  582. catalog[v.name][damage] = {}
  583. end
  584. if (editName) then
  585. catalog[v.name][damage].name = name
  586. end
  587. if (editPrice) then
  588. catalog[v.name][damage].price = price
  589. end
  590. catalog[v.name][damage].count = count[k]
  591. end
  592.  
  593. updateCatalog()
  594.  
  595. bankapi.successScreen("Producto registrado")
  596.  
  597. elseif (command == "remove") then
  598.  
  599. turtle.select(1)
  600. local steps = {
  601. "Productos a eliminar"
  602. }
  603. local count = turtle.getItemCount()
  604. local breaking = false
  605. repeat
  606. local accept = bankapi.confirmScreen({"Ingresa los productos que quieras", "eliminar en el inventario", "y luego presiona aceptar"}, {}, steps, 1)
  607. if (not accept) then
  608. breaking = true
  609. break
  610. end
  611. count = turtle.getItemCount()
  612. until count > 0
  613. if (breaking) then break end
  614.  
  615. local detail = {}
  616. for i=1, 16 do
  617. local itemDetail = turtle.getItemDetail(i)
  618. if (itemDetail ~= nil) then
  619. detail[i] = itemDetail
  620. end
  621. end
  622.  
  623. local displayName = nil
  624. local oneName = true
  625. local set = false
  626. for k, v in pairs(detail) do
  627. if (not set) then
  628. displayName = v.name
  629. set = true
  630. else
  631. if (displayName ~= v.name) then
  632. oneName = false
  633. displayName = "<varios>"
  634. end
  635. end
  636. end
  637.  
  638. local displayMessage = {
  639. ["Nombre"] = displayName
  640. }
  641. local accept = bankapi.confirmScreen({"¿Quieres eliminar estos productos?"}, displayMessage)
  642. if (not accept) then break end
  643.  
  644. for k, v in pairs (detail) do
  645. local damage = v.damage
  646. if v.damage == nil then
  647. damage = 1
  648. end
  649. catalog[v.name][damage] = nil
  650. end
  651.  
  652. updateCatalog()
  653.  
  654. bankapi.successScreen("Producto eliminado")
  655.  
  656. elseif (command == "back") then
  657. break
  658. end
  659. end
  660.  
  661. elseif (command == "forfeit") then
  662. local accept = bankapi.confirmScreen({"¿Deseas desasignarte como dueño", "de esta maquina?"})
  663. if (accept) then
  664. fs.delete("owner.txt")
  665. disk.eject(diskSide)
  666. bankapi.successScreen("Te desasignaste como dueño.")
  667. os.shutdown()
  668. end
  669.  
  670. elseif (command == "logout") then
  671. disk.eject(diskSide)
  672. os.shutdown()
  673. end
  674. elseif (currentAccount == 0) then -- No valid disk
  675. bankapi.errorScreen("Inserte una tarjeta")
  676. os.shutdown()
  677. else -- Valid account
  678.  
  679. local scrW, scrH = term.getSize()
  680. local tempClientData = bankapi.getClientData()
  681. while true do
  682. term.setBackgroundColor(colors.black)
  683. term.setTextColor(colors.lightGray)
  684. term.clear()
  685. term.setCursorPos(1,1)
  686. term.setTextColor(colors.gray)
  687. local buyingItems = {}
  688. for i=1, 16 do
  689. local detail = turtle.getItemDetail(i)
  690. if (detail ~= nil) then
  691. local item = detail.name
  692. if (catalog[item] ~= nil) then
  693. local damage = detail.damage
  694. if detail.damage == nil then
  695. damage = 1
  696. end
  697. if (catalog[item][damage] ~= nil) then
  698. local product = catalog[item][damage]
  699.  
  700. if (buyingItems[item] == nil) then
  701. buyingItems[item] = {}
  702. end
  703. if (buyingItems[item][damage] == nil) then
  704. buyingItems[item][damage] = detail.count
  705. else
  706. buyingItems[item][damage] = buyingItems[item][damage]+detail.count
  707. end
  708. end
  709. end
  710. end
  711. end
  712.  
  713. local totalPrice = 0
  714.  
  715. for item, damagetypes in pairs(buyingItems) do
  716. for damage, count in pairs(damagetypes) do
  717. local product = catalog[item][damage]
  718. local estimatedPrice = math.ceil(count*product.price/product.count)
  719. local leftText = product.name.." x"..count
  720. local rightText = "$"..estimatedPrice
  721. totalPrice = totalPrice+estimatedPrice
  722. printWithPadding(1, leftText, rightText)
  723. end
  724. end
  725.  
  726. print("")
  727. print("")
  728.  
  729. term.setCursorPos(1, scrH-2)
  730. term.setTextColor(colors.lightGray)
  731.  
  732. local balance = tempClientData[currentAccount].balance
  733. printWithPadding(23, "Tu Balance", "$"..balance, true, colors.gray)
  734. printWithPadding(23, "Precio", "$"..totalPrice)
  735. local total = balance-totalPrice
  736. if (total < 0) then
  737. printWithPadding(23, "Total", "$"..total, false, colors.red)
  738. else
  739. printWithPadding(23, "Total", "$"..total, false, colors.gray)
  740. end
  741.  
  742. term.setTextColor(colors.black)
  743. if (totalPrice > 0 and total >= 0) then
  744. term.setCursorPos(1, scrH-2)
  745. term.setBackgroundColor(colors.green)
  746. term.write(" Comprar y continuar ")
  747. term.setCursorPos(1, scrH-1)
  748. term.setBackgroundColor(colors.yellow)
  749. term.write(" Comprar y salir ")
  750. else
  751. term.setCursorPos(1, 1)
  752. term.setBackgroundColor(colors.orange)
  753. term.write(" Instrucciones ")
  754. end
  755. term.setCursorPos(1, scrH)
  756. term.setBackgroundColor(colors.red)
  757. term.write(" Cancelar y salir ")
  758.  
  759. while true do
  760. local event, button, cx, cy = os.pullEvent()
  761. if (event == "turtle_inventory") then
  762. break
  763. elseif (event == "mouse_click") then
  764. if (cx < 23) then
  765. if (totalPrice > 0 and total >= 0) then
  766. if (cy == scrH-2) then
  767. buy(totalPrice)
  768. break
  769. end
  770. if (cy == scrH-1) then
  771. buy(totalPrice)
  772. logout()
  773. break
  774. end
  775. else
  776. if (cy == 1) then
  777. bankapi.textScreen({
  778. "Trae los items que quieras comprar",
  779. "y ponlos en el inventario de este",
  780. "robot. Se contará el monto a pagar",
  781. "automáticamente, y podrás aceptar para",
  782. "finalizar el pago. Cuando confirmes,",
  783. "tus compras serán depositadas en el",
  784. "cofre debajo de este robot.",
  785. "Si cancelas y dejaste items adentro",
  786. "del robot, por favor, devuelvelos a",
  787. "su lugar. ¡No te olvides tu tarjeta!",
  788. "Siempre usa el boton de 'cancelar y",
  789. "salir' en vez de quitarla a mano."
  790. })
  791. break
  792. end
  793. end
  794. if (cy == scrH) then
  795. logout()
  796. end
  797. end
  798. end
  799. end
  800. end
  801. end
  802. end
  803. end
Add Comment
Please, Sign In to add comment