• Craft System ?
    3 replies, posted
hello facepunch, I would like to make a craft system. So, I have 3 entities : "Box1", "Box2" and Crafter. when i put "Box1" and "Box2" near Crafter and i press use i want it to spawn another entitie. Part of init.lua: [lua]function ENT:Use(ply) local CrafterPos = self:GetPos() local box1 = ents.FindByName("box1") local box2 = ents.FindByName("box2") local FindInSphereCrafter = ents.FindInSphere( CrafterPos, 32 ) for k, v in ipairs( FindInSphereCrafter ) do if ( v:IsValid() && v != self and v:GetName() == box2 and v:GetName() == box1 )then print("you crafted something") else print("you crafted nothing") end end end[/lua]when I press use on "Crafter"with "box1" and "box2" near, the console say :"you crafted nothing" thanks in advance for your help
Are you sure the find functions found anything?
I dont know :p Box 1 and 2 are two basic entities who just spawn with a model. they are situed in lua/entities/box1 and lua/entities/box2. the code for both box1 and two: [lua]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self.Entity:SetModel("models/hunter/blocks/cube025x025x025.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) local phys = self.Entity:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() end self.Entity:SetUseType( SIMPLE_USE ) end function ENT:SpawnFunction( ply, tr ) local ent = ents.Create( self.GetClass() ) ent:Spawn() ent:Activate() return ent end function ENT:Use(ply) print("box1") --or print("box2") end function ENT:Think() end function ENT:OnRemove() end[/lua]
Try inserting debugprints or somthing
Sorry, you need to Log In to post a reply to this thread.