• Post Processing problems
    8 replies, posted
  • Avatar of El Jameo
  • OK, so in short, I'm trying to make it so that when I press a specific key, it toggles between a certain postprocessing set of values. This is code outside of a gamemode. Here it is: [code] local vats = true --for toggle bind? local function effectss() DrawMotionBlur( 0.2, 0.99, 0.01 ) local tab = {} tab[ "$pp_colour_addr" ] = 0 tab[ "$pp_colour_addg" ] = 0 tab[ "$pp_colour_addb" ] = 0 tab[ "$pp_colour_brightness" ] = 0 tab[ "$pp_colour_contrast" ] = 1 tab[ "$pp_colour_colour" ] = 1 tab[ "$pp_colour_mulr" ] = 0 tab[ "$pp_colour_mulg" ] = 1 tab[ "$pp_colour_mulb" ] = 1 DrawColorModify( tab ) DrawToyTown( 3, 0.4 ) end hook.Add("RenderScreenspaceEffects", "vatshook", effectss) local function govats( ply ) if vats then ply:ConCommand("host_timescale 0.1") effectss() vats = false else -- ply:ChatPrint(HUD_PRINTTALK, "Nope.") vats = true end end concommand.Add("vats", govats) [/code] (I called it VATS for the lulz). Can anyone tell me what's wrong? I'm getting this error: [code][lua\autorun\vats.lua:5] attempt to call global 'DrawMotionBlur' (a nil value)[/code] But I swear I've followed everything said on the [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index189b.html?title=G.DrawMotionBlur"]wiki page[/URL]... Any help is much appreciated.
  • Avatar of El Jameo
  • And how do I get it to be clientside? I tried wrapping a "if (CLIENT) then" tag around it... This is my new code: [code] if (SERVER) then print("Y U PUT ON SERVERSIDE???") end local vats = true --for toggle bind? local function govats( ply ) if vats then ply:ConCommand("host_timescale 0.1") if (CLIENT) then DrawMotionBlur( 0.2, 0.99, 0.01 ) local tab = {} tab[ "$pp_colour_addr" ] = 0 tab[ "$pp_colour_addg" ] = 0 tab[ "$pp_colour_addb" ] = 0 tab[ "$pp_colour_brightness" ] = 0 tab[ "$pp_colour_contrast" ] = 1 tab[ "$pp_colour_colour" ] = 1 tab[ "$pp_colour_mulr" ] = 0 tab[ "$pp_colour_mulg" ] = 1 tab[ "$pp_colour_mulb" ] = 1 DrawColorModify( tab ) DrawToyTown( 3, 0.4 ) end vats = false else ply:ConCommand("host_timescale 1") vats = true end end concommand.Add("vats", govats) hook.Add("RenderScreenspaceEffects", "vatshook", govats) [/code] I've even put it all in the autorun/client folder. No joy. But the "host_timescale" toggle part works fine. I know that's serverside. No errors either, apart from the one I made at the top.
  • Avatar of SharpCoder
  • [QUOTE=El_Jameo;34744474]And how do I get it to be clientside? I tried wrapping a "if (CLIENT) then" tag around it... This is my new code: [code] -- code here [/code] I've even put it all in the autorun/client folder. No joy. But the "host_timescale" toggle part works fine. I know that's serverside. No errors either, apart from the one I made at the top.[/QUOTE] Firstly, I think you have the casing wrong for the hook (I have absolutely no idea if it matters, but it very well might). Secondly, that hook is only client side. So you need to also wrap it around an if ( CLIENT ) then statement. [lua] // This needs to be changed hook.Add("RenderScreenspaceEffects", "vatshook", govats) // To this if ( CLIENT ) then hook.Add("RenderScreenSpaceEffects", "vatshook", govats) end [/lua]
  • Avatar of El Jameo
  • [lua] if (SERVER) then print("Y U PUT ON SERVERSIDE???") end local vats = true /*local function vatsvision() if (CLIENT) then DrawMotionBlur( 0.2, 0.99, 0.01 ) local tab = {} tab[ "$pp_colour_addr" ] = 0 tab[ "$pp_colour_addg" ] = 0 tab[ "$pp_colour_addb" ] = 0 tab[ "$pp_colour_brightness" ] = 0 tab[ "$pp_colour_contrast" ] = 1 tab[ "$pp_colour_colour" ] = 1 tab[ "$pp_colour_mulr" ] = 0 tab[ "$pp_colour_mulg" ] = 0 tab[ "$pp_colour_mulb" ] = 0 DrawColorModify( tab ) DrawToyTown( 3, 0.4 ) end end*/ --hook.Add("RenderScreenspaceEffects", "vatshook", vatsvision) local function govats() if vats then LocalPlayer():ConCommand("host_timescale 0.1") DrawMotionBlur( 0.2, 0.99, 0.01 ) local tab = {} tab[ "$pp_colour_addr" ] = 0 tab[ "$pp_colour_addg" ] = 0 tab[ "$pp_colour_addb" ] = 0 tab[ "$pp_colour_brightness" ] = 0 tab[ "$pp_colour_contrast" ] = 1 tab[ "$pp_colour_colour" ] = 1 tab[ "$pp_colour_mulr" ] = 0 tab[ "$pp_colour_mulg" ] = 0 tab[ "$pp_colour_mulb" ] = 0 DrawColorModify( tab ) DrawToyTown( 3, 0.4 ) -- vatsvision() vats = false else LocalPlayer():ConCommand("host_timescale 1") vats = true end end concommand.Add("vats", govats) if (CLIENT) then hook.Add("RenderScreenspaceEffects", "vatshook", govats) end [/lua] So far, no luck. :< My screen really spazzes out too.
  • Avatar of SharpCoder
  • [QUOTE=El_Jameo;34745215] So far, no luck. :< My screen really spazzes out too.[/QUOTE] Ahhh wait, your screen spazzes out? That could mean it's apply the effect. Do you get any code errors still? Also, since I am sure there are a few code changes you've made, what file is this located in and which folder did you put it in?
  • Avatar of El Jameo
  • Just fixed it all. Decided to rewrite the code and here's what I got: [lua] if (SERVER) then print("Y U PUT ON SERVERSIDE???") end local eff = false local function effect() if eff then DrawMotionBlur( 0.2, 0.99, 0.01 ) local tab = {} tab[ "$pp_colour_addr" ] = 0 tab[ "$pp_colour_addg" ] = 0 tab[ "$pp_colour_addb" ] = 0 tab[ "$pp_colour_brightness" ] = 0 tab[ "$pp_colour_contrast" ] = 1 tab[ "$pp_colour_colour" ] = 1 tab[ "$pp_colour_mulr" ] = 0 tab[ "$pp_colour_mulg" ] = 0 tab[ "$pp_colour_mulb" ] = 0 DrawColorModify( tab ) DrawToyTown( 3, 0.4 ) end end hook.Add("RenderScreenspaceEffects", "vatshook", effect) local vats = true local function togglevats( ply ) if vats then ply:PrintMessage(HUD_PRINTTALK, "VATS ON!") ply:ConCommand("host_timescale 0.1") vats = false eff = true else ply:PrintMessage(HUD_PRINTTALK, "VATS OFF!") ply:ConCommand("host_timescale 1") vats = true eff = false end end concommand.Add("vatstog", togglevats) [/lua] It all works. :D It's times like these where you feel like you're the best at Lua... But you're not really. Well, for the moment you are. ;) Thanks for the help guys. I'll probably fuck it up fairly soon though. :P
  • Avatar of El Jameo
  • Bump (apologies). Yeah. Not quite relating to the topic but it's the same script. I tried adding a timer to it so that when you turn it on, 5 seconds later it would automatically turn off. It turns on perfectly fine, but doesn't turn off. [lua] local vats = true local function vatsoff( ply ) if vats then ply:PrintMessage(HUD_PRINTTALK, "VATS OFF!") ply:ConCommand("host_timescale 1") vats = true eff = false end end local function vatson( ply ) if vats then ply:PrintMessage(HUD_PRINTTALK, "VATS ON!") ply:ConCommand("host_timescale 0.1") vats = false eff = true end timer.Simple(5, vatsoff, ply) end concommand.Add("vats", vatson) [/lua] The [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index93f1.html?title=Timer.Simple"]wiki page[/URL] is unclear (to me, anywho) about it. Can anyone help me here? :(
  • Avatar of brandonj4
  • [QUOTE=El_Jameo;34748147]Bump (apologies). Yeah. Not quite relating to the topic but it's the same script. I tried adding a timer to it so that when you turn it on, 5 seconds later it would automatically turn off. It turns on perfectly fine, but doesn't turn off. [lua] local vats = true local function vatsoff( ply ) if vats then ply:PrintMessage(HUD_PRINTTALK, "VATS OFF!") ply:ConCommand("host_timescale 1") vats = true eff = false end end local function vatson( ply ) if vats then ply:PrintMessage(HUD_PRINTTALK, "VATS ON!") ply:ConCommand("host_timescale 0.1") vats = false eff = true end timer.Simple(5, vatsoff, ply) end concommand.Add("vats", vatson) [/lua] The [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index93f1.html?title=Timer.Simple"]wiki page[/URL] is unclear (to me, anywho) about it. Can anyone help me here? :([/QUOTE] I think its because you're looping it to turn true over, and over again.