Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. function SWEP:Think()
  2.     if not IsFirstTimePredicted() then return end
  3.  
  4.     -- Update the rotation speed
  5.     -- This is done on both server and client
  6.     self.Reloading = self.Reloading or false
  7.     self.SpinAccel = self.SpinAccel or 0
  8.     if self.Owner:KeyDown(IN_ATTACK) and not self.Reloading then
  9.         self.SpinAccel = math.Approach(self.SpinAccel, self.CyMaxSpeed, 0.02*FrameTime())
  10.     else
  11.         self.SpinAccel = math.Approach(self.SpinAccel, 0, 0.015*FrameTime())
  12.     end
  13.  
  14.     -- Update piston positions on the client only
  15.     if CLIENT then
  16.         self.SpinPos1 = (self.SpinPos1 or 0) + self.SpinAccel
  17.         self.SpinPos2 = (self.SpinPos2 or 0) + self.SpinAccel
  18.         self.SpinPos3 = (self.SpinPos3 or 0) + self.SpinAccel
  19.  
  20.         self.VElements["cylinder"].pos.x = -self.SpinPos1
  21.         self.VElements["cylinder+"].pos.x = self.SpinPos2
  22.         self.VElements["cylinder++"].pos.x = -self.SpinPos3
  23.  
  24.         if -self.SpinPos1 <= self.CyIn then
  25.             self.SpinPos1 = -self.CyOut
  26.         end
  27.  
  28.         if self.SpinPos2 >= self.CyOut then
  29.             self.SpinPos2 = self.CyIn
  30.         end
  31.  
  32.         if -self.SpinPos3 <= self.CyIn then
  33.             self.SpinPos3 = -self.CyOut
  34.         end
  35.     end
  36.  
  37.     print(self.SpinAccel)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement