I can't seem to pass 'self' properly to the function.
What I am getting is:
[code][ERROR] lua/entities/copier/init.lua:66: attempt to index local 'self' (a nil value)
1. unknown - lua/entities/copier/init.lua:66
Timer Failed! [Simple][@lua/entities/copier/init.lua (line 55)]
I[/code]
[lua]function ENT:StartTouch( ent )
if ent:GetClass() == "spawned_weapon" then
for i=1, 8 do
if self.Items[i].Ent == nil then
local Shelf = self.Items[i]
Shelf.Ent = ent.weaponclass
Shelf.Attachment = ents.Create("prop_physics")
Shelf.Attachment:SetModel(ent:GetModel())
Shelf.Attachment:Spawn()
Shelf.Attachment:SetPos(self:GetPos() + Shelf.Pos)
Shelf.Attachment:SetAngles(self:GetAngles() + Angle(0,0,90))
Shelf.Attachment:SetParent(self)
ent:Remove()
timer.Simple( 1, self.SendItemsInfo, self )
break
end
end
end
end
function ENT:SendItemsInfo()
net.Start("NET_ShelfItems")
net.WriteEntity(self)
net.WriteTable(self.Items)
net.Broadcast()
end[/lua]
@Edit: I would also like to add that doing self:SendItemsInfo() works just fine, but table has "NULL Entity" as one of its values due to delay of ent creation (ents.Create("prop_physics"))
Which is line 66?
[editline]29th May 2013[/editline]
Nvm, [code]
timer.Simple( 1, function() self:SendItemsInfo() end)[/code]
The timer.simple requires a function, it isn't argument based like before.
[lua]
timer.Simple( 1, function()
self:SendItemsInfo( self )
end )
[/lua]
[QUOTE=ptown2;40827311]The timer.simple requires a function, it isn't argument based like before.
[lua]
timer.Simple( 1, function()
self:SendItemsInfo( self )
end )
[/lua][/QUOTE]
I believe I've tried doing it this way already and it didn't work, will check.
@Edit: Works great, thanks!
Fuck me, right?
[QUOTE=ptown2;40827311]The timer.simple requires a function, it isn't argument based like before.
[lua]
timer.Simple( 1, function()
self:SendItemsInfo( self )
end )
[/lua][/QUOTE]
You don't need to put self into arguments, self: does it already.
[QUOTE=Robotboy655;40827383]Fuck me, right?
You don't need to put self into arguments, self: does it already.[/QUOTE]
Well, I noticed it from start but since he tried to do so on the timer.simple, I added it. :v:
Also didn't noticed your post and kinda skimmed over it, sorry.
[QUOTE=ptown2;40827442]Well, I noticed it from start but since he tried to do so on the timer.simple, I added it. :v:
Also didn't noticed your post and kinda skimmed over it, sorry.[/QUOTE]
Yeah, I've noticed his post and read it BEFORE he edited it.
Try this?
[code]
timer.Simple( 1, function(self)
self:SendItemsInfo()
end )
[/code]
Sorry, you need to Log In to post a reply to this thread.