Advertisement
avix133

Untitled

Aug 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. local transposer = component.proxy(component.list("transposer")())
  2. local reward_side = 1
  3. local input_side = 3
  4. local redstone_init_side = sides.north
  5. local redstone_bet_side = sides.west
  6. local redstone_rand_side = sides.up
  7. local redstone = component.proxy(component.list("redstone")())
  8.  
  9. local function get_size(side)
  10.     return transposer.getStackInSlot(input, 2).size
  11. end
  12.  
  13. local function transfer(source, dest, amount, max_stack_size)
  14.     local full_stacks_amount = math.floor(amount/max_stack_size)
  15.     local rest = amount%max_stack_size
  16.     for i = 1, full_stacks_amount do
  17.         transposer.transferItem(source, dest, max_stack_size)
  18.     end
  19.     transposer.transferItem(source, dest, rest)
  20. end
  21.  
  22. local function cash_out(amount)
  23.     print("Cashing out " .. amount)
  24. end
  25.  
  26. local function win()
  27.     print("Win!")
  28. end
  29.  
  30. local function lose()
  31.     print("Lose :(")
  32. end
  33.  
  34.  
  35. local function play()
  36.     local bet_number = redstone.getInput(redstone_bet_side)
  37.     if bet_number >= 1 and bet_number <= 6 then
  38.         rand = math.random(1,6)
  39.         redstone.setOutput(redstone_rand_side, rand)
  40.         print("Rand: " .. rand)
  41.         if bet_number == rand then
  42.             win()
  43.         else
  44.             lose()
  45.         end
  46.     else
  47.         cash_out()
  48.     end
  49. end
  50.  
  51. local function wait_for_action()
  52.     while (true) do
  53.         if redstone.getInput(redstone_init_side) > 0 then
  54.             play()
  55.         end
  56.     end
  57. end
  58.  
  59. wait_for_action()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement