luaintellij-idealuajavaluaj

Lua Newbie stuck on simple input


I'm trying to pick up Lua programming but I'm stuck on something that's probably trivial. I'm prototyping some Lua scripts using Kahlua from IntelliJ Idea 11 and I keep getting errors whenever I try to use io.read(). Here's what I currently have:

require "io"

print("input:")
a = io.read()        -- read a number
print(a)

When I run it in Idea I get "Tried to call nil at interpreter:1" If I remove the require and the blank line after it I get "input: attempted index of non-table: null at interpreter:2" What am I doing wrong?


Solution

  • Kahula doesn't support the io library.

    Your best bet would be to set up a real Lua SDK, and use the run lua console feature.

    See: http://www.screencast.com/t/0f262SeCKmqT