I tried required('luascript.lua') in an attempt to call another function from said script to my current script, but it's not going over very well (by very well; not calling at all)
instead it gives me the error that 'it cannot find said module', which is what I'm guessing I do not want to be using required() for
is there a way to do this? I can't find anything on the wiki on it and it'd be extremely useful
essentially OOP in lua
Make sure the function is global in the other file then do include("path")
ah OK cool it worked, seemed simple enough i thought include() would immediately execute the code once called which is why i was a bit hesitant to use it
[QUOTE=techtuts0;32684598]Make sure the function is global in the other file then do include("path")[/QUOTE]
Your also forgetting this:
Local function() = A function that can only be called from a script and an other scripts linked to it via the include function.
function() = A function that can be called from any script even if its not linked via the include function.
Exmaple:
// This can only be called from the file its located in and any other linked files via the include function //
local function firethelazor( ent )
ent:fire()
end
// This can be called from any script even if they are not linked to the script. //
function firethelazor( ent )
ent:fire()
end
Also keep in mind that's its good practice to add local to the start of any function your not going to be using outside the script.
[QUOTE=ayre10;32744834]Your also forgetting this:
Local function() = A function that can only be called from a script and an other scripts linked to it via the include function.
function() = A function that can be called from any script even if its not linked via the include function.
Exmaple:
// This can only be called from the file its located in and any other linked files via the include function //
local function firethelazor( ent )
ent:fire()
end
// This can be called from any script even if they are not linked to the script. //
function firethelazor( ent )
ent:fire()
end
Also keep in mind that's its good practice to add local to the start of any function your not going to be using outside the script.[/QUOTE]
That's called scoping, it goes beyond that.
Sorry, you need to Log In to post a reply to this thread.