This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kazimir's profile picture

[Error] redpulse

Started by Kazimir, 03 September 2012 - 01:40 PM
Kazimir #1
Posted 03 September 2012 - 03:40 PM
I make a roulette.
Program is almost ready, but does not send the signal in the second half of the code.
Help me find a the error.
--------------------------------------------------------------------------
tNum={
[0]=colors.red,
[1]=colors.green,
[2]=colors.purple,
[3]=colors.brown,
[4]=colors.cyan,
[5]=colors.blue,
[6]=colors.lightGray,
[7]=colors.gray,
[8]=colors.yellow,
[9]=colors.pink,
[10]=colors.lightBlue,
[11]=colors.lime,
[12]=colors.magenta}
--------------------------------------------------------------------------
tEvenOdd={
[1]="odd", [2]="even",
[3]="odd", [4]="even",
[5]="odd", [6]="even",
[7]="odd", [8]="even",
[9]="odd", [10]="even",
[11]="odd", [12]="even"}
--------------------------------------------------------------------------
tBlackRed={
[1]="black", [2]="red",
[3]="red", [4]="black",
[5]="black", [6]="red",
[7]="black", [8]="red",
[9]="red", [10]="black",
[11]="black", [12]="red"}
--------------------------------------------------------------------------
rednet.open("top")
term.clear() term.setCursorPos(1,1)
print("Enter the amount of your bet")
local amo = read()
shell.run("redpulse", "left", amo, "0.5")
--------------------------------------------------------------------------
term.clear() term.setCursorPos(1,1)
print("You will be put on the number? [yes/no]")
local sel = read()
--------------------------------------------------------------------------
if sel == "yes" then term.clear() term.setCursorPos(1,1)
  print("Enter the number to which you want to bet [0-12]")
  local iNumb = read()
end
if sel == "no" then term.clear() term.setCursorPos(1,1)
  print("Enter the number to which you want to bet [odd/even, black/red]")
  local sArr = read()
end
term.clear() term.setCursorPos(1,1)
--------------------------------------------------------------------------
local w = math.random(0,12)
term.clear() term.setCursorPos(1,1) print("["..w.."]")
rs.setBundledOutput("back", tNum[w]) sleep(5)
rs.setBundledOutput("back", 0)
--------------------------------------------error somewhere below
if sArr == tEvenOdd[w] then
  if sArr == "odd" then amo = amo*2
  shell.run("redpulse", "bottom", amo, "0.5")
  elseif sArr == "even" then amo = amo*2
  shell.run("redpulse", "bottom", amo, "0.5")
  end
--------------------------------------------------------------------------
elseif sArr == tBlackRed[w] then
  if sArr == "black" then amo = amo*2
  shell.run("redpulse", "bottom", amo, "0.5")
  elseif sArr == "red" then amo = amo*2
  shell.run("redpulse", "bottom", amo, "0.5")
  end
end
--------------------------------------------------------------------------
if iNumb == w then amo = amo*100
shell.run("redpulse", "bottom", amo, "0.5")
end
--------------------------------------------------------------------------

Advance thanks
Magus #2
Posted 03 September 2012 - 04:04 PM
iNumb is a string and w is an integer so iNumb == w is always false.
use tostring or tonumber to convert one of them
Kazimir #3
Posted 03 September 2012 - 05:09 PM
iNumb is a string and w is an integer so iNumb == w is always false.
use tostring or tonumber to convert one of them

I do not work
it seems that the variable "amo" just disappears.
Magus #4
Posted 03 September 2012 - 06:20 PM
amo is defined at in global scope but is declared local
remove local