• Visual Studio Code: GLua Code Runner
    0 replies, posted
Visual Studio Code: GLua Code Runner This extension allows you to run glua code through Visual Studio in GMod. There is a Readme file in the bottom linked GitHub-Repo! How To Use: Here is a example video of how this extension works. https://files.facepunch.com/forum/upload/252266/bf8574aa-699d-43cc-88af-df78a0d019ea/2018-04-24_16-32-10.mp4 To be able to use this you need to peform some actions. First you will have to add the GLua code to your server, or add it as a Libary, that is your choice, if you do want it as a addon you just put the "glua_code_runner" in your addon folder, and also be sure to not add the "ignore" folder, as that folder is not needed inorder for this extension to run, it is only for development uses. After adding the GLua code you have some new features. Client hook.Add( "GLR.PostWebsocketSetup", "SomeHookName", function() print( "PostWebSocketSetup" ) end ) This hook will be called once the client requested the websocket client from the server, and it got ran. glr_setup_socket This command will send a request to the server to start your client websocket, more on that later. Server hook.Add( "GLR.CanRunCodeSV", "SomeHookName", function( client ) print( client, "Tries to run server side code, but we don't wont allow it!" ) return false end ) This hook will be called once the client requested to run server side code, only clients that are superadmin will even reach this hook! hook.Add( "GLR.CanRunSetupSocket", "SomeHookName", function ( client ) print( client, "Tries to setup his server socket, but we wont allow it!" ) return false end ) This hook will be called once the client requested to start a client websocket on himself, only clients that are superadmin will even reach this hook! If you return "false" on either those hooks you will prevent the action from happening. So in order to run your code now you will have to install the Visual Studio Code extension which can be found under releases in the GitHub-Repo. Or Here: https://github.com/7Flixs/vs_code_glua_code_runner/releases Once you have downloaded the ".vsix" file you will need to run this command in Visual Studio Code code --install-extension .\glua-code-runner-1.0.0.vsix If you downloaded a version that isn't 1.0.0 besure to also change it in the command! After you've installed the Visual Studio Code Extension we can start on actually running code! First you will need to run the "GLR: Start Socket" command in Visual Studio Code, to type in commands press "F1". After you've ran that command you will need to go into GMod and run the "glua_setup_socket". It will create a socket on the client and connect to the server socket that was created in Visual Studio Code, in order to see all those logs in Visual Studio, go on the tool menu "Help" and then "Toggle Developer Tools" this will open the console in Visual Studio Code. After you've started the the client socket you will be able to run code! If you press "F1" again and type "GLR: Run Code CL" or "GLR: Run Code SV" the current file will be ran in GMod either the Client Realm or Server Realm depening on which command, SV = Server Side, CL = Client Side fairly simple! There are some side notes to know, if want to print anything that is being ran from your file, the print function will not be called instead a implemented function will be called which leads all logs back to Visual Studio Code, if errors occure those are sent back to Visual Studio Code aswell, if you run "print()" make sure to only use one parameter because only one is supported, "PrintTable()" will also send the result back to Visual Studio Code. While running code the variable "GLR_CP" will always be yourself so if you want to perform an action on yourself you should use that variable it is you in the Client and Server Realm, so use this. This should be everything you need to know, if there are still questions be sure to ask, if there are issues be sure to post them on the GitHub-Repo under issues! This is the GitHub-Repo: https://github.com/7Flixs/vs_code_glua_code_runner Special Thanks To: @Thomasim
Sorry, you need to Log In to post a reply to this thread.