• Lua E2 question.
    2 replies, posted
Hello, i'm working on an entity that spawns with a E2 chip with already written code, now here is the question. How do i spawn E2 and upload prewritten E2 script on it? That's the code i already have: [code] function ENT:SpawnE2() local pos = self.Entity:GetPos(); local ang = self.Entity:GetAngles(); local e = ents.Create("gmod_wire_expression2"); e:SetPos(pos); e:Spawn(); e:Activate(); e:SetAngles(ang); return e; end [/code]
protip 1: [url]www.wiremod.com[/url] protip 2: look at E2's entity init.lua and see how it loads its code but here You want this function [code]function ENT:Setup(buffer, includes, restore, forcecompile)[/code] Here's how to use it [code]ent:Setup( "YOUR E2 CODE HERE", {} )[/code] Having includes is optional (Although if your E2 code has #include "stuff" anywhere, you need to place that include in the table) The last two arguments are also optional, and you don't need to worry about them
[QUOTE=Divran;37594287]protip 1: [url]www.wiremod.com[/url] protip 2: look at E2's entity init.lua and see how it loads its code but here You want this function [code]function ENT:Setup(buffer, includes, restore, forcecompile)[/code] Here's how to use it [code]ent:Setup( "YOUR E2 CODE HERE", {} )[/code] Having includes is optional (Although if your E2 code has #include "stuff" anywhere, you need to place that include in the table) The last two arguments are also optional, and you don't need to worry about them[/QUOTE] Thank you!
Sorry, you need to Log In to post a reply to this thread.