GoldenEye: Source Forums

Debriefing => Questions, Help, & How To's => Topic started by: Mark [lodle] on February 10, 2009, 03:57:15 pm

Title: Read Me
Post by: Mark [lodle] on February 10, 2009, 03:57:15 pm
With the beta 3.1 patch coming up i have added some extra functions to allow more customization of gameplays.

You can find information on making new game plays here: http://wiki.goldeneyesource.net/index.php/Category:Lua and we will be constantly adding to that as the patches roll.

Feel free to discuss gameplay ideas and scripts you are working in this board (in a new thread please) and add any function requests here.
Title: Re: Read Me
Post by: mookie on February 10, 2009, 07:58:21 pm
Are the existing gamemodes written in LUA, and if so, could you post the complete script for one of them as an example?
Title: Re: Read Me
Post by: Mark [lodle] on February 10, 2009, 11:07:05 pm
Yes they are, i will be putting up the gungame one i wrote today as and example and have a bit more detail about it.
Title: Re: Read Me
Post by: Mark [lodle] on February 11, 2009, 12:13:41 am
Example has been added.
Title: Re: Read Me
Post by: keefy on February 11, 2009, 12:46:45 am
Cool so gungame needs no seperate plugins to work?
How does it work in CS:S does that need seperate plugins to work?
Title: Re: Read Me
Post by: Mark [lodle] on February 11, 2009, 12:54:51 am
gungame is a native script except it needs the new patch to work. Css gun game needs a plugin that scans css for function to work where as we code the functions directly into the game.
Title: Re: Read Me
Post by: stig on March 21, 2009, 03:14:12 pm
Is there a chance you guys can add a CallBack named PlayerHurt?
I think you know when it's going to be fired :P
Title: Re: Read Me
Post by: VC on March 21, 2009, 03:25:11 pm
You can handle damage events using ShouldDoCustomDamage.
Title: Re: Read Me
Post by: stig on March 21, 2009, 10:47:15 pm
Thanks, how about function named GetPlayerSteamid ?
Title: Re: Read Me
Post by: VC on March 21, 2009, 10:54:13 pm
How about not writing scenarios that give specific celebrities different powers. : )
Title: Re: Read Me
Post by: stig on March 21, 2009, 11:10:19 pm
it's for my rpgmod
Title: Re: Read Me
Post by: Mark [lodle] on March 21, 2009, 11:22:34 pm
There is a function that gets a players hash which is unique per player.

Edit: I coded a function to do it, not sure if it made the release as im in the states and dont have the source code.
Title: Re: Read Me
Post by: stig on March 21, 2009, 11:26:11 pm
PlayerGUID ?
Title: Re: Read Me
Post by: VC on March 21, 2009, 11:33:08 pm
RPG mod...

Please make it fun and not stupid.  I've seen a few for CSS and they were absurdly stupid.  However, there is one for Zombie Panic Source that was actually really awesome.  You couldn't get so ubered up that the game wasn't fun, but it was enough that you paid attention to who was playing because you knew certain guys had a lot of levels and knew how to use them so you would work with your teammates (or fellow dead-heads) and make a plan to handle them.  And sometimes you'd get the epic rounds where one guy (me) would be all alone with nothing but speed buffs, a magnum, and ammo-recovery to my name, leading the horde around the map twice and taking all their tickets away one at a time for the most jaw-dropping player victory ever.

On that note, I don't know really what you can do for an RPG mod in GES.  In Live and Let Die, the only things I could think of giving were weapons, which only mattered because the Baron can't pick up weapons in the world, and damage buffing, which was simply based on the Goldeneye 007 handicap scale.  There really aren't any other things to adjust, other than Speed, Agility, Spawn Armored, and...  and I'm out of ideas.
Title: Re: Read Me
Post by: Mark [lodle] on March 21, 2009, 11:37:46 pm
PlayerGUID ?

Thats the one
Title: Re: Read Me
Post by: Slinky on July 19, 2009, 04:28:02 am
Hi, what's the working directory for running lua scripts?  I'm trying to put some reusable logic into a separate script so I can use it for later game types.  Unfortunately, no matter where I put the included file, when I try to use, "dofile(gamecycle.lua)" to include it, I get a message in the console saying that there is no such file or directory as gamecycle.lua.  Is there any solution for this?
Title: Re: Read Me
Post by: Mark [lodle] on July 19, 2009, 07:42:18 am
i dont think we support that as i have never had to use it. If you show me your script i can debug it and make it work. :P
Title: Re: Read Me
Post by: Slinky on July 19, 2009, 05:14:56 pm
The script was pretty simple because I was just trying to get this working before stepping into the whole thing:

In eliminatio.lua:
Code: [Select]
dofile("gamecycle.lua");

function Think()
   TestFunc();
end

In gamecycle.lua:
Code: [Select]
function TestFunc();
   ClientPrintAll(HUD_PRINTCENTER, "TEST");
end
Title: Re: Read Me
Post by: Mark [lodle] on July 19, 2009, 06:47:09 pm
Ill give it ago tomorrow.
Title: Re: Read Me
Post by: killermonkey on July 19, 2009, 11:40:50 pm
Try using loadfile(filename)

Make sure the file is in the same directory as the current LUA script. If this doesn't work, try putting the lua file that you want to load in:

....\steam\steamapps\_STEAMNAME_\Source SDK Base 2007\  just for shits and giggles and see if it loads...

Then try putting it in the base directory of the mod (gesource) and try it again. The thing I am trying to get you to test is to see where the entry point of loading files is located. Since we bind LUA to source there are MANY entry points, I am not sure that we define any specific directory as a load point and there is no documentation on dofile or loadfile that describes how LUA handles the entry point...
Title: Re: Read Me
Post by: Slinky on July 20, 2009, 05:05:22 am
With gamecycle.lua and elminatio.lua int he same directory, and using dofile(), I get that error.  However, when I change it to loadfile(), I no longer get a "no such file or directory" error.  However:

Previously when Think() ran, it said that it had a problem trying to call a nil value, with no additional details.
Now it throws an error when calling think():  'attempt to call global TestFunc: a nil value'.  So that says to me that loadfile() may still be failing, but silently.  This happens when gamecycle.lua is in the other two directories you named as well.

Title: Re: Read Me
Post by: Slinky on July 20, 2009, 05:11:23 am
I've just verified- I removed gamecycle.lua from my steam folders completely and it's still doing the same thing, so probably not reading gamecycle.lua successfully.
Title: Re: Read Me
Post by: Slinky on August 01, 2009, 08:19:09 pm
Was there ever an answer discovered for this?
Title: Re: Read Me
Post by: killermonkey on August 02, 2009, 01:19:51 pm
Awesome, here's a reference i just found:

http://www.lua.org/pil/8.1.html

It uses the LUA command require <filename>, where require actually lets you specify a path to search on.

You can set that path by setting the global variable: LUA_PATH to a string and thats it.

I have added direct support for this newly found feature in Beta 4 where the LUA_PATH global variable will be defined based on the full path to gesource/scripts/gameplay  so future use of "require" will be meaningful without declaring your own variable
Title: Re: Read Me
Post by: Slinky on August 02, 2009, 05:46:44 pm
Awesome, thank you.
Title: Re: Read Me
Post by: Slinky on August 03, 2009, 02:42:23 am
Just a note- you may have to add support for the 'require' method itself.  I tried to implement this immediately, figuring that it just wouldn't be able to find my file but instead got this:


Executing listen server config file
[LUA-ERR] Error running function "eliminatio": [string "eliminatio"]:1: attempt to call global 'require' (a nil value)

So it looks like require isn't implemented in 3.1's lua libraries.
Title: Re: Read Me
Post by: killermonkey on August 03, 2009, 02:44:20 pm
Shit, looks like you'll have to wait for BETA 4 in order to implement your module system properly. I had to add the "Package Library" to the LUA environment in order to get the 'require' function.

By the way, the proper way to set the path for "require" and not have an environment variable for it is to set:

package.path = "C:/Program Files/Steam/steamapps/SourceMods/gesource_svn/scripts/gameplay/?.lua";

Where package is the global table that comes from the "Package Library."

So this is working wonderfully in Beta 4 now. Sorry that it won't work out for B3.1.4.

Code: [Select]
(C++)
// Define our path
char fullpath[ 512 ] = { 0 };
filesystem->RelativePathToFullPath( "scripts/gameplay", "MOD", fullpath, sizeof(fullpath) );
Q_strncat( fullpath, "\\?.lua", sizeof(fullpath) );

lua_getglobal(GetLua(), "package");
if (LUA_TTABLE != lua_type(GetLua(), 1))
return;
lua_pushlstring(GetLua(), fullpath, Q_strlen(fullpath) );
lua_setfield(GetLua(), 1, "path"); /* package.path = fullpath */


(LUA)
testfunc.lua

function TestFunc()
    ClientPrintAll(HUD_PRINTTALK, "TEST FUNC!");
end


deathmatch.lua

require( "testfunc" );
function PlayerKilled( victim, killer )
TestFunc();
end
Title: Re: Read Me
Post by: Slinky on August 04, 2009, 03:44:32 am
Cool, good to  hear this will be fixed in 4.  Thanks so much!
Title: Re: Read Me
Post by: Mark [lodle] on August 04, 2009, 05:30:07 am
Monkey why dont you checkout 3.1.4 and add this in, send the server dll to slinky so slinky can make sure it works 100% before beta 4. :P
Title: Re: Read Me
Post by: killermonkey on August 04, 2009, 12:44:10 pm
For someone who doesn't have a lot of time you sure know how to make other people do a lot of work, Mark. :-P

Yah, I'll do that for the poor sap, I'll post it up here for anyone who wants to try, **THIS WILL BE BETA 3.1.4.1 NOT BETA 4 IN ANY WAY**

EDIT:
Beta 3.1.4.1 (added LUA support for the "require" module)
http://www.divshare.com/download/8081271-067
Title: Re: Read Me
Post by: Mark [lodle] on August 05, 2009, 02:14:42 am
See i spend all my time making sure others are working that i dont have enough time to develop my self :P