Posted 29 December 2013 - 03:27 AM
I'm helping a guy on this one server I play on make a slots machine using the monitor peripherals. my only problem is that if a player right-clicks twice on the monitor, it returns, "slot :42: Expected number." If you only right-click once, it works fine, so how would I ignore the player interaction until the program is done doing its thing? Code.
The part in specific that I'm having troubles with is line 19
Any help would be greatly appreciated. = ^_^/>=
--Finding the monitor side
local side=nil
for r,s in pairs(rs.getSides()) do
if peripheral.getType(s)=='monitor' then
side=s
break
end
end
--Wrapping the peripheral and setting up defaults
local m = peripheral.wrap(side)
m.setBackgroundColor(colors.black)
m.clear()
m.setTextScale(1)
m.setCursorPos(1,1)
m.setTextColor(colors.yellow)
m.write("SLOTS")
--Playing the game
while true do
if os.pullEvent()=='monitor_touch' then
--Spinner 1
local sponge1=nil
local number1 = math.random(1, 6)
if number1 == 1 then
sponge1 = colors.yellow
elseif number1 == 2 then
sponge1 = colors.green
elseif number1 == 3 then
sponge1 = colors.blue
elseif number1 == 4 then
sponge1 = colors.violet
elseif number1 == 5 then
sponge1 = colors.red
elseif number1 == 6 then
sponge1 = colors.orange
end
function slot1(x1,y1,x2,y2,color1)
x1,y1,x2,y2 = 1,2,2,2
for i = x1,x2 do
for o = y1,y2 do
color1 = sponge1
m.setCursorPos(i,o)
m.setBackgroundColor(color1)
m.write(" ")
end
end
end
if number1==1 then
slot1(x1,y1,x2,y2,color1)
elseif number1==2 then
slot1(x1,y1,x2,y2,color1)
elseif number1==3 then
slot1(x1,y1,x2,y2,color1)
elseif number1==4 then
slot1(x1,y1,x2,y2,color1)
elseif number1==5 then
slot1(x1,y1,x2,y2,color1)
elseif number1==6 then
slot1(x1.y1.x2.y2.color1)
end
end
end
The part in specific that I'm having troubles with is line 19
if os.pullEvent()=='monitor_touch' then
Any help would be greatly appreciated. = ^_^/>=
Edited on 29 December 2013 - 03:03 AM