The following is code I am using to render a beam through a function called when
function drawbeam(startpos, endpos, angle) local mat = Material("cable/blue_elec") function startDoodling() print("Got to function") render.SetMaterial(mat) render.DrawBeam(startpos, endpos, 5, 1, 1, Color( 0, 255, 255, 255 )) end print("Got to hook.Add") hook.Add("PostDrawOpaqueRenderables", "LightningDoodles", startDoodling) end function SWEP:PrimaryAttack() local muzzlepos = --don't worry, i defined this drawbeam(muzzlepos, endpos --[===[also defined]===], angle--[===[also defined and necesarry]===]) end
There are two issues with this that are tied together. First, any time I load the game, this error happens:
[ERROR] gamemodes/terrortown/entities/weapons/aa.lua:36: function arguments expected near ':' 1. unknown - gamemodes/terrortown/entities/weapons/custweapon.lua:0
This is because the SWEP:PrimaryFire() function doesn’t go all the way through to end, because it gets stopped when it goes to the drawbeam() function.
The other issue is in the drawbeam() function itself, and is the cause of the error message. The drawbeam() function ONLY goes through to the
hook.Add("PostDrawOpaqueRenderables", "LightningDoodles", startDoodling)
section, and the last print in the console log is “Got to hook.Add”.
Can anyone tell me why the drawbeam() function is only going up until the hook.Add portion, and also why the beam is not appearing. I would LOVE it if someone could help me. Thanks!