Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local transposer = component.proxy(component.list("transposer")())
- local reward_side = 1
- local input_side = 3
- local redstone_init_side = sides.north
- local redstone_bet_side = sides.west
- local redstone_rand_side = sides.up
- local redstone = component.proxy(component.list("redstone")())
- local function get_size(side)
- return transposer.getStackInSlot(input, 2).size
- end
- local function transfer(source, dest, amount, max_stack_size)
- local full_stacks_amount = math.floor(amount/max_stack_size)
- local rest = amount%max_stack_size
- for i = 1, full_stacks_amount do
- transposer.transferItem(source, dest, max_stack_size)
- end
- transposer.transferItem(source, dest, rest)
- end
- local function cash_out(amount)
- print("Cashing out " .. amount)
- end
- local function win()
- print("Win!")
- end
- local function lose()
- print("Lose :(")
- end
- local function play()
- local bet_number = redstone.getInput(redstone_bet_side)
- if bet_number >= 1 and bet_number <= 6 then
- rand = math.random(1,6)
- redstone.setOutput(redstone_rand_side, rand)
- print("Rand: " .. rand)
- if bet_number == rand then
- win()
- else
- lose()
- end
- else
- cash_out()
- end
- end
- local function wait_for_action()
- while (true) do
- if redstone.getInput(redstone_init_side) > 0 then
- play()
- end
- end
- end
- wait_for_action()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement