Scripts / OOP LUA framework for FPSC:R

Author
Message
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 26th Mar 2014 19:55 Edited at: 21st Apr 2015 09:44
After couple of weeks of working and testing (in my free) and after last 24 hours working on documentation, I can finally present you my object-oriented LUA framework for Game Guru - Avram's Game Guru Toolkit



As I have spent whole day working on a project's wiki system, I'm just going to copy description from the wiki:



Avram's Game Guru Toolkit is a LUA OOP framework (set of LUA OOP classes) for easier development of FPS games with Game Guru. Instead of writing spaghetti code and cluttering your global game namespace with custom variables and functions this project tries to encapsulate player and entities in Game Guru into single variables so you can easily interact with entities within the game. Don't expect too much though, as LUA support in Game Guru is still poor at this stage. There are only few things you can do, but with this framework you're going to do them easier than ever!



Features



[*] everywhere accessible aPlayer object that encapsulates player

[*] encapsulate entities into single variable per entity

[*] fetch entities by their name (or part of the name)

[*] fetch nearest entities, all or by (part of) their name

[*] interact with multiple entities within one entity script function

[*] assign custom global (persistent) attributes to entities and/or player

[*] have custom global (persistent) variables not related to any entities or player

[*] have timed events (Avram's timer is now part of this framework)



Sample code:







Result:







Wiki is not still complete, I need to write documentation for static aMisc class and make couple of more examples. Or someone else might test it and send me the code and youtube video clip for his example



Download and documentation
Jerry Tremble
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 27th Mar 2014 02:08 Edited at: 27th Mar 2014 02:09
Great work again! I bookmarked your wiki, it will come in handy. I am actually off work all next week so as soon as I get done fixing all the little broken things around the house and cleaning I am going to sit down and start working on the two things that are still holding me back from doing anything original in Reloaded (3 if you count that it doesn't work right yet): Making decent textures and scripting! Thank you for your time!
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 29th Mar 2014 00:02
I have updated methods aEntity:nearest_entities() and aEntity:nearest() to include optional max_distance and max_entities to limit results by maximum distance or maximum number of entities returned.



I will give my best to create at least one more example along with YouTube video by next Monday.

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 3rd Jun 2014 02:50 Edited at: 3rd Jun 2014 15:16
I have updated my framework to work with 1.007 now. You must, however, re-download it and update your global.lua as described here.



Here's another demo where I show how one script can read other entities states (and get their E )







The teapot script (teapot.lua) actually does nothing more than setting name "teapot" for each teapot so the cabinet script (cabinet.lua) can work with teapots



Each of three teapots in this example share the same script:



teapot.lua







The cabinet script actually does all the work:



cabinet.lua







You'll notice how the cabinet script detects nearest teapot and displays it's E value in brackets (15, 19 and then 16).



You could destroy the nearest teapot by calling Destroy(nearest_teapot.e)

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 21st Apr 2015 09:20
For the past year I was randomly working on this and adding useful functions I built myself or found online. Finally I found some time to update the documentation so all functions should be now documented.

Special thanks to @smallg for his "PlayerLooking" function which I've implemented into aPlayer class so you can now easily call aPlayer:isLookingAt(entity) to check if the player is facing an entity. I have credited him in the source code also

There is a couple of new functions for the player, for example you can check if the key is held down or if it is pressed, check the last typed text (by the player) and/or check if the correct phrase has been typed in (recently).

Also, more than 20 useful functions of the aMisc class have been (properly) documented. They are often used internally by the framework but you can use them also "manually" if you need them.

Login to post a reply

Server time is: 2024-04-26 23:15:13
Your offset time is: 2024-04-26 23:15:13