Advertisement
Inksaver

toolkitTutorial class for libs directory

Apr 18th, 2020
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. -- use with https://pastebin.com/PthjTNys
  2. -- make a folder called libs
  3. -- put this class in libs folder
  4. local clsTurtle = {}
  5. clsTurtle.__index = clsTurtle
  6.  
  7. setmetatable(clsTurtle,
  8. {
  9.     __call = function (cls, ...)
  10.     return cls.new(...)
  11.     end,
  12. })
  13. -- if you want to pass arguments at construction...
  14. function clsTurtle.new(name) --note dot, NOT colon, someValue = list of args or ... (table)
  15.     local self = setmetatable({}, clsTurtle)
  16.     if name == nil or name == "" then
  17.         name = "Turtle"
  18.     end
  19.     self.name = name -- not used, placeholder for tutorial purposes
  20.     self.x = 0
  21.     self.y = 0
  22.     self.z = 0
  23.     self.facing = 0
  24.     self.compass = ""
  25.     self.equippedLeft = ""
  26.     self.equippedRight = ""
  27.     self.placeSlot = 0
  28.     self.placeItem = ""
  29.     self.osVersion = os.version() -- eg CraftOS 1.8
  30.     return self
  31. end
  32.  
  33. function clsTurtle.getName(self)
  34.     return self.name
  35. end
  36.  
  37. return clsTurtle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement