Hello, i am using pairs loop for a directory, by adding concommand.Add for each one of them and PlayerSay hook to each, I am looking for a way to register my concommands using / searching a string and converting it to a function, i don't like to add PlayerSay hook and concommand.Add to each file, there are around 50 files, (I think it's not but) If it's possible please tell me.
Thanks!
I am not talking about C, I am talking about GMod lua:
[lua]
for k, v in pairs( file.Find("commands/*.lua", "LUA") ) do
include("commands/" .. v)
local name = string.Replace(v, ".lua", "")
concommand.Add(name, name)
if SERVER then
AddCSLuaFile("commands/" .. v)
ASay("Command "..string.Replace(v, ".lua", "").." loaded!")
end
end
[/lua]
That's what i'm talking about, I want to do a function for each file on the pairs, adding concommands or maybe hooking them using their functions, as reminder the function for concommand.Add of each file is equal to name of it without the .lua extension.
For running a basic string:
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1ca2.html[/url]
For what you posted, it seems like you want an autoloading system. What you have should work, as long as the function inside the file is the same name as the file.
[QUOTE=KarmaLord;41483518]For running a basic string:
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1ca2.html[/url]
For what you posted, it seems like you want an autoloading system. What you have should work, as long as the function inside the file is the same name as the file.[/QUOTE]
Facepunch was down, i lost my clipboard copy text but error was:
Can't do the string, it was on concommand.lua line [63] i think.
[editline]17th July 2013[/editline]
Solved by _G, special thanks to skullorz
Sorry, you need to Log In to post a reply to this thread.