General > Developers Corner
calling functions outside of the modules folder
(1/1)
fartrage:
Hi there, so i've been working on a small addon for gmod to make an effective buildmode script.
All has been going fine so far, and i wanted to add support for ulx loggs.
I've ran into a problem where i can't seem to get
--- Code: ---ulx.logWriteln("Player:"..ply:Nick().."changed build mode")
--- End code ---
to work, outside or inside of the modules folder.
For example. i have defined
--- Code: ---function LogBuildMode(ply,bool)
--- End code ---
inside of my "\addons\BuildMode\lua\ulx\modules\sh"
and it is being called in "\addons\BuildMode\BuildMode" with
--- Code: ---LogBuildMode(ply,bool)
--- End code ---
the build mode addon itself is loaded with an include file at "\addons\BuildMode\lua\autorun"
To my knowlege, lua defined functions should be able to be called from different scripts as long as they are not marked as local functions. Is this correct?
if i haven't messed up somewhere, the only thing i can think of is that it would be some kind of load order problem, in which the addon itself is read, but it can't find the function because ulx has not loaded.
I've also tried removing the need to comunicate functions across different scripts by simply adding
--- Code: ---ulx.logWriteln("Player:"..ply:Nick().."changed build mode")
--- End code ---
inside the addon itself outside of the "modules/sh" folder, but that didn't seem to work either.
Is this some kind of scope problem, or some kind of load order problem?
Thanks for any help. :)
Stickly Man!:
It's very likely a load order problem. You should put server-side scripts that rely on ULX (or at least the sections of code you need) in the <your addon>\lua\ulx\modules\ folder, then use the cl\ or sh\ folder for client-side or shared scripts respectively.
Navigation
[0] Message Index
Go to full version