haskell_loading [with automation]

Hello, I’ve made something awesome. Its going to make your life 100% Easier, and can be used in any situation. Its a simple file loader, this means that you don’t have too type ‘include’ around a billion times, and all your servers files are synced perfectly. I made this because I’m quite lazy when it comes to programming, and with two functions you need to call, and around 4 arguments in total, this game make your life a lot easier.

The syntax like all my classes is very simple, here’s how you load a directory.

    LOAD:UpdateFilesServer(root ,  directory)	
    LOAD:UpdateFilesClient(root,    directory)	
    LOAD:UpdateFilesShared(root,  directory)

Here’s an example.

    LOAD:UpdateFilesServer("gamemodes/garrysurvival/gamemode","server" )	

The ‘root’ folder is your garrysmod/ folder, from here you can navigate to where ever you want, if you want to go to the auto-run folder:-

    LOAD:UpdateFilesServer("lua/autorun","server" )	

The second argument is the directory, this is the folder the class will load into your gamemode.


I really wanted a method on which the server would automatically add the servers to the gamemode with out the need to ‘refresh’ your garrysmod, or do this and that. So here’s the automation part.
If you want to automate your loading process, you need to first use UpdateFilesServer. This will store a Directory to check under a table, then after that you can use this:-


Again, your location has to be the same as your previous UpdateFileServer’s, If you are using multiple locations this will not work ( sorry ). After that you might want to put it in a simple timer, here’s a practical example of this used.

timer.Create( "UpdateTimer", 60, 0, function()
end )

Every 60 seconds, we will check the files for any changes, but this can be lowered, it won’t be that expensive on your resources!


You must not call this in the init.lua, just like an include type this must be called outside any functions, for example.

// Load files
function LoadFiles()
		print("==[START]=[HASKELL LOAD 3.0]=================================")
		print("    >Haskell Loading Script has begun loading correct scripts")
			LOAD:UpdateFilesServer("gamemodes/garrysurvival/gamemode","server" )	

	timer.Create( "UpdateTimer", 60, 0, function()
	end )

LoadFiles() // Call

If you don’t do this, things can break!

To install, you will need to add ‘haskell_load.lua’ into your init.lua, then it can be called from anywhere.

Download: https://www.dropbox.com/s/ya9apdxbl8691pc/haskell_load.lua

Thanks and enjoy! :slight_smile:

Go and work for FP, we need you!

I love automated loading. Anything I work on uses it.

For instance, in my works I have myfolder, with three directories in it: cl sh sv.

This way I can add content without worrying about it any; a script reads the three directories and processes them appropriately.

What you have now works fine with your two functions for updating the server and one for updating the client. I guess what I’m saying is that a general folder layout shell is more useful.

If you’re using this addon, you already plan on having such directories, so why not include them as one no-effort package?

Following this, I’ve added a few new things:-

LOAD:UpdateFilesServer("gamemodes/garrysurvival/gamemode","server" )	
LOAD:UpdateFilesClient("gamemodes/garrysurvival/gamemode","client" )	
LOAD:UpdateFilesShared("gamemodes/garrysurvival/gamemode","shared" )

There you go :slight_smile:

What I mean to say is

[lua]GM.ScriptLoader = {}
function GM.ScriptLoader:LoadFolder(path,realm)
–realm: true=server,false=client,nil=shared
if type(path) != ‘string’ then return end
if !(path[#path] == ‘/’ || path[#path] == ‘’) then path = path…’/’ end
local fs, ds = file.Find(path,‘LUA’)
for k, v in pairs(fs) do
local filepath = string.Explode(’*’,path,false)[1]…v
if SERVER then
if realm || realm == nil then
if !realm then
if !realm then

function GM.ScriptLoader:LoadAll()

Anyone building their addon with automated loading tools will already have cl/sh/sv folders.

Instead of having people download the code to insert the folder loading lines, why not have them download an autorun file+folder to insert into their lua folder that with no other efforts allows new files to be handled?

zip/lua/autoload/cl, etc/sh, etc/sv
zip/lua/autorun/autoloadloader.lua <-- runs the LoadFolder calls

Automated script loading is not something new. Let’s be honest, someone who couldn’t make an automatic script loader is clearly doing something wrong.

here’s a shell if anyone wants it

Rename the file in autorun, open the file and change the name variable to your addon’s name. Rename the youraddonname folder to the same thing as the name variable.

bingo blammo, good to go, all files added to the cl/sh/sv folders don’t need anything to download or include