test2.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. local SpawnerScriptSample =
  12. {
  13. Properties =
  14. {
  15. ScriptVar = { default = "test3" }
  16. }
  17. }
  18. function SpawnerScriptSample:OnActivate()
  19. -- Register our handlers to receive notification from the spawner attached to this entity.
  20. if( self.spawnerNotiBusHandler == nil ) then
  21. self.spawnerNotiBusHandler = SpawnerComponentNotificationBus.Connect(self, self.entityId)
  22. end
  23. Script.ReloadScript("some/path/test3.lua")
  24. if self.script.reloadScriptVar == true then
  25. end
  26. end
  27. -- This handler is called when we start spawning a slice.
  28. function SpawnerScriptSample:OnSpawnBegin(sliceTicket)
  29. -- Do something so we know if/when this is being called
  30. Debug.Log("Slice Spawn Begin")
  31. end
  32. -- This handler is called when we're finished spawning a slice.
  33. function SpawnerScriptSample:OnSpawnEnd(sliceTicket)
  34. -- Do something so we know if/when this is being called
  35. Debug.Log("Slice Spawn End")
  36. end
  37. -- This handler is called whenever an entity is spawned.
  38. function SpawnerScriptSample:OnEntitySpawned(sliceTicket, entityId)
  39. -- Do something so we know if/when this is being called
  40. Debug.Log("Entity Spawned: " .. tostring(entityId) )
  41. end
  42. function SpawnerScriptSample:OnDeactivate()
  43. -- Disconnect our spawner notificaton
  44. if self.spawnerNotiBusHandler ~= nil then
  45. self.spawnerNotiBusHandler:Disconnect()
  46. self.spawnerNotiBusHandler = nil
  47. end
  48. end
  49. return SpawnerScriptSample