Slimwaffle Posted January 12, 2019 Share Posted January 12, 2019 Hi guys and girls. I was just wondering if its possible and what would it take to add/trigger steam achievements using lua. Or incorporate them into a lua project. Quote Link to comment Share on other sites More sharing options...
reepblue Posted January 12, 2019 Share Posted January 12, 2019 From my understanding, no. You need to call the use the Steamworks API with C++. You can always expose these classes yourself if you have the professional version. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Slimwaffle Posted January 12, 2019 Author Share Posted January 12, 2019 I do have the professional version. But I have no idea how I would expose these myself any tips or helpful links? Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted January 12, 2019 Share Posted January 12, 2019 Try here https://partner.steamgames.com/doc/features/achievements/ach_guide Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted January 13, 2019 Author Share Posted January 13, 2019 Ohh yeah I understand the steam stuff and documentation. I want to know if there is a way to trigger it using lua. My game only uses c++ when first launching the game and then swaps to lua Is there a way I can maybe pass a value from lua to a global in c++. So that when the game first runs it checks the globals and triggers achievements? Quote Link to comment Share on other sites More sharing options...
Kenneth Nyström Posted January 13, 2019 Share Posted January 13, 2019 I have the exact same question....and I get the steam partner thingy part... and that I have to use Microsofts; Visual studio but there is an multitude of versions of M: VS.. which one is the correct? (I think I have figured out how the code must look like) But what program to use is the next step? and how do I reach the Leadwerks C++ stuff. Is it just to start M: VS and find your correct script and type in the code? cant find the preexisting scripts I want (re)written with/in C++.. within M: VS. (I know this is outside Leadwerks) but does someone know how to find the files? I suspect im gonna need Code::Blocks and thru that find the files i want... (am I correct?) No I guess thats for...Linux... hmm Ahh wait there is an open folder in M: VS...is that the way? Quote Link to comment Share on other sites More sharing options...
Kenneth Nyström Posted January 14, 2019 Share Posted January 14, 2019 On 1/12/2019 at 4:56 AM, reepblue said: From my understanding, no. You need to call the use the Steamworks API with C++. You can always expose these classes yourself if you have the professional version. Am I correct in assuming one need add //lua to the following C++ "external dependencies" isteamuserstats.h line 88 class ISteamUserStats and make it class ISteamUserStats//lua to expose the class and to line 90 public: .... add say .... static void SetAchiv1()//lua ........ as activator. ........... or do one need do that in like the header files section? ........... or even the source section? ...................... the code from line 88: isteamuserstats.h .................... class ISteamUserStats { public: // Ask the server to send down this user's data and achievements for this game CALL_BACK( UserStatsReceived_t ) virtual bool RequestCurrentStats() = 0; // Data accessors virtual bool GetStat( const char *pchName, int32 *pData ) = 0; virtual bool GetStat( const char *pchName, float *pData ) = 0; // Set / update data virtual bool SetStat( const char *pchName, int32 nData ) = 0; virtual bool SetStat( const char *pchName, float fData ) = 0; virtual bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength ) = 0; // Achievement flag accessors virtual bool GetAchievement( const char *pchName, bool *pbAchieved ) = 0; virtual bool SetAchievement( const char *pchName ) = 0; virtual bool ClearAchievement( const char *pchName ) = 0; I am just confused after having spent 12 hours trying to figure out how to use the ToLua++ generator; ISteamUserStats::SetAchievement("A_TEST_ACHIV") virtual bool SetAchievement( const char *pchName ) = 0; ....... I strongly suspect I need to use the ToLua++ to generate two files of some code. to be able to use the commands from inside a lua script. and with that (luascript) using an XxxXxxxxx::ZzzZzzz(); that the C++ scripts (running in the background (behind the "game window")) can interpret: and then run a bit of code; class XxxXxxxxx//lua { public: static void :ZzzZzzz() { ISteamUserStats::SetAchievement("A_TEST_ACHIV"); } }; That then in its turn uses the preset "external dependencies .h scripts (in this case ISteamUserStats.h that has its ISteamUserStats//lua (exposed)) allowing the SetAchievement("A_TEST_ACHIV") code to be sent to steam... and thru that activating the steam achiv However I am still missing something... (I suspect it has to to with I havent gotten an grasp of what the ToLua++ generatoris supposed to do and work/how to be used) Need an pointer on where to look next as my head is spinning hard (again) as I cant see what I am missing atm. I even have an suspicion there is an built in steamworks lua to c++ (due to the steam interface reacting to shift + tab from with in the game) that is already working and that I only need to understand how to use the XxxXxxxxx::ZzzZzzz(); correctly... Quote Link to comment Share on other sites More sharing options...
Slimwaffle Posted January 15, 2019 Author Share Posted January 15, 2019 ok so to my understanding. There is a folder called projects with a folder inside that for windows or linux. Open the windows folder and you will find a file with the title of your project with the .sln extension. You want to open this in visual studio. This file uses an interpreter to call your main.lua script to run. And if you want to make a c++ project. Just don't use this code and instead launch a main.cpp. What I am wanting to know is how can I use the interpreter to pass a value from a lua script to a c++ script? This way I can do a check at the start of the game to see if an achievement has been triggered. Or would it be possible to say write to a file then read from a file? SO for example; if you kill 100 enemies the lua script writes to a file on line one the word "true". Then when first running the game before the lua stuff kicks in. The c++ reads line 1 from file and triggers achievement if true. Then continues through the list to trigger the game. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.