Advertisement
Noneatme

Untitled

Jul 15th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. -- #######################################
  2. -- ## Project:  Electricity Resource    ##
  3. -- ## Name: Electricity_Bold.lua                    ##
  4. -- ## Author: Noneatme                  ##
  5. -- ## Version: 1.0                      ##
  6. -- ## License: See top Folder           ##
  7. -- #######################################
  8.  
  9. -- FUNCTIONS / METHODS --
  10.  
  11. local cFunc = {};       -- Local Functions
  12. local cSetting = {};    -- Local Settings
  13.  
  14. Electricity_Bold = {};
  15. Electricity_Bold.__index = Electricity_Bold;
  16.  
  17. --[[
  18.  
  19. ]]
  20.  
  21. -- ///////////////////////////////
  22. -- ///// New                //////
  23. -- ///// Returns: Object    //////
  24. -- ///////////////////////////////
  25.  
  26. function Electricity_Bold:New(...)
  27.     local obj = setmetatable({}, {__index = self});
  28.     if obj.Constructor then
  29.         obj:Constructor(...);
  30.     end
  31.     return obj;
  32. end
  33.  
  34. -- ///////////////////////////////
  35. -- ///// Render             //////
  36. -- ///// Returns: void      //////
  37. -- ///////////////////////////////
  38.  
  39. function Electricity_Bold:Render()
  40.     for i = 1, self.length, self.abstand do
  41.         if(self.renderPos[i]) and (self.renderPos[i+1]) then
  42.        
  43.             local x1, y1, z1 = self.renderPos[i][1], self.renderPos[i][2], self.renderPos[i][3]
  44.             local x2, y2, z2 = self.renderPos[i+1][1], self.renderPos[i+1][2], self.renderPos[i+1][3]
  45.            
  46.             if(x1 and y1 and z1) then
  47.                 dxDrawLine3D(x1, y1, z1, x2, y2, z2, tocolor(self.color[1], self.color[2], self.color[3], self.color[4]), self.width)
  48.             end
  49.         end
  50.     end
  51. end
  52.  
  53. -- ///////////////////////////////
  54. -- ///// Constructor        //////
  55. -- ///// Returns: void      //////
  56. -- ///////////////////////////////
  57.  
  58. function Electricity_Bold:Constructor(x, y, z, length, abstand, color, width)
  59.     self.renderFunc = function() self:Render() end;
  60.     assert(x and y and z);
  61.     -- length: integer representing the ingame coordinates
  62.    
  63.     length = (length or 10);
  64.    
  65.     self.renderPos = {}
  66.     self.length = length;
  67.     self.color = (color or {0, 0, 255, 255});
  68.     self.width = (width or 1);
  69.    
  70.     self.abstand = (abstand or 0.5)
  71.    
  72.     self.endPos = {x, y, z+length};
  73.    
  74.     for i = 1, length, self.abstand do
  75.         self.renderPos[i] = {x+math.random(-10, 10)/10, y+math.random(-10, 10)/10, z+(length)-i};
  76.     end
  77.    
  78.    
  79.     addEventHandler("onClientRender", getRootElement(), self.renderFunc)
  80.     outputDebugString("[CALLING] Electricity_Bold: Constructor");
  81. end
  82.  
  83. -- EVENT HANDLER --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement