General > Developers Corner

Help build a game mode!

<< < (6/7) > >>

LuaTenshi:

--- Quote from: Aaron113 on August 09, 2011, 04:05:14 PM ---I think your problem is you're running it shared.  Try making a client folder inside the autorun folder and place the file in there.  It's just a guess.

--- End quote ---

I already tried that and still no luck.

I get the same error.

Aaron113:
Ahhh, sorry.  Must've missed that in your post.  I've never messed with this stuff.  I'm clueless.

LuaTenshi:

--- Quote from: Aaron113 on August 09, 2011, 09:43:08 PM ---Ahhh, sorry.  Must've missed that in your post.  I've never messed with this stuff.  I'm clueless.

--- End quote ---

The funny thing is that I looked at weather mods lua and the example lua on the gmod wiki, and by what I see they are both doing it the same way I am, I must be missing some thing...

Edit: Megiddo seems to know what he is doing with hooks and such may be he can help me...

Edit: Seems like no one know what to do to fix that... :'(

Stickly Man!:
So your hooks should be set up properly, your main error is here:


--- Code: ---[lua\autorun\client\cl_damageeffect.lua:24] attempt to call global 'DrawColorModify' (a nil value)
--- End code ---

It's saying the global function DrawColorModify doesn't exist. This could either be caused by:
A) Your code isn't being executed on the client (which isn't the case if this error is appearing on your client console)
B) You're trying to call the DrawColorModify function before it is created (unlikely, seeing as how it looks like it requires player action to trigger the hook)
C) DrawColorModify doesn't exist. Looking at where the function is defined (http://luabin.foszor.com/code/lua/postprocess/color_modify.lua#22), it appears that it is part of a post-process effects file. Aren't those only loaded in the sandbox and sandbox-derived gamemodes? If possible, try running this section of code within the sandbox gamemode and see if it works.

LuaTenshi:
The odd thing is that I am running it in sandbox and when I change the Post Processing effects manually they work without giving any errors.

This is my current script, another error also turned up...


--- Code: ---function GAMEMODE:EntityTakeDamage( ent )
 
if ent:IsPlayer() then
Hp = ent:Health()

if(Hp <= 41) then
hook.Call( "RenderScreenspaceEffects", RenderEFunc, ent, Hp )
end
end
end

//Should I split the script here and put the above in Server and whats below in Client?

function RenderEFunc( ent, Hp )

local tab = {}
tab[ "$pp_colour_addr" ] = 5
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" ] = Hp * 2
tab[ "$pp_colour_mulg" ] = 1
tab[ "$pp_colour_mulb" ] = 1

DrawColorModify( tab )

DrawMotionBlur( 0.5, 0.5, 0.1 )
DrawBloom( 1, Hp/100, 3, 9, 9, 1, 255, 0, 0 )

end

hook.Add( "RenderScreenspaceEffects", "RenderEFunc", RenderEFunc )

--- End code ---

The errors I get are...


--- Code: ---ERROR: Hook 'RenderEFunc' Failed: [lua\autorun\sh_damageeffect.lua:25] attempt to call global 'DrawColorModify' (a nil value)
Removing Hook 'RenderEFunc'
ERROR: GAMEMODE:'EntityTakeDamage' Failed: [addons\ulib\lua\ulib\shared\hook.lua:173] attempt to index local 'gm' (a function value)
ERROR: GAMEMODE:'EntityTakeDamage' Failed: [addons\ulib\lua\ulib\shared\hook.lua:173] attempt to index local 'gm' (a function value)

--- End code ---

The sh_damageeffect.lua:25 error appears only once when my health reaches 41.

The hook.lua:173 error spams in console when ever I take damage and my health is below 41.

Edit: I have found an old post about the hook.lua:173 and a quote from Megiddo says...


--- Quote from: Megiddo on April 13, 2009, 01:23:19 PM ---Not a ULib problem. You would (or at least should, feel free to test) get a nearly exact error without ULib. Something is calling hook.Call incorrectly.

--- End quote ---

When did I start calling hook.Call incorrectly?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version