Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. AddCSLuaFile()
  2. DEFINE_BASECLASS( "base_gmodentity" )
  3. ENT.PrintName = "Main Signal"
  4. ENT.Author = "Ron"
  5. ENT.Category = "Ron's German Signals"
  6. ENT.Editable = false
  7. ENT.Spawnable = true
  8. ENT.AdminOnly = false
  9.  
  10. function ENT:SetupDataTables()
  11. self:NetworkVar( "Int", 0, "Signal State" )
  12. end
  13.  
  14. function ENT:SpawnFunction( ply, tr, ClassName )
  15.  
  16. if ( !tr.Hit ) then return end
  17.  
  18. local ent = ents.Create( ClassName )
  19. ent:SetModel("models/ron/signals/hp_lichtsignal.mdl")
  20. ent:PhysicsInit( SOLID_VPHYSICS )
  21. ent:SetMoveType( MOVETYPE_VPHYSICS )
  22. ent:SetSolid( SOLID_VPHYSICS )
  23. ent:SetPos( tr.HitPos + tr.HitNormal )
  24. ent:Spawn()
  25. ent:GetPhysicsObject():SetMass(50000)
  26. ent:SetCollisionGroup( COLLISION_GROUP_WORLD )
  27.  
  28. return ent
  29. end
  30.  
  31. function ENT:Initialize()
  32. if SERVER then
  33.  
  34. if WireLib then
  35. if !WireLib.CreateSpecialInputs then return end
  36. self.Inputs = WireLib.CreateSpecialInputs( self, { "Signal_State" }, { "NORMAL" } )
  37. self.WireDebugName = "Main Signal"
  38. end
  39. end
  40. end
  41.  
  42. function ENT:TriggerInput(inname, value)
  43. if inname == "Signal_State" && value ~= 0 then
  44. self:SetBodygroup(1, value)
  45. elseif inname == "Signal_State" && value == 0 then
  46. self:SetBodygroup(1, 0)
  47. end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement