I love Gmod, I have been playing it for a few years play it every week. And I'm also a Stargate fan, so I downloaded a Stargate pack for gmod that included a lua scripted stool that lets me spawn an object that when triggered cloaks a given area. But when i trigger it I keep getting the same lua error until i turn it off again. The error is:
"entities/cloaking/cl_init.lua:14: attempt to index local 'parent' (a number value)"
this is the contents of cl_init.lua
[lua]
include("shared.lua");
ENT.Material = StarGate.MaterialCopy("CloakMuzzle","effects/strider_bulge_dudv");
--################### Init @aVoN
function ENT:Initialize()
self.Created = CurTime();
end
--################### Init @aVoN
function ENT:Draw()
if(render.GetDXLevel() >= 90) then
local size = self.Entity:GetNWInt("size") + 100;
local parent = self.Entity:GetNWEntity("parent",self.Entity);
local multiply = math.Clamp(parent:GetVelocity():Length()/30000,0,1)*math.Clamp((CurTime() - self.Created)/2,0,1);
self.Material:SetMaterialFloat("$refractamount",multiply);
render.UpdateScreenEffectTexture();
render.SetMaterial(self.Material);
render.DrawSprite(self.Entity:GetPos(),size,size,Color(255,255,255,255));
end
end
[/lua]
Why not use set color?
[lua]function CheckItems( pl )
if pl:HasItem("cloaking") then
hook.call("CloakPlayer", GAMEMODE, pl)
end
end
function CloakPlayer( pl )
pl:SetColor( 0, 0, 0, 0 )
end
hook.add("CloakPlayer", CloakPlayer, CloakPlayer)[/lua]
Don't know if it will work.
I have no idea how LUA works or how what you posted works. This is an addon I found in the garrysmod.org reppository. Planning to learn lua but right now this is just gibberish for me :S
[QUOTE=Terabit;19463530]Why not use set color?
[lua]function CheckItems( pl )
if pl:HasItem("cloaking") then
hook.call("CloakPlayer", GAMEMODE, pl)
end
end
function CloakPlayer( pl )
pl:SetColor( 0, 0, 0, 0 )
end
hook.add("CloakPlayer", CloakPlayer, CloakPlayer)[/lua]
Don't know if it will work.[/QUOTE]
That won't work at all..
[lua]
include("shared.lua");
ENT.Material = StarGate.MaterialCopy("CloakMuzzle","effects/strider_bulge_dudv");
--################### Init @aVoN
function ENT:Initialize()
self.Created = CurTime();
end
--################### Init @aVoN
function ENT:Draw()
if(render.GetDXLevel() >= 90) then
local size = self.Entity:GetNWInt("size") + 100;
local parent = self.Entity
local multiply = math.Clamp(parent:GetVelocity():Length()/30000,0,1)*math.Clamp((CurTime() - self.Created)/2,0,1);
self.Material:SetMaterialFloat("$refractamount",multiply);
render.UpdateScreenEffectTexture();
render.SetMaterial(self.Material);
render.DrawSprite(self.Entity:GetPos(),size,size,Color(255,255,255,255));
end
end
[/lua]
Replace the code with that. Since parent is defined weirdly for some reason, why don't we just assume that the parent is the entity itself, and replace the parent with self.Entity.
[QUOTE=Kill coDer;19463859]That won't work at all..
[lua]
include("shared.lua");
ENT.Material = StarGate.MaterialCopy("CloakMuzzle","effects/strider_bulge_dudv");
--################### Init @aVoN
function ENT:Initialize()
self.Created = CurTime();
end
--################### Init @aVoN
function ENT:Draw()
if(render.GetDXLevel() >= 90) then
local size = self.Entity:GetNWInt("size") + 100;
local parent = self.Entity
local multiply = math.Clamp(parent:GetVelocity():Length()/30000,0,1)*math.Clamp((CurTime() - self.Created)/2,0,1);
self.Material:SetMaterialFloat("$refractamount",multiply);
render.UpdateScreenEffectTexture();
render.SetMaterial(self.Material);
render.DrawSprite(self.Entity:GetPos(),size,size,Color(255,255,255,255));
end
end
[/lua]
Replace the code with that. Since parent is defined weirdly for some reason, why don't we just assume that the parent is the entity itself, and replace the parent with self.Entity.[/QUOTE]
Thanks a lot!!! :D
I thought you where talking about a player. Oh my god, I should have read all of your post instead of skimmed.
Sorry, you need to Log In to post a reply to this thread.