ecco7777

CC Slotmachine

Jan 6th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --Slotmachine my ecco7777 Copyright 2016
  2. chestside=2
  3. outputside=5
  4. --0 for down, 1 for up, 2 for -Z, 3 for +Z, 4 for -X and 5 for +X.
  5. money=0
  6. cost=1
  7. n1,n2,n3=1,2,3
  8. sym={"CC","IC","SC"}
  9. m=peripheral.wrap("top")
  10. s=peripheral.wrap("right")
  11.  
  12. function show()
  13. m.clear()
  14. m.setCursorPos(1,1) m.write("Money:")
  15. m.setCursorPos(1,2) m.write(tostring(money).."$")
  16. m.setCursorPos(1,3) m.write("_Slots_")
  17. m.setCursorPos(1,4) m.write(sym[n1]..sym[n2]..sym[n3])
  18. m.setCursorPos(1,5) m.write("Play")
  19. end
  20.  
  21. function play()
  22. if money>=cost then
  23. money=money-cost
  24. n1,n2,n3=math.random(1,3),math.random(1,3),math.random(1,3)
  25. value=tonumber(tostring(n1)..tostring(n2)..tostring(n3))
  26. if value==111 then s.extract(chestside,21256,outputside,1) end
  27. if value==222 then s.extract(chestside,30186,outputside,1) end
  28. if value==333 then s.extract(chestside,54024,outputside,1) end
  29.  
  30. end
  31. end
  32.  
  33. function payin()
  34. if id==21256 then money=money+(0.125*amount) end
  35. if id==30186 then money=money+(1*amount) end
  36. if id==54024 then money=money+(8*amount) end
  37. if id==86792 then money=money+(64*amount) end
  38. if id==119560 then money=money+(512*amount) end
  39. s.sort(chestside,amount)
  40. end
  41.  
  42. show()
  43. while true do
  44. event,id,amount=os.pullEvent()
  45. if event=="isort_item" then payin() end
  46. if event=="monitor_touch" then play() end
  47. show()
  48. end
Add Comment
Please, Sign In to add comment