• Hooks to do a step.
    17 replies, posted
Hi everyone. I would know which hooks I need to execute to keep alive gmod. I mean: [lua] while(true) end [/lua] That will block garrysmod. I would something like: [lua] while(true) step() end [/lua] So each time step function is executed, Garrysmod do their work. I think step should be something executing Draw hooks, think hook, etc... I want it for debug purposes (I'm doing a breakpoint system with lua that I will release). So if anyone knows something, let me know please. Thanks for read.
Lua can't control the engine like that. Basically you're out of luck. What are you even trying to do?
[QUOTE=Python1320;19765359]Lua can't control the engine like that. Basically you're out of luck. What are you even trying to do?[/QUOTE] Breakpoint debug as Visual Studio does. Something like in console: ·Breakpoint MyFunction Then in lua [lua] MyFunction__old = MyFunction MyFunction = function() while(1) Step() end end [/lua] And then: ·PrintVariable MyVariable
[QUOTE=lilezek;19765414]·PrintVariable MyVariable[/QUOTE] Server: [code]lua_run print(MyVariable)[/code] Client: [code]lua_run_cl print(MyVariable)[/code]
[QUOTE=lilezek;19765414]Breakpoint debug as Visual Studio does. Something like in console: ·Breakpoint MyFunction Then in lua [lua] MyFunction__old = MyFunction MyFunction = function() while(1) Step() end end [/lua] And then: ·PrintVariable MyVariable[/QUOTE] [url=http://wiki.garrysmod.com/?title=Debug]This[/url] is nearly everything you can do to debug plus printing variables. I don't even see how you could need a breakpoint in gmod.
Yeah I mean when you really wanna do that add your own prints like print("Now doing this: blabla") <do shit> print("Now doing this:") etc...
[QUOTE=lilezek;19765414]Breakpoint debug as Visual Studio does. Something like in console: ·Breakpoint MyFunction Then in lua MyFunction__old = MyFunction MyFunction = function() while(1) Step() end end And then: ·PrintVariable MyVariable[/QUOTE] Well, what this will do is save a copy of your function to MyFunction__old and proceed to give you an error in the infinate loop detection. Yup, breakpoints :geno:
sounds like a plan
[lua]timer.Create("my thing",0,0,function() -- do shit if (stop doing my shit) then timer.Stop("my thing") end end)[/lua] if you set up a timer with 0 time you get a temporary think hook. If you set the repetitions to 0 you get an infinite loop. A think hook lets the server do things between your code being run, and the infinite loop is what you want. Enjoy. [editline]07:45AM[/editline] no wait fuck nevermind, missread. I don't think what you want to do is possible, gmod is controlled by C++ not Lua. If you want to disable Lua being run, override the hook.Call function, and stop hooks being called. Since Lua has no life of it's own, (even timers use a think hook) that'll kill it.
I think you will find [url=http://www.facepunch.com/showthread.php?t=864376]Error Finder[/url] by Nori most useful.
Why do you want to do this anyway?
[QUOTE=Gbps;19769972]Well, what this will do is save a copy of your function to MyFunction__old and proceed to give you an error in the infinate loop detection. Yup, breakpoints :geno:[/QUOTE] For do that you need to refresh script, and sometimes, restart. With breakpoints you won't have the need of refresh or restart, that will do you win a lot of time. An instance of it: I have my function Add. [lua] function Add(a,b) return a + b end [/lua] So if I want to debug, you need to modify the file: [lua] function Add(a,b) print(tostring(a).." is going to be added to"..tostring(b).." that will return "..tostring(a+b)) return a + b end [/lua] Then you have to refresh/restart. When you finish debuggin, you need to remove the line. By the breakpoint system: [lua] function Add(a,b) return a + b end [/lua] In console, breakpoint Add. Then, PrintVariable Add a, or PrintVariable Add b, will show you it. When you finish, just removebreakpoint Add. As you can notice, first refresh/restart and modify can make you delay 2 minuts. Breakpoints just 1 minute. You will say: just a minute less. That's because this is a simple example. If you have a system with 30 functions calling another functions, is not a minute less, is 20 minutes less... And error finder looks for sintax errors. Where I do: [lua] function Substract(a, b) return a * b end [/lua] I made a mistake, but not a sintax error...
Why are you making a function to replace a single character? And what iRzilla said.
[QUOTE=|FlapJack|;19782157]Why are you making a function to replace a single character? And what iRzilla said.[/QUOTE] Omg, Is just an example... I think you didn't understand me... I said that the error checker or whatever is named DOESN'T find all errors, just sintax errors...
It will never find a sintax error.
That would require that the game know exactly what you're trying to do. That is simply impossible.
Sorry, you need to Log In to post a reply to this thread.