Guest User

Sillyness

a guest
Mar 31st, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1.  
  2. -- Instance:Interpolate(numberproperty,numberstart,numberend,time)
  3. -- Example at bottom
  4.  
  5. local oldinstance = Instance.new;
  6. local Instance = {};
  7. local metas = {
  8.  __index = function(s,i)
  9.   return s._u[i];
  10.  end,
  11.  __newindex = function(s,i,v)
  12.   s._u[i]=v;
  13.  end
  14. }
  15. function interpolate(s,prop,startValue,targetValue,d)
  16.    if type(targetValue) == "number" then
  17.     local object = s._u;
  18.     local time, duration = tick(), d;
  19.     local halfPi = math.pi/2;
  20.     local difValue = targetValue - startValue;
  21.     repeat  
  22.     local i = math.sin(((tick() - time) / duration) * (halfPi));
  23.     object[prop] = startValue + ((difValue) * i)  
  24.     wait();
  25.     until
  26.     tick() - time >= duration  
  27.     object[prop] = targetValue;
  28.    end
  29. end
  30. function find(obj,str)
  31.    local a,b = pcall(function() print(obj[str]) end);
  32.    return a;
  33. end
  34. function destroy(s)
  35.    s = null;
  36.    s._U:Destroy();
  37. end
  38. function get(obj)
  39.  if type(obj) == 'userdata' then
  40.   if find(obj,'Parent') and not find(obj,'_u') then
  41.    local array = {_u=obj,Interpolate=interpolate,Destroy=destroy};
  42.    array.u = obj;
  43.    array.Interpolate = interpolate;
  44.    setmetatable(array,metas);
  45.    return array;
  46.   else
  47.    error(".",0);
  48.   end
  49.  else
  50.      error("..");
  51.  end
  52. end
  53. Instance.new = function(str,par)
  54.  local array = {
  55.  Destroy=destroy,_u=oldinstance(str,par),Interpolate = coroutine.wrap(interpolate)
  56.  };
  57.  setmetatable(array,metas);
  58.  return array;
  59. end
  60.  
  61.  
  62.  
  63. p = Instance.new("Part",Workspace);
  64. p.Name = "Hi";
  65. wait(4);
  66. p:Interpolate("Transparency",0,1,2);
  67.  
  68. BasePlate = get(Workspace.BasePlate)
  69. BasePlate:Interpolate("Reflectance",0,2,5);
Add Comment
Please, Sign In to add comment