sdi_ext.lua

Lua source files to HTML converted04/22/03 19:13:14

   1  -- SDI_HellCreator
   2  -- Salomatine Dmitry.
   3  -- sdihellcreator@bezeqint.net
   4  -- Israel
   5  -- revision 13.04.2003
   6  -- start ext type definition
   7  require("sdi_class");
   8  ARB_ext = {};
   9  local ARB_ext_mt = Class(ARB_ext);
  10  -- via new function must provide arguments
  11  function ARB_ext:new(name,status)
  12      return setmetatable({ext_name=name,ext_status=status}, ARB_ext_mt);
  13  end
  14  -- default constructor for object via new
  15  function ARB_ext:ARB_ext()
  16      return ARB_ext:new("noname",0);--default noname X 0
  17  end
  18  -- enable/disable 
  19  function ARB_ext:OnOff(sg,val)
  20      if sg==1 then
  21         if val==1 then
  22            self.ext_status=1; -- enable
  23         else
  24            self.ext_status=0;-- disable
  25         end
  26      else -- informative
  27         return self.ext_name,self.ext_status;
  28      end
  29  end
  30  -- check if extension is enabled
  31  function ARB_ext:Enabled()
  32      if (tx>=self.x and tx<= self.x+self.dx)and(ty>=self.y and ty<= self.y+self.dy) then 
  33      return 1;
  34      end
  35      return 0;
  36  end
  37  -- prints all information about extension
  38  function ARB_ext:Pinfo()
  39        print("Extension is",self:OnOff());
  40  end