Concommand.Add

I’m learning Lua because I’m a having mappers block.
Now, I used the tutorials on the Garry’s Mod Wiki page.
I combined everything in 1 Lua file because that is the easiest thing for now.

I get this error message when I run my Lua file:



lua	est.lua:11: attempt to index global 'Concommand' (a nil value)


Line 11:
[lua]Concommand.Add(“Number”, whatIsMyNumber)[/lua]

I am trying to call this function:
[lua]function whatIsMyNumber()
print("myNumber is "…myNumber)
end [/lua]

myNumber is changing over the lua file, first value being 0, last value being 10.

Can anyone tell me why it is returning that error?
I think it has something to do with myNumber because I can get a normal message printed in the console.

concommand should be lowercase.

Oh god I feel stupid.
I can remember back in the days at high school where my teacher hammered on that in Java.

Thanks

Clearly he didnt hammer it hard enough

Zing!

You’re also missing!

[lua]function whatIsMyNumber(myNumber)
print("myNumber is "…myNumber)
end [/lua]

not if he uses a var.

Wrong.

he can’t use vars?

If he uses a global variable, it will work perfectly fine without giving it as an argument.

[lua]
] lua_run_cl function whatIsMyNumber(myNumber) print("myNumber is "…myNumber) end whatIsMyNumber(5)
myNumber is 5
] lua_run_cl function whatIsMyNumber() print("myNumber is "…myNumber) end whatIsMyNumber(5)
:1: attempt to concatenate global ‘myNumber’ (a nil value)
] lua_run_cl function whatIsMyNumber() print("myNumber is "…myNumber) end concommand.Add(“Number”, whatIsMyNumber)
] Number 5
:1: attempt to concatenate global ‘myNumber’ (a nil value)

[/lua]

Are you serious…?

How about this:

[lua]
myNumber = 5
function whatIsMyNumber() print("myNumber is "…myNumber) end[/lua]