Modding:World Access: Difference between revisions

From Vintage Story Wiki
(Created page with "== Get and Set Blocks through the API == Let's Take our basic mod init code for a server mod <syntaxhighlight lang="c#"> public class SampleMod : ModBase { I...")
 
Line 21: Line 21:
</syntaxhighlight>
</syntaxhighlight>


with this you can already start setting and reding blocks using the api object. Please not that mods are loaded before the world is loaded. So you cannot immediately access the world. So depending on what you want to achieve, you have to register to the appropriate event. For some examples in order to do something...
With this you can already start setting or reading blocks using the api object. Please not that mods are loaded before the world is loaded. So you cannot immediately access the world. So 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: <code>api.Event.ServerRunPhase(EnumServerRunPhase.RunGame, OnRunGame);</code>
* after the world has loaded you could register to the RunGame phase: <code>api.Event.ServerRunPhase(EnumServerRunPhase.RunGame, OnRunGame);</code>
* during world generation we'd have to register to the [[WorldGen API|appropriate world gen events]].
* during world generation we'd have to register to the [[WorldGen API|appropriate world gen events]].
Confirmedusers, Bureaucrats, editor, Administrators
1,778

edits