dobrograd-13-06-2022/garrysmod/addons/feature-wire/lua/entities/gmod_wire_weight.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

44 lines
1 KiB
Lua

AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName = "Wire Weight"
ENT.WireDebugName = "Weight"
if CLIENT then return end -- No more client
local MODEL = Model("models/props_interiors/pot01a.mdl")
function ENT:Initialize()
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self.Inputs = Wire_CreateInputs(self,{"Weight"})
self.Outputs = Wire_CreateOutputs(self,{"Weight"})
self:ShowOutput(self:GetPhysicsObject():GetMass())
end
function ENT:TriggerInput(iname,value)
if(value>0)then
value = math.Clamp(value, 0.001, 50000)
local phys = self:GetPhysicsObject()
if ( phys:IsValid() ) then
phys:SetMass(value)
phys:Wake()
self:ShowOutput(value)
Wire_TriggerOutput(self,"Weight",value)
end
end
return true
end
function ENT:Think()
BaseClass.Think(self)
end
function ENT:Setup()
end
function ENT:ShowOutput(value)
self:SetOverlayText( "Weight: "..tostring(value) )
end
duplicator.RegisterEntityClass("gmod_wire_weight", WireLib.MakeWireEnt, "Data")