Translations:Modding:World Access/8/en

From Vintage Story Wiki

With this you can already start placing or reading blocks using the api object. Please note that mods are loaded before the world is loaded, so you cannot immediately access the world. Depending on what you want to achieve, you have to register to the appropriate event. For some examples in order to do something...

  • after the world has loaded you could register to the RunGame phase: api.Event.ServerRunPhase(EnumServerRunPhase.RunGame, OnRunGame);
  • during world generation we'd have to register to the appropriate world gen events.
  • when the player runs a custom command we need to register one: api.RegisterCommand("test", "a test command", "", OnCommand);
  • when a player joins the game: api.Event.PlayerJoin += OnPlayerJoin;