CoreMotionEvent.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require "Polycode/Event"
  2. class "CoreMotionEvent" (Event)
  3. function CoreMotionEvent:__getvar(name)
  4. if name == "amount" then
  5. local retVal = Polycode.CoreMotionEvent_get_amount(self.__ptr)
  6. if retVal == nil then return nil end
  7. local __c = _G["Vector3"]("__skip_ptr__")
  8. __c.__ptr = retVal
  9. return __c
  10. end
  11. if Event["__getvar"] ~= nil then
  12. return Event.__getvar(self, name)
  13. end
  14. end
  15. function CoreMotionEvent:__setvar(name,value)
  16. if name == "amount" then
  17. Polycode.CoreMotionEvent_set_amount(self.__ptr, value.__ptr)
  18. return true
  19. end
  20. if Event["__setvar"] ~= nil then
  21. return Event.__setvar(self, name, value)
  22. else
  23. return false
  24. end
  25. end
  26. function CoreMotionEvent:CoreMotionEvent(...)
  27. local arg = {...}
  28. if type(arg[1]) == "table" and count(arg) == 1 then
  29. if ""..arg[1].__classname == "Event" then
  30. self.__ptr = arg[1].__ptr
  31. return
  32. end
  33. end
  34. for k,v in pairs(arg) do
  35. if type(v) == "table" then
  36. if v.__ptr ~= nil then
  37. arg[k] = v.__ptr
  38. end
  39. end
  40. end
  41. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  42. self.__ptr = Polycode.CoreMotionEvent(unpack(arg))
  43. end
  44. end
  45. function CoreMotionEvent:__delete()
  46. if self then Polycode.delete_CoreMotionEvent(self.__ptr) end
  47. end