Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //self == the instance. When i saw that "self" had a userdata type and not a table type i started to suspect this. The test that confirmed it: http://pastebin.com/X6D2k4YH
- //untested but it should work:
- class 'UnitTestManager' (GUIScript)
- function UnitTestManager:Initialize()
- self.tests = {}
- end
- function UnitTestManager:Uninitialize()
- self.tests = nil
- end
- function UnitTestManager:RunTests()
- //no trouble using self now when hooked to a console event.
- for i,v in pairs(self.tests) do
- end
- end
- //global so it can be called in different test files without having to recreate this line:
- UnitTestManager = GetGUIManager():CreateGUIScriptSingle("UnitTestManager")
- if not UnitTestManager_Hooked then //wrapped in if so that saving changes to this file won't cause additional hooks
- UnitTestManager_Hooked = true
- local function Test()
- UnitTestManager.RunTests(UnitTestManager) //UnitTestManager == "self" of that classes instance.
- end
- Event.Hook("Console_test", Test)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement