expert975 Posted October 2, 2015 Share Posted October 2, 2015 Here's the thing:I've wrote some cool functions that would make my life on the console a lot easier. The problem is that I'm not sure how to actually apply them to the game as a mod, all I can do right now is trow the functions on some game file like consolecommands.lua and then I can call them like any o ther. What I need to know is how to implement them to a 'standalone' mod.Thanks in advance. Link to comment Share on other sites More sharing options...
pickleplayer Posted October 2, 2015 Share Posted October 2, 2015 You mean like putting them in the modmain.lua? What kind of functions do you mean?Also, if you wanted, you could just keep them in consolecommands.lua and put that copy in your mod folder in a scripts folder, it will overwrite the currently existing version with your version while the mod is enabled Link to comment Share on other sites More sharing options...
expert975 Posted October 2, 2015 Author Share Posted October 2, 2015 You mean like putting them in the modmain.lua? What kind of functions do you mean?Also, if you wanted, you could just keep them in consolecommands.lua and put that copy in your mod folder in a scripts folder, it will overwrite the currently existing version with your version while the mod is enabled That's what I'm doing right now, but it's quite annoying to have to restore that file after each update on all servers... even especially when I feel like changing the functions.What I need is to make a mod so I can load them without invading the game files.The functions are just functions. all I want to do is call them at will. Link to comment Share on other sites More sharing options...
DarkXero Posted October 2, 2015 Share Posted October 2, 2015 @expert975, In modmain:GLOBAL.c_mycom = function() print("Hello")endGLOBAL.c_kill = function(player) player.components.health:Kill()endNow in console you can write- c_mycom() and it will print "Hello".- c_kill(ThePlayer), c_kill(AllPlayers[2]) to kill somebody This is for server side commands, or for when you host a game directly.If you put them on the server, and you are a client, then you can sendRemote: c_mycom()and it will run on the server. Even for the server, this should be specified client side mod, so it doesn't appear on the list. If you want remote custom commands, you send strings to the server:GLOBAL.c_mycom = function() local x, y, z = TheSim:ProjectScreenPos(TheSim:GetPosition()) local fnstr = "print(\"hello\")" GLOBAL.TheNet:SendRemoteExecute(fnstr, x, z)endGLOBAL.c_kill = function(playerstr) local x, y, z = TheSim:ProjectScreenPos(TheSim:GetPosition()) local fnstr = playerstr..".components.health:Kill()" GLOBAL.TheNet:SendRemoteExecute(fnstr, x, z)endNow running c_mycom() will send the string of what c_mycom does and it will run in the server. This way you can have a client side mod and have server ready commands in multiple servers. Link to comment Share on other sites More sharing options...
expert975 Posted October 2, 2015 Author Share Posted October 2, 2015 (edited) @DarkXero, Thank you very much! I can call the print function with no problems, but seems like I can't use local variables in the same way I did before for some reason. The traceback says "attempt to call global 'GetEnabledModsModInfoDetails' (a nil value)" on this line: local mods = GetEnabledModsModInfoDetails() Maybe the problem is not actually on local variables, but on something to do with the function I'm calling and this GLOBAL thingy. How do we work around that? Edited October 2, 2015 by expert975 Link to comment Share on other sites More sharing options...
DarkXero Posted October 3, 2015 Share Posted October 3, 2015 I'm calling and this GLOBAL thingy. How do we work around that? local mods = GLOBAL.GetEnabledModsModInfoDetails() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now