• Project SourceLua
    130 replies, posted
[url=http://hl2sb.googlecode.com/svn/trunk/serverplugin_lua/][img]http://hl2sb.googlecode.com/files/Project%20SourceLua%20Title%20Logo%2060%20pt.png[/img][/url] :science: [b]LUA? IN TF2? LUA? IN CS:S?[/b] [media]http://www.youtube.com/watch?v=C_VheAwZBuQ[/media] Hey guys, does anyone remember Alexander's [url=http://www.overvprojects.nl/?p=13]SourceScript[/url]? It's a dead project now, however I'm working on a replacement project that's already making slow but solid progress, and has been acknowledged by Overv himself. SourceLua is a plugin designed to allow for fast development on the Source Engine, across all games. Core objects such as CBaseEntity, CBasePlayer, CBaseCombatWeapon, and Vector and QAngle have already been implemented from it's derived project. I'm here to ask you guys a question: What functions and methods should I sigscan for to give us more flexibility? What hooks? Currently available hooks: [lua]Unload() Pause() UnPause() LevelInit( string pMapName ) GameFrame( bool simulating ) LevelShutdown() ClientActive( CBasePlayer pPlayer ) ClientDisconnect( CBasePlayer pPlayer ) ClientPutInServer( CBasePlayer pPlayer, string playername ) ClientSettingsChanged( CBasePlayer pPlayer ) ClientConnect( CBasePlayer pPlayer, string pszName, string pszAddress, bool reject, int maxrejectlen ) NetworkIDValidated( string pszUserName, string pszNetworkID ) OnEdictAllocated( CBaseEntity pEntity ) [/lua] Currently available objects and methods: [lua]CBaseCombatWeapon.__metatable() CBaseCombatWeapon.__tostring() CBaseCombatWeapon.__index() CBaseEntity.IsAlive() CBaseEntity.SetAbsOrigin() CBaseEntity.__index() CBaseEntity.SetModel() CBaseEntity.__tostring() CBasePlayer.GetUserID() CBasePlayer.GetActiveWeapon() CBasePlayer.__tostring() CBasePlayer.__metatable() CBasePlayer.__index() CBasePlayer.GiveNamedItem() Color.SetRawColor() Color.r() Color.g() Color.b() Color.__eq() Color.__tostring() Color.GetColor() Color.GetRawColor() Color.a() Color.__index() Color.SetColor() ConVar.__index() ConVar.__tostring() ConVar.GetMax() ConVar.Revert() ConVar.IsRegistered() ConVar.IsCommand() ConVar.GetInt() ConVar.GetString() ConVar.IsFlagSet() ConVar.GetFloat() ConVar.GetName() ConVar.GetBool() ConVar.GetMin() ConVar.GetDefault() ConVar.GetHelpText() ConVar.AddFlags() QAngle.IsValid() QAngle.LengthSqr() QAngle.Init() QAngle.__metatable() QAngle.Invalidate() QAngle.__add() QAngle.__div() QAngle.__mul() QAngle.__sub() QAngle.__eq() QAngle.Length() QAngle.__index() QAngle.__tostring() Vector.Length2DSqr Vector.LengthSqr Vector.__eq Vector.DistToSqr Vector.Invalidate Vector.DistTo Vector.IsLengthLessThan Vector.Negate Vector.Dot Vector.Length Vector.Random Vector.__add Vector.WithinAABox Vector.IsValid Vector.Zero Vector.IsLengthGreaterThan Vector.Max Vector.__metatable Vector.__mul Vector.NormalizeInPlace Vector.Length2D Vector.__div Vector.__tostring Vector.Cross Vector.__index Vector.MulAdd Vector.__sub Vector.Min [/lua] Currently available global functions: [lua]Color() ConColorMsg() ConDColorMsg() ConDLog() ConDMsg() ConDWarning() ConLog() ConMsg() ConWarning() CreateEntityByName() DLog() DMsg() DWarning() DevLog() DevMsg() DevWarning() DispatchSpawn() Error() IsSpewActive() Log() Msg() NetLog() NetMsg() NetWarning() QAngle() SpewActivate() UTIL_ClientPrintAll() UTIL_PlayerByIndex() UTIL_Remove() Vector() Warning() assert() collectgarbage() dofile() error() gcinfo() getfenv() getmetatable() ipairs() load() loadfile() loadstring() module() newproxy() next() pairs() pcall() print() rawequal() rawget() rawset() require() select() setfenv() setmetatable() tonumber() tostring() type() unpack() xpcall() [/lua] Screenshots: [IMG]http://i944.photobucket.com/albums/ad281/andrewmcwatters/Half-Life%202%20Sandbox/snapshot0001-3.jpg[/IMG] [IMG]http://i944.photobucket.com/albums/ad281/andrewmcwatters/Half-Life%202%20Sandbox/cp_legoblast_20120001.jpg[/IMG] [IMG]http://i944.photobucket.com/albums/ad281/andrewmcwatters/Half-Life%202%20Sandbox/ctf_2fort0002.jpg[/IMG]
A bit more information would help. Across all games doesn't explain much. You could include information form the website.
[QUOTE=Aide;23006978]A bit more information would help. Across all games doesn't explain much. You could include information form the website.[/QUOTE] I don't understand what you mean. Across all games == across all games. It's like Lua meets SourceMod and MetaMod: Source.
Lua scripting language for all source engine games?
It looks pretty good, although I would suggest [url=http://hl2sb.googlecode.com/svn/trunk/serverplugin_lua/lua/includes/modules/hook.lua]following your own style guide[/url] (:v:). Also, creating 10 locals in hook.Call, which gets called often isn't a good practice (assuming you're going to have a Tick hook or something similar). Instead of r1-r8 you should use one table defined outside the function. [lua]ret = { pcall( v, ... ) } bError = ret[1] table.remove( ret, 1 )[/lua] [editline]07:20PM[/editline] [QUOTE=Aide;23007093]Lua scripting language for all source engine games?[/QUOTE] Yes, although server-side only.
Is this anything like LSS?
[QUOTE=raBBish;23007118]It looks pretty good, although I would suggest [url=http://hl2sb.googlecode.com/svn/trunk/serverplugin_lua/lua/includes/modules/hook.lua]following your own style guide[/url] (:v:). Also, creating 10 locals in hook.Call, which gets called often isn't a good practice (assuming you're going to have a Tick hook or something similar). Instead of r1-r8 you should use one table defined outside the function. [lua]ret = { pcall( v, ... ) } bError = ret[1] table.remove( ret, 1 )[/lua] [/QUOTE] It's funny that I don't follow it, thanks for the heads up. Could you explain the issue with the multiple values? Additionally, could you show me where this would be implemented? I apologize, I haven't looked at the hook module in a while now. [editline]09:30AM[/editline] [QUOTE=Shadow187(FP);23007137]Is this anything like LSS?[/QUOTE] I have heard of this before, but I don't know anything about it. [editline]09:32AM[/editline] The reason I ask is mainly because you state, "outside of the function". Which I don't understand why. I'll easily replace the code so it's more efficient, though. I'm just ignorant as to what you fully mean. Give me a moment, and I'll try and replicate what I think you mean. [highlight](User was banned for this post ("Wrong section (moved)" - SteveUK))[/highlight]
That logo sets my OCD trigger off.
[QUOTE=Dlaor;23007414]That logo sets my OCD trigger off.[/QUOTE] As in, you can tell I have OCD? Or...? [editline]09:38AM[/editline] Revised hook.lua: [lua]--========== Copyleft © 2010, Team Sandbox, Some rights reserved. ===========-- -- -- Purpose: Hook implementation. -- --===========================================================================-- local pairs = pairs local Warning = Warning local tostring = tostring local pcall = pcall module( "hook" ) local bError, r1, r2, r3, r4, r5, r6, r7, r8 local tHooks = {} ------------------------------------------------------------------------------- -- Purpose: Adds a hook to the given GameRules function -- Input : strEventName - Name of the internal GameRules method -- strHookName - Name of the hook -- pFn - pointer to function -- Output : ------------------------------------------------------------------------------- function Add( strEventName, strHookName, pFn ) tHooks[ strEventName ] = tHooks[ strEventName ] or {} tHooks[ strEventName ][ strHookName ] = pFn end ------------------------------------------------------------------------------- -- Purpose: Called by the engine to call a GameRules hook -- Input : strEventName - Name of the internal GameRules method -- Output : ------------------------------------------------------------------------------- function Call( strEventName, ... ) local tHooks = tHooks[ strEventName ] if ( tHooks ~= nil ) then for k, v in pairs( tHooks ) do if ( v == nil ) then Warning( "Hook '" .. tostring( k ) .. "' tried to call a nil function!\n" ) tHooks[ k ] = nil break else bError, r1, r2, r3, r4, r5, r6, r7, r8 = pcall( v, ... ) if ( bError == false ) then Warning( "Hook '" .. tostring( k ) .. "' (" .. tostring( strEventName ) .. ") Failed: " .. tostring( r1 ) .. "\n" ) tHooks[ k ] = nil else if ( r1 ~= nil ) then return r1, r2, r3, r4, r5, r6, r7, r8 end end end end end return r1, r2, r3, r4, r5, r6, r7, r8 end ------------------------------------------------------------------------------- -- Purpose: Returns all of the registered hooks or only hooks pertaining to a -- specific event -- Input : strEventName - Name of the internal GameRules method -- Output : table ------------------------------------------------------------------------------- function GetHooks( strEventName ) if ( strEventName ) then return tHooks[ strEventName ] end return tHooks end ------------------------------------------------------------------------------- -- Purpose: Removes a hook from the list of registered hooks -- Input : strEventName - Name of the internal GameRules method -- strHookName - Name of the hook -- Output : ------------------------------------------------------------------------------- function Remove( strEventName, strHookName ) tHooks[ strEventName ][ strHookName ] = nil end [/lua] [editline]09:40AM[/editline] Wait a moment, I foresee a problem. tHooks is being redefined in the call function as the table of hooks for said event. When attempting to remove a hook with an error, won't this improperly disengage the hook? [editline]09:41AM[/editline] [QUOTE=raBBish;23007118]It looks pretty good, although I would suggest [url=http://hl2sb.googlecode.com/svn/trunk/serverplugin_lua/lua/includes/modules/hook.lua]following your own style guide[/url] (:v:).[/QUOTE] Wait a moment, what part of the style guide am I not following? [editline]09:49AM[/editline] Updating file above to indicate changes made.
[lua]local bError, tRet, tHooksTemp function Call( strEventName, ... ) tHooksTemp = tHooks[ strEventName ] tRet = {} if ( tHooksTemp ~= nil ) then for k, v in pairs( tHooksTemp ) do if ( v == nil ) then Warning( "Hook '" .. tostring( k ) .. "' tried to call a nil function!\n" ) tHooksTemp[ k ] = nil break else tRet = { pcall( v, ... ) } bError = tRet[1] table.remove( tRet, 1 ) if ( bError == false ) then Warning( "Hook '" .. tostring( k ) .. "' (" .. tostring( strEventName ) .. ") Failed: " .. tostring( r1 ) .. "\n" ) tHooksTemp[ k ] = nil else if ( tRet[1] ~= nil ) then return unpack( tRet ) end end end end end return unpack( tRet ) end[/lua] Declaring the variables like that stops the garbage collector from freaking out. I don't really know how the internals work, so I hope someone else could give a better explanation. Basically you'd create 10 locals every frame, which would go out of scope when Call returns. The GC takes much performance, so every time it would collect the out-of-scope locals, which results in server performance drops. With the variables declared outside the function, they won't go out of scope when the function returns, so the GC doesn't need to collect them. This leads to better performance. [editline]07:51PM[/editline] [QUOTE=amcwatters;23007481]Wait a moment, what part of the style guide am I not following?[/QUOTE] You were mixing both normal tabs and the two-spaces style.
[QUOTE=raBBish;23007740]Declaring the variables like that stops the garbage collector from freaking out. ... Basically you'd create 10 locals every frame, which would go out of scope when Call returns. ... With the variables declared outside the function, they won't go out of scope when the function returns, so the GC doesn't need to collect them. This leads to better performance. [editline]07:51PM[/editline] You were mixing both normal tabs and the two-spaces style.[/QUOTE] Oh thanks, I didn't know about that. I work with the internals, but I don't know much in respect to the GC. The tab thing is an issue with N++. I just don't go back and correct it. I have OCD, but my OCD says it's better to conform to what N++ does, even if it's problematic, so the results are always the same.
Excuse me for not reading thread or for being misinformed, but what I'm getting from this is that you're making Lua libraries for all source games? i.e. using SourceLua, Lua in CS:S and TF2 would be possible?
[QUOTE=Kopimi;23008160]Excuse me for not reading thread or for being misinformed, but what I'm getting from this is that you're making Lua libraries for all source games? i.e. using SourceLua, Lua in CS:S and TF2 would be possible?[/QUOTE] Yes, but only server-side, like with SourceMod too.
[img]http://i944.photobucket.com/albums/ad281/andrewmcwatters/Half-Life%202%20Sandbox/ctf_2fort0002.jpg[/img] Nah, I just used magical powers to do this.
[QUOTE=raBBish;23008173]Yes, but only server-side, like with SourceMod too.[/QUOTE] Are you saying that the code is only executable serverside or that only serverside controls will be enabled? In other words, will you be able to call code on the client FROM the server, so you can draw HUDs and things like that, or will you only be able to call serverside code?
You do realize this is going to lead to "hw 2 intalz gmod adon in css" spam. Oh well, it looks interesting all the same. I can think of some source mods that would benefit from lua. Although it's probably not much good unless you can hook into specific game systems (for example, in the Empires sourcemod, there'd need to be a way to see if a specific research was complete or not).
[QUOTE=Kopimi;23008262]Are you saying that the code is only executable serverside or that only serverside controls will be enabled? In other words, will you be able to call code on the client FROM the server, so you can draw HUDs and things like that, or will you only be able to call serverside code?[/QUOTE] Server only stuff, I suppose somehow it would be possible to do stuff to clients to some degree, but I'm too scared to play with my account. I don't know much about sigscanning + client binaries + VAC. Infact, I'm so paranoid, I've done all of these tests with -insecure, regardless of it all being server-side only. [editline]10:18AM[/editline] [QUOTE=thomasfn;23008280]You do realize this is going to lead to "hw 2 intalz gmod adon in css" spam. Oh well, it looks interesting all the same. I can think of some source mods that would benefit from lua. Although it's probably not much good unless you can hook into specific game systems (for example, in the Empires sourcemod, there'd need to be a way to see if a specific research was complete or not).[/QUOTE] Totally. But basically, it would open up more opportunities than SourcePawn. Mainly being that people don't want to learn it, or don't care to, unless they really need something taken care of.
[QUOTE=amcwatters;23008312]Server only stuff, I suppose somehow it would be possible to do stuff to clients to some degree, but I'm too scared to play with my account. I don't know much about sigscanning + client binaries + VAC. Infact, I'm so paranoid, I've done all of these tests with -insecure, regardless of it all being server-side only.[/QUOTE] For client-side stuff, there's of course [url=http://3rdera.com/]LSS[/url], posted earlier in this thread. [editline]08:19PM[/editline] [QUOTE=amcwatters;23008312]Totally. But basically, it would open up more opportunities than SourcePawn. Mainly being that people don't want to learn it, or don't care to, unless they really need something taken care of.[/QUOTE] Also, I'm going to :love: you if you manage to pull this off properly. I despise SourcePawn but I'm forced to use it in order to keep my Zombie Master servers alive... :sigh:
Isn't that potentially dangerous? I mean, come on, anyone with a brain realizes this has to hook into client and shared code.
[QUOTE=amcwatters;23008380]Isn't that potentially dangerous? I mean, come on, anyone with a brain realizes this has to hook into client and shared code.[/QUOTE] Well, it seems to be in Valve's plugin format, so I doubt it can get you banned yet at least. The SourceMod exploit (loading it client-side) uses the same trick, and nobody's been banned for that (except manually).
I'll try my hardest. Project SourceLua is derived from Half-Life 2: Sandbox code, so any updates from there should trickle down. [editline]10:24AM[/editline] [QUOTE=raBBish;23008428]Well, it seems to be in Valve's plugin format, so I doubt it can get you banned yet at least. The SourceMod exploit (loading it client-side) uses the same trick, and nobody's been banned for that (except manually).[/QUOTE] Hmm. Personally, I'm not big on the security level involved with signature scanning at all. It's really fishy. I mean, anyone could port the signatures to replicate mechanics behind GMod aimbots, so why is this an exception? Just my two cents.
[QUOTE=amcwatters;23008431]I'll try my hardest. Project SourceLua is derived from Half-Life 2: Sandbox code, so any updates from there should trickle down.[/QUOTE] Have you considered contacting Valve? As stupid as this seems, you ARE making a heavy modification to the game I doubt they've foreseen. I'm not saying you should be afraid of releasing or continuing your work, but you may as well write a quick email explaining the project and its reach, surprisingly large corporations like Valve actually do respond.
[QUOTE=raBBish;23008344]Also, I'm going to :love: you if you manage to pull this off properly. I despise SourcePawn but I'm forced to use it in order to keep my Zombie Master servers alive... :sigh:[/QUOTE] I hate that, I'm right there with you, bud. [editline]10:27AM[/editline] [QUOTE=Kopimi;23008501]Have you considered contacting Valve? As stupid as this seems, you ARE making a heavy modification to the game I doubt they've foreseen. I'm not saying you should be afraid of releasing or continuing your work, but you may as well write a quick email explaining the project and its reach, surprisingly large corporations like Valve actually do respond.[/QUOTE] I was actually going to talk to Valve employees about the controversy that could easily arise as a result of Half-Life 2: Sandbox, but not about this. Obviously my priorities are wrong here. I shall make it a plan to do so, thank you friend.
[QUOTE=amcwatters;23008515]I hate that, I'm right there with you, bud. [editline]10:27AM[/editline] I was actually going to talk to Valve employees about the controversy that could easily arise as a result of Half-Life 2: Sandbox, but not about this. Obviously my priorities are wrong here. I shall make it a plan to do so, thank you friend.[/QUOTE] No problem :smile: Also, I'm not sure what methods you use to work on this project and what help you may need, but I know my way around GLua and was about to give up (Because I really havent got anything I'm interested in making) until I saw this, I've also got the fundamentals of C++, mainly syntax and all that good stuff, so if you need help with someone proficient in GLua who can manage in C++, let me know and I'd be happy to help an interesting and promising project.
[QUOTE=Kopimi;23008678]No problem :smile: Also, I'm not sure what methods you use to work on this project and what help you may need, but I know my way around GLua and was about to give up (Because I really havent got anything I'm interested in making) until I saw this, I've also got the fundamentals of C++, mainly syntax and all that good stuff, so if you need help with someone proficient in GLua who can manage in C++, let me know and I'd be happy to help an interesting and promising project.[/QUOTE] Team Sandbox needs developers, since I'm the only one fooling around with HL2SB and SL. We're a small group. If you know GLua stuff, then it won't be hard at all. The most fun is in the HL2SB branch of the project, but the most satisfying results are as seen above, in the SL branch. Oh, by the way, I checked out SLL or whatever it's called, and it looks like a neat plugin for 1337|-|4<k3r5 to bh0p.
[QUOTE=amcwatters;23008786]Team Sandbox needs developers, since I'm the only one fooling around with HL2SB and SL. We're a small group. If you know GLua stuff, then it won't be hard at all. The most fun is in the HL2SB branch of the project, but the most satisfying results are as seen above, in the SL branch. Oh, by the way, I checked out SLL or whatever it's called, and it looks like a neat plugin for 1337|-|4<k3r5 to bh0p.[/QUOTE] Where do I sign up? :3:
If you've got a gmail account, send it to me, and I'll add you to the contributers list. We have a twitter, facebook, and Steam group, besides the Google Code site. And our lacking wiki is called "Sandboxia". [url]http://hl2sb.andrewmcwatters.com/wiki/index.php/Main_Page[/url] [url]http://steamcommunity.com/groups/HL2SB[/url] [url]http://twitter.com/HL2SB[/url] [url]http://www.facebook.com/pages/Half-Life-2-Sandbox/116552271697734[/url] [editline]10:41AM[/editline] You should add me to Steam friends as well. <3
You're right about hooking to the equivalent of the current Lua bindings and being able to recreate a Lua aimbot. Not something I'd take risks with personally.
[QUOTE=amcwatters;23008934]If you've got a gmail account, send it to me, and I'll add you to the contributers list. We have a twitter, facebook, and Steam group, besides the Google Code site. And our lacking wiki is called "Sandboxia". [url]http://hl2sb.andrewmcwatters.com/wiki/index.php/Main_Page[/url] [url]http://steamcommunity.com/groups/HL2SB[/url] [url]http://twitter.com/HL2SB[/url] [url]http://www.facebook.com/pages/Half-Life-2-Sandbox/116552271697734[/url] [editline]10:41AM[/editline] You should add me to Steam friends as well. <3[/QUOTE] Will do that as soon as my Facebook stops redirecting to that stupid weaboo kid's MySpace and when Steam comes back online for me. :sigh:
[QUOTE=|FlapJack|;23008999]You're right about hooking to the equivalent of the current Lua bindings and being able to recreate a Lua aimbot. Not something I'd take risks with personally.[/QUOTE] Yeah, I don't quite understand why someone would take the liberty of creating a client-side VSP especially if it uses memory straight out of the game. This = cheat + VSP structure. That's all it is. [editline]10:45AM[/editline] I suppose a developer decision here is for the plugin to never interface with the client binaries then. [editline]10:46AM[/editline] Cool, I made a friend today. :krad2:
Sorry, you need to Log In to post a reply to this thread.