ExampleModule.tscript 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. function ExampleModule::onCreate(%this)
  2. {
  3. }
  4. function ExampleModule::onDestroy(%this)
  5. {
  6. }
  7. //This is called when the server is initially set up by the game application
  8. function ExampleModule::initServer(%this)
  9. {
  10. %this.queueExec("./scripts/server/ExampleGameMode");
  11. }
  12. //This is called when the server is created for an actual game/map to be played
  13. function ExampleModule::onCreateGameServer(%this)
  14. {
  15. //These are common managed data files. For any datablock-based stuff that gets generated by the editors
  16. //(that doesn't have a specific associated file, like data for a player class) will go into these.
  17. //So we'll register them now if they exist.
  18. if(isFile("./scripts/managedData/managedDatablocks." @ $TorqueScriptFileExtension))
  19. %this.registerDatablock("./scripts/managedData/managedDatablocks");
  20. if(isFile("./scripts/managedData/managedForestItemData." @ $TorqueScriptFileExtension))
  21. %this.registerDatablock("./scripts/managedData/managedForestItemData");
  22. if(isFile("./scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension))
  23. %this.registerDatablock("./scripts/managedData/managedForestBrushData");
  24. if(isFile("./scripts/managedData/managedParticleEmitterData." @ $TorqueScriptFileExtension))
  25. %this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
  26. if(isFile("./scripts/managedData/managedParticleData." @ $TorqueScriptFileExtension))
  27. %this.registerDatablock("./scripts/managedData/managedParticleData");
  28. }
  29. //This is called when the server is shut down due to the game/map being exited
  30. function ExampleModule::onDestroyGameServer(%this)
  31. {
  32. }
  33. //This is called when the client is initially set up by the game application
  34. function ExampleModule::initClient(%this)
  35. {
  36. %this.queueExec("./scripts/client/inputCommands");
  37. //client scripts
  38. exec("./scripts/client/defaultkeybinds");
  39. %prefPath = getPrefpath();
  40. if(isScriptFile(%prefPath @ "/keybinds"))
  41. exec(%prefPath @ "/keybinds");
  42. }
  43. //This is called when a client connects to a server
  44. function ExampleModule::onCreateClientConnection(%this)
  45. {
  46. ExampleMovemap.push();
  47. }
  48. //This is called when a client disconnects from a server
  49. function ExampleModule::onDestroyClientConnection(%this)
  50. {
  51. }