Programming Help

Program *********

math.random(0,10) --Generates no. between 0-10. 
variable_one = math.random(0,10) --Tells PC that variable is a random no


local input = nil --The input currently is nothing.

print("Enter a number between 0-10 that you think the computer is thinking of.") 

Io.write("Enter number (0/1/2/3/4/5/6/7/8/9/10)")
Answer=io.read()
If answer = "variable_one" then
   (print("Correct."))
else
    print("You were wrong!")
end

I get the following error message: ‘=’ expected near ‘answer.’
This program is meant to ask the user what number it is thinking of. If the user enters the correct value, then the program prints “Correct” and the program ends. This is my first attempt at my own program based on looking at YouTube tutorials.

hey @noobprogrammer you cant use io.* modules in Codea till 1.5 is released, for what your trying to do you can get the app Coders which is similar to Codea but with no where near as many Functions (Features) but it will still give you the ability to create Graphical input.
Touch Lua can also take in io.read statements but the app is directed towards i(pod/phone) and the final solution is SimplyLua which is confusing at first but does exactly what you need, no more no less, its a full featured lua interpreter with the ability to create lua files to run in the console.

If However for some reason Codea is your only option, you’ll have to settle with Programming on your computer for a little while, when you learn enough concepts you can come back to Codea in put in a text box that the user can interact with to play the game.

Finally you could get the Pythonista app and learn python instead so that you could use the knowledge you gain from tutorials directly in your game.

p.s. The Error message was telling you that you needed to have formatted your if loop like this: if answer == "variable_one" then --whatever you want

p.p.s use the tilde symbol ~ three times to tell the website that some text is actually code i.e.

~~-
replace the - with a tilde
~~-

p.p.p.s i fixed up your code a little

math.random(0,10) 
variable_one = math.random(0,10) --Tells PC that variable is a random no

local input = nil --The input currently is nothing.

print("Enter a number between 0-10 that you think the computer is thinking of.")

io.write("Enter number (0/1/2/3/4/5/6/7/8/9/10)") 
Answer=io.read() 

if answer == variable_one then 
    print("Correct.")
else 
    print("You were wrong!") 
end

p.p.p.p.s
if you need anymore help you can email (or imessage) me @ senam@y7mail.com

edit: already answered

Zahlenraten

Zahlenraten




-- Zahlenraten

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    print("Enter a number from 0 to 10")
    iparameter("a",1,10)
    backingMode(RETAINED)
    n=0
    m=0
end

-- This function gets called once every frame
function draw()
    -- This sets the line thickness
    strokeWidth(5)
    fontSize(40)
    -- Do your drawing here
  
    text("You guessed it",200,600)
    text("You guessed wrong",200,500)
    text("Cick on the page",200, 200)
end

function touched(touch)
    if touch.state == BEGAN then
        background(40,40,50)
        c = tonumber(a)
        b = math.random(1,10)
          if (c == b) then
            n=n+1
          else
            m=m+1
          end
    text("iPad Number = ".. b, 200, 400)
    text("Your Number = ".. c, 200, 300)   
    text(m,500,500)
    text(n,500,600)
  end
end