Author Topic: Help build a game mode!  (Read 13014 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Help build a game mode!
« Reply #15 on: August 04, 2011, 02:41:54 PM »
Hah, I'm also horrible with names. After all, ULX as a name was a rip-off from AMX/AMXX...
Experiencing God's grace one day at a time.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #16 on: August 06, 2011, 12:11:28 AM »
I have added yet another update, now there is a place for us to start building the Garry's-mod game modification that is called...

The Unity Within

Yep, I went with that name, I hope you all like it.

-----------

My friend was to lazy to create an account so I asked him if it was OK if I put what he said as a quote...

Quote from: Teh Engineer
I like the name GaP better, it just fits better then then the one you have now.
« Last Edit: August 06, 2011, 02:51:45 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #17 on: August 06, 2011, 08:29:58 PM »
This is my script for the damage effects, I do not understand hooks at all, and hook.call has no explanation on the Gmod wiki.

Code: [Select]
function GM:EntityTakeDamage( ent )
 
if ent:IsPlayer() then
Hp = ent:Health()
if(Hp <= 41) then

Mult = (200 - Hp - 159)

hook.Call( "RenderScreenspaceEffects", RenderEFunc, Hp, Mult )
end
end
 end
---
Code: [Select]
local function RenderEFunc(Hp, Mult)

local tab = {}
tab[ "$pp_colour_addr" ] = 5 * Mult
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 )
« Last Edit: August 06, 2011, 08:35:13 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Help build a game mode!
« Reply #18 on: August 06, 2011, 10:53:31 PM »
You don't need to use hook.Call for this, you only need to register the hook. (using hook.Register)
Experiencing God's grace one day at a time.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #19 on: August 07, 2011, 01:31:34 PM »
You don't need to use hook.Call for this, you only need to register the hook. (using hook.Register)

How would I use that? Its not even on the Gmod Wiki...

Are you telling me to use it the same way that I am using hook.Call?
I cry every time I see that I am not a respected member of this community.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Help build a game mode!
« Reply #20 on: August 07, 2011, 02:24:36 PM »
Sorry, not hook.Register... hook.Add. It's as you had it in the post above, if it's not working there's probably a bug in the code..
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help build a game mode!
« Reply #21 on: August 07, 2011, 04:31:32 PM »
You mentioned you didn't understand hooks...well, for a game mode, you better learn! :)
In simplest terms I can think of;

Garry wrote hooks into Gmod.
Those hooks watch for specific events (Spawn,Death, TakeDamage, Suicide, ... ) within the game, no matter what type of game mode.
Adding a hook watcher (hook.add) makes your code look for any of those events, and if they occur, do something.
See also http://wiki.garrysmod.com/?title=Hook
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #22 on: August 07, 2011, 09:07:26 PM »
I was reading the posts carefully and I found that Megiddo said that the code I had from before should work, now I feel stupid for posting script veriations  :-[

I will check to see if I get any other problems, also just woundering if any one else is working, or thinking about working on some thing for this game-mode.

I have decided to keep this closer to ULX and stay farther away from Facepunch because I was told and have also seen that facepunch is not a place for development.

(Why am I up at 5:30 AM you ask thats because I was haunted with thoughts about the game-mode...)
« Last Edit: August 09, 2011, 02:32:52 AM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #23 on: August 09, 2011, 02:20:04 PM »
I am adding this into "...\lua\autorun\"

Code: [Select]
function GAMEMODE:EntityTakeDamage( ent )
 
if ent:IsPlayer() then
Hp = ent:Health()
if(Hp <= 41) then
hook.Call( "RenderScreenspaceEffects", RenderEFunc, ent, Hp )
end
end
end

local 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 )

I get the following error when my health reaches 41...

Code: [Select]
ERROR: Hook 'RenderEFunc' Failed: [lua\autorun\sh_damageeffect.lua:24] attempt to call method 'DrawColorModify' (a nil value)
Removing Hook 'RenderEFunc'

I have tried sending the entity over to my hook with no results. I have also tried separating it and putting the hook into the client folder but I got the same error...

Code: [Select]
ERROR: Hook 'RenderEFunc' Failed: [lua\autorun\client\cl_damageeffect.lua:14] attempt to call global 'DrawColorModify' (a nil value)
Removing Hook 'RenderEFunc'

Any ideas on how I can fix this?

Edit: I need help before my head explodes!!! Because I looked in the script of weather mod and it looks like he is doing that the same way I am...

« Last Edit: August 09, 2011, 02:46:55 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Help build a game mode!
« Reply #24 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.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #25 on: August 09, 2011, 06:39:13 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.

I already tried that and still no luck.

I get the same error.
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Help build a game mode!
« Reply #26 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.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #27 on: August 09, 2011, 10:02:59 PM »
Ahhh, sorry.  Must've missed that in your post.  I've never messed with this stuff.  I'm clueless.

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... :'(
« Last Edit: August 10, 2011, 02:48:40 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Help build a game mode!
« Reply #28 on: August 12, 2011, 05:07:15 PM »
So your hooks should be set up properly, your main error is here:

Code: [Select]
[lua\autorun\client\cl_damageeffect.lua:24] attempt to call global 'DrawColorModify' (a nil value)
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.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Help build a game mode!
« Reply #29 on: August 12, 2011, 05:49:09 PM »
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: [Select]
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 )

The errors I get are...

Code: [Select]
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)

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...

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.

When did I start calling hook.Call incorrectly?
« Last Edit: August 12, 2011, 05:53:59 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.