Advertisement
Ozzypig

Person Class

May 10th, 2018
529
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.37 KB | None
  1. local Person = {}
  2. Person.__index = Person
  3.  
  4. function Person.new(gender, name)
  5.     local self = setmetatable({
  6.         gender = gender; -- M or F
  7.         name = name;
  8.         health = 100;
  9.     }, Person)
  10.     return self
  11. end
  12.  
  13. function Person:speak(sentence)
  14.     print(self.name .. ": " .. sentence)
  15. end
  16.  
  17. function Person:greet()
  18.     self:speak("Hello, my name is " .. self.name)
  19. end
  20.  
  21. return Person
Advertisement
RAW Paste Data Copied
Advertisement