Posted 10 August 2012 - 05:46 PM
Hey there.
I'm trying to make a casino on a multiplayer server I play on. However, I keep on getting errors with my code. I set the code as startup, by the way. Basically, you put a diamond in a chest, and it will pass through a filter then item detector and send a pulse to the computer, which will start the slots. The code is linked http://pastebin.com/kxUNBk1p . Also posted below. Thanks for any and all help in advance!
I'm trying to make a casino on a multiplayer server I play on. However, I keep on getting errors with my code. I set the code as startup, by the way. Basically, you put a diamond in a chest, and it will pass through a filter then item detector and send a pulse to the computer, which will start the slots. The code is linked http://pastebin.com/kxUNBk1p . Also posted below. Thanks for any and all help in advance!
prizeamount = 10
detectside = "front"
monside = "right"
dispenserside = "bottom"
showloser = true
mon = peripheral.wrap(monside)
shell.run("clear",1)
mon.clear()
mon.setCursorPos(1,1)
mon.write(" Place")
mon.setCursorPos(1,2)
mon.write("Diamond")
mon.setCursorPos(1,3)
mon.write("In Chest")
mon.setCursorPos(1,4)
mon.write("To Play")
print("Hold Control + T to edit code")
function winner()
sleep(2)
mon.clear()
mon.setCursorPos(1,1)
mon.write("*-*-*-*")
mon.setCursorPos(1,2)
mon.write("-*-*-*-")
mon.setCursorPos(1,3)
mon.write("Winner!")
mon.setCursorPos(1,4)
mon.write("-*-*-*-")
mon.setCursorPos(1,5)
mon.write("*-*-*-*")
sleep(2.5)
end
function Loser()
sleep(2)
mon.clear()
mon.setCursorPos(1,1)
mon.write("*-*-*-*")
mon.setCursorPos(1,2)
mon.write("-*-*-*-")
mon.setCursorPos(1,3)
mon.write("Loser!!")
mon.setCursorPos(1,4)
mon.write("-*-*-*-")
mon.setCursorPos(1,5)
mon.write("*-*-*-*")
sleep(2)
end
function slots()
result1 = math.random(1,7)
result1 = result1 - ".0"
result2 = math.random(1,7)
result2 = result2 - ".0"
result3 = math.random(1,7)
result3 = result3 - ".0"
result4 = math.random(1,7)
result4 = result4 - ".0"
result5 = math.random(1,7)
result5 = result5 - ".0"
result6 = math.random(1,7)
result6 = result6 - ".0"
result7 = math.random(1,7)
result7 = result7 - ".0"
result8 = math.random(1,7)
result8 = result8 - ".0"
result9 = math.random(1,7)
result9 = result9 - ".0"
term.setCursorPos(25,5)
mon.clear()
mon.setCursorPos(1,1)
mon.write("*******")
mon.setCursorPos(2,2)
mon.write(result1.."|"..result2.."|"..result3)
mon.setCursorPos(2,3)
mon.write(result4.."|"..result5.."|"..result6)
mon.setCursorPos(2,4)
mon.write(result7.."|"..result8.."|"..result9)
mon.setCursorPos(1,5)
mon.write("*******")
term.setCursorPos(1,3)
print("Debug Info:")
print("Results: "..result1.."|"..result2.."|"..result3)
print(" "..result4.."|"..result5.."|"..result6)
print(" "..result7.."|"..result8.."|"..result9)
if result1 == result2 and result2 == result3 then
print("Row Match, Top Row")
winner()
cpayout = 0
while cpayout < prizeamount do
redstone.setOutput(dispenserside,true)
sleep(0.2)
redstone.setOutput(dispenserside,false)
sleep(0.2)
cpayout = cpayout +1
end
os.reboot()
elseif result4 == result5 and result5 == result6 then
print("Row Match, Middle Row")
winner()
cpayout = 0
while cpayout < prizeamount do
redstone.setOutput(dispenserside,true)
sleep(0.2)
redstone.setOutput(dispenserside,false)
sleep(0.2)
cpayout = cpayout +1
end
os.reboot()
elseif result7 == result8 and result8 == result9 then
print("Row Match, Bottom Row")
winner()
cpayout = 0
while cpayout < prizeamount do
redstone.setOutput(dispenserside,true)
sleep(0.2)
redstone.setOutput(dispenserside,false)
sleep(0.2)
cpayout = cpayout +1
end
os.reboot()
elseif result1 == result5 and result5 == result9 then
print("Diagonal Match From top to bottom.")
winner()
cpayout = 0
while cpayout < prizeamount do
redstone.setOutput(dispenserside,true)
sleep(0.2)
redstone.setOutput(dispenserside,false)
sleep(0.2)
cpayout = cpayout +1
end
os.reboot()
elseif result7 == result5 and result5 == result3 then
print("Diagonal Match From bottom to top.")
winner()
cpayout = 0
while cpayout < prizeamount do
redstone.setOutput(dispenserside,true)
sleep(0.2)
redstone.setOutput(dispenserside,false)
sleep(0.2)
cpayout = cpayout +1
end
os.reboot()
else
print("There was No Match")
if showloser == true then
Loser()
end
sleep(2)
os.reboot()
end
end
local rRunning = true
while rRunning do
sleep(0.5)
local rEvent, param = os.pullEvent()
if rEvent == "redstone" then
if redstone.getInput(detectside) then
if redstone.getInput(detectside) == true then
slots()
else
shell.run("clear",1)
end
end
end
end