gmsv_include - Include files with a new function using C++

Due to the highly successful release of gmcl_msg (http://www.facepunch.com/showthread.php?t=928768), I now present to you gmsv_include!

Source:



#include "GMLuaModule.h"

GMOD_MODULE(Open, Close);

ILuaInterface *gLua = NULL;

LUA_FUNCTION( gInclude )
{
	gLua->CheckType(1, GLua::TYPE_STRING);
	
	bool cl = gLua->IsClient();

	if(cl)
	{
		gLua->Msg("BOOM! POW! THIS ADDON IS FOR SERVERSIDE ONLY! BROOOOOOOM!");
		return 0;
	}

	gLua->FindAndRunScript( gLua->GetString(1), true, true );

	return 0;
}

int Open(lua_State *L)
{
	gLua = Lua();

	gLua->SetGlobal("gInclude", gInclude );

	return 0;
}

int Close(lua_State *L)
{
	return 0;
}


Download:

http://solidfiles.com/info_imgs/T9fn.jpg

Enjoy :3

This looks really good could we see some examples of usage

Hello Flawless,

An example for using this module would be:

[lua]
require(“include”)
gInclude(“my_lua/lua_script.lua”)
[/lua]

Thanks

Good its just what I was looking for

Amazing, thanks for adding a function we didn’t have yet.

Could you also compile a linux version of this? Thanks in advance!

Hello AzuiSleet,
There are currently no Linux binaries for Garry’s Mod.
This module will work perfectly under WINE.
Thanks

[editline]03:37PM[/editline]

rated dumb

http://dl.dropbox.com/u/759758/invalidelves.jpg

:iceburn:

Thanks for the module, should help a ton in the future! Rated useful.

Hello AzuiSleet,
Please send me an example of a linux-compatible Garry’s Mod module, and I’ll see what I can do :wink:
Thanks,
Paul

Best module ever!
Very useful.

This is the best thing since the Source engine!

Garry please add this in vanilla Gmod 14.

Can you please make a function to run a console command? I’ve been needing one of those…

I’d love a module that can make cereal come out of my cd drive. Someone made it for GMOD 9 but it doesn’t work anymore :frowning:

[editline]08:29PM[/editline]

rated useful!

Ah, I’ve always wanted to place code from one file into another file at runtime, this will come in as extremely useful to me :slight_smile:

[editline]10:41PM[/editline]

Holy hell, 568 downloads and only 16 posts? Indignant bastards…

Uhh… A troll? WTF is this?
[lua]function gInclude(fn)
if CLIENT then return MsgN(“bullshit”) end
include(fn)
end[/lua]
If someone knows what was in first post before that Lua code - please tell us.

Lua code? In first post?

This Lua code does the same as C++ code in first post. No need for C++.

Stop trolling kna_rus, this is awesome.