Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dynamicLoader.py 874B

123456789101112131415161718192021222324252627282930313233
  1. import bge
  2. def finished_cb(status):
  3. print("Library (%s) loaded in %.2fms." % (status.libraryName, status.timeTaken))
  4. def main(cont):
  5. own = cont.owner
  6. sens = cont.sensors['Collision']
  7. if sens.positive:
  8. mainDir = bge.logic.expandPath("//")
  9. wLib = mainDir + "assets\\" + own['libName']
  10. print('colliding')
  11. to_free = None
  12. if own['libName'] not in str(bge.logic.LibList()):
  13. print(wLib, 'loading')
  14. #bge.logic.LibLoad(wLib, 'Scene', asynchronous=True).onFinish = finished_cb
  15. bge.logic.LibLoad(wLib, 'Scene', async=True).onFinish = finished_cb
  16. else:
  17. y = bge.logic.LibList()
  18. for x in y:
  19. if own['libName'] in x:
  20. print('unloading', x)
  21. to_free = x
  22. #bge.logic.LibFree(x)
  23. if to_free != None:
  24. bge.logic.LibFree(to_free)
  25. #else:
  26. #print('cant unload', x, y)
  27. #print('not loading', bge.logic.LibList(), wLib)