lego11

VERSAMENTO 1.19

Feb 15th, 2025 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Versamenti contanti 1.19
  2.  
  3. --disabilita
  4. rs.setOutput("top", true)
  5.  
  6. local maxw, maxh = term.getSize()
  7.  
  8. --vuota il bancomat
  9. ben = peripheral.wrap("back")
  10. j=ben.getBlockData()
  11.  
  12. coin = 0
  13. coin_8x = 0
  14. coin_64x = 0
  15. coin_512x = 0
  16. coin_4096x = 0
  17. coin_32768x = 0
  18.  
  19.  
  20. for k,v in pairs(j.Items) do
  21. if v.id == "ic2:coin" then
  22. coin = coin + v.Count
  23. elseif v.id == "ic2:coin_8x" then
  24. coin_8x = coin_8x + v.Count
  25. elseif v.id == "ic2:coin_64x" then
  26. coin_64x = coin_64x + v.Count
  27. elseif v.id == "ic2:coin_512x" then
  28. coin_512x = coin_512x + v.Count
  29. elseif v.id == "ic2:coin_4096x" then
  30. coin_4096x = coin_4096x + v.Count
  31. elseif v.id == "ic2:coin_32768x" then
  32. coin_32768x = coin_32768x + v.Count
  33. end
  34. sleep(0.1)
  35. end
  36.  
  37. function clear()
  38. term.clear()
  39. term.setCursorPos(1,1)
  40. end
  41.  
  42.  
  43. if coin ~= 0 or coin_8x ~= 0 or coin_64x ~= 0 or coin_512x ~= 0 or coin_4096x ~= 0 or coin_32768x ~= 0 then
  44. clear()
  45. print("Bancomat temporaneamente non disponibile, per favore attendere")
  46. rs.setOutput("top", false)
  47. for i=1,5 do
  48. term.setCursorPos(3, 3)
  49. term.write("*---")
  50. sleep(0.5)
  51. term.setCursorPos(3, 3)
  52. term.write("-*--")
  53. sleep(0.5)
  54. term.setCursorPos(3, 3)
  55. term.write("--*-")
  56. sleep(0.5)
  57. term.setCursorPos(3, 3)
  58. term.write("---*")
  59. sleep(0.5)
  60. end
  61. rs.setOutput("top", true)
  62. os.reboot()
  63. end
  64.  
  65. function clear()
  66. term.clear()
  67. term.setCursorPos(1, 1)
  68. end
  69.  
  70. function clearRed()
  71. sfondo(colors.red)
  72. term.clear()
  73. term.setCursorPos(1, 1)
  74. end
  75.  
  76. function colore(sfumatura) term.setTextColour(sfumatura) end
  77.  
  78. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  79.  
  80. function fineColore() term.setTextColour(colours.white) end
  81.  
  82. function fineSfondo() term.setBackgroundColour(colours.black) end
  83.  
  84.  
  85. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  86. local function drawPixelInternal(xPos, yPos)
  87. term.setCursorPos(xPos, yPos)
  88. term.write(" ")
  89. end
  90.  
  91. local tColourLookup = {}
  92. for n = 1, 16 do
  93. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  94. end
  95.  
  96. function drawFilledBox(startX, startY, endX, endY, nColour)
  97. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  98. "number" or type(endY) ~= "number" or
  99. (nColour ~= nil and type(nColour) ~= "number") then
  100. error("Expected startX, startY, endX, endY, colour", 2)
  101. end
  102.  
  103. startX = math.floor(startX)
  104. startY = math.floor(startY)
  105. endX = math.floor(endX)
  106. endY = math.floor(endY)
  107.  
  108. if nColour then term.setBackgroundColor(nColour) end
  109. if startX == endX and startY == endY then
  110. drawPixelInternal(startX, startY)
  111. return
  112. end
  113.  
  114. local minX = math.min(startX, endX)
  115. if minX == startX then
  116. minY = startY
  117. maxX = endX
  118. maxY = endY
  119. else
  120. minY = endY
  121. maxX = startX
  122. maxY = startY
  123. end
  124.  
  125. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  126. end
  127.  
  128.  
  129. function titolo(testo)
  130. drawFilledBox(1, 1, maxw, 1, colors.yellow)
  131. term.setCursorPos((maxw - #testo) / 2, 1)
  132. colore(colors.black)
  133. term.write(testo)
  134. sfondo(colors.blue)
  135. end
  136.  
  137. function errore(errore)
  138. sfondo(colors.red)
  139. colore(colors.white)
  140. term.clear()
  141. term.setCursorPos(1, 1)
  142. titolo("Errore irreversibile")
  143. term.setCursorPos(1, 3)
  144. sfondo(colors.red)
  145. colore(colors.white)
  146. print(errore)
  147. print("\n\n\nAttendere qualche secondo...")
  148. os.sleep(5)
  149. os.reboot()
  150. end
  151.  
  152. sfondo(colours.blue)
  153. clear()
  154. titolo("Banco di Nebraska")
  155. sfondo(colours.blue)
  156. colore(colors.white)
  157. print("\n\nSistema Versamento")
  158. print("")
  159. print("Premere un tasto per iniziare l'operazione di versamento")
  160. event = os.pullEvent()
  161.  
  162. sfondo(colours.blue)
  163. term.clear()
  164. term.setCursorPos(1, 1)
  165. titolo("Accredita su Nebraska Pay")
  166. sfondo(colours.blue)
  167. colore(colors.white)
  168. print(
  169. "\n\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
  170.  
  171. -- nomeutente
  172. term.setCursorPos(1, 9)
  173. term.write("Nome utente:")
  174. term.setCursorPos(15, 9)
  175. fineColore()
  176. utenteAccettato = false
  177. conteggioErrori = 0
  178. while utenteAccettato == false do
  179. utente = read()
  180. utente = string.gsub(utente, "%s", "")
  181. checkuser = http.get(
  182. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" ..
  183. utente).readAll()
  184. tabcheckuser = textutils.unserialize(checkuser)
  185. if tabcheckuser.stato == "OK" then
  186. term.setCursorPos(15, 9)
  187. colore(colours.lime)
  188. term.write(utente)
  189. fineColore()
  190. utenteAccettato = true
  191. else
  192. term.setCursorPos(15, 9)
  193. colore(colours.red)
  194. term.write("Utente errato! ")
  195. sleep(2)
  196. term.setCursorPos(15, 9)
  197. fineColore()
  198. term.write(" ")
  199. term.setCursorPos(15, 9)
  200. conteggioErrori = conteggioErrori + 1
  201. if conteggioErrori > 2 then
  202. term.setCursorPos(15, 9)
  203. colore(colours.red)
  204. errore("Troppi tentativi di immissione errati ")
  205. end
  206. end
  207. end
  208. colore(colours.white)
  209. term.setCursorPos(1, 11)
  210. term.write("Password:")
  211. term.setCursorPos(15, 11)
  212. conteggioErrori = 0
  213. passAccettata = false
  214. while passAccettata == false do
  215. fineColore()
  216. password = read("#")
  217. colore(colours.black)
  218. checkuser = http.get(
  219. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=" ..
  220. password .. "&richiesta=addebito&valore=0&utente=" ..
  221. utente).readAll()
  222. risposta = textutils.unserialize(checkuser)
  223. if risposta.stato == "OK" then
  224. term.setCursorPos(15, 11)
  225. colore(colours.lime)
  226. term.write("############## ")
  227. fineColore()
  228. passAccettata = true
  229. else
  230. term.setCursorPos(15, 11)
  231. colore(colours.red)
  232. term.write("Password errata! ")
  233. conteggioErrori = conteggioErrori + 1
  234. sleep(2)
  235. term.setCursorPos(15, 11)
  236. term.write(" ")
  237. term.setCursorPos(15, 11)
  238. if conteggioErrori > 2 then
  239. term.setCursorPos(15, 11)
  240. colore(colours.red)
  241. errore("Troppi tentativi di immissione errati")
  242. end
  243. end
  244. end
  245. metodoPagamento = "NPAY"
  246. credito = tonumber(risposta.saldo)
  247. clear()
  248.  
  249. while true do
  250. print("Il conto ha un saldo di "..credito.." IC.")
  251. print("")
  252. print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
  253. print("")
  254. print("[1] Versare contanti")
  255. print("[2] Annullare il versamento")
  256.  
  257. num=tonumber(read())
  258. if num == 1 then
  259.  
  260. clear()
  261. redstone.setOutput("right", true)
  262. print("Inserire i contanti nello sportello sotto al computer")
  263. print("")
  264. print("AVVERTENZA IMPORTANTE:")
  265. print("Inserire SOLO monete:")
  266. print("Oggetti non consentiti vengono rifiutati")
  267. print("")
  268. print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
  269. print("")
  270. print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
  271. os.pullEvent("key")
  272.  
  273. clear()
  274.  
  275. redstone.setOutput("right", false)
  276.  
  277. print("Conteggio contanti in corso...")
  278. term.setCursorPos(3, 3)
  279. term.write("*---")
  280. sleep(0.5)
  281. term.setCursorPos(3, 3)
  282. term.write("-*--")
  283. sleep(0.5)
  284. term.setCursorPos(3, 3)
  285. term.write("--*-")
  286. sleep(0.5)
  287. term.setCursorPos(3, 3)
  288. term.write("---*")
  289. sleep(0.5)
  290.  
  291. ben = peripheral.wrap("back")
  292. j=ben.getBlockData()
  293.  
  294. coin = 0
  295. coin_8x = 0
  296. coin_64x = 0
  297. coin_512x = 0
  298. coin_4096x = 0
  299. coin_32768x = 0
  300.  
  301.  
  302. for k,v in pairs(j.Items) do
  303. if v.id == "ic2:coin" then
  304. coin = coin + v.Count
  305. elseif v.id == "ic2:coin_8x" then
  306. coin_8x = coin_8x + v.Count
  307. elseif v.id == "ic2:coin_64x" then
  308. coin_64x = coin_64x + v.Count
  309. elseif v.id == "ic2:coin_512x" then
  310. coin_512x = coin_512x + v.Count
  311. elseif v.id == "ic2:coin_4096x" then
  312. coin_4096x = coin_4096x + v.Count
  313. elseif v.id == "ic2:coin_32768x" then
  314. coin_32768x = coin_32768x + v.Count
  315. end
  316. sleep(0.1)
  317. end
  318.  
  319. contanti = coin + coin_8x*8 + coin_64x*64 + coin_512x*512 + coin_4096x*4096 + coin_32768x*32768
  320.  
  321. print("\n\nTotale versato: "..contanti.." IC")
  322.  
  323. rs.setOutput("top", false)
  324. print("")
  325. inviaDenaro = http.get(
  326. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=" ..
  327. password .. "&utente=" .. utente ..
  328. "&richiesta=accredito&causale=Vendita%20contanti&valore=" .. contanti).readAll()
  329. risultatoInvio = textutils.unserialize(inviaDenaro)
  330. if risultatoInvio.stato == "OK" then
  331. colore(colors.white)
  332. else
  333. clear()
  334. errore("Errore durante il pagamento")
  335. sleep(5)
  336. os.reboot()
  337. end
  338.  
  339. sleep(1)
  340. clear()
  341. print("Denaro versato.")
  342. print("")
  343. print("")
  344. print("Grazie!")
  345. sleep(1)
  346. term.setTextColor(colors.black)
  347. rs.setOutput("top", true)
  348. shell.run("pastebin get 0M1pB5f3 startup2")
  349. if fs.exists("startup2") then
  350. shell.run("rm startup")
  351. shell.run("mv startup2 startup")
  352. end
  353.  
  354. os.reboot()
  355. elseif num == 2 then clear() break end
  356. end
  357. clear()
  358. print("Attendere")
  359.  
  360. shell.run("pastebin get 0M1pB5f3 startup2")
  361. if fs.exists("startup2") then
  362. shell.run("rm startup")
  363. shell.run("mv startup2 startup")
  364. end
  365.  
  366. term.setTextColor(colors.black)
  367. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment