Calling a function from another file

How would I go about calling a function from another file?

From my init.lua I have a command Check(ply) that references Info(ply) in cl_init.lua. How would I call that properly, seeing as just doing
[lua]function check(ply)
info(ply)
if returnedvalue1 == returnedvalue2 then
–Run code here
else
–Run code here
end
end[/lua]
Does not want to work. (info(ply) sends a derma input with 2 things to input, returning them as “return returnedvalue1, returnedvalue2”)

Normally calling a function from another file is fine since they’re global. eg

lolprint.lua
[lua]
function a(myarg)
return myarg * 2
end
[/lua]

loldie.lua
[lua]
function doubled(num)
print(a(num))
end
[/lua]

That would work fine and calling doubled(num) would print the double of what you passed as an argument. But init.lua and cl_init.lua are running on different machines. So the info function never existed on the server.

You’d have to make the server function first send a command to the player telling his client machine to open the menu. Then make the submit button send another command from the client to the server (sending the text box (?) content as arguments) which the server will handle.

Basically you can’t call functions that only exist on the other side of the client-server line.

Generally if you want to access functions from another file, at the top of the file you use:


include( 'filename.lua' )

No you don’t, that includes the file in the current Lua state - for example, the game environment or menu environment

What? It can function to access tables and functions from other files…

include just runs the file doesn’t it.

including a file with a local function or variable in it doesn’t give you access to that function or variable. It’s not like some other languages’ include where it’s like you copypasted the code where the include is.