WorldGen: Difference between revisions

From Vintage Story Wiki
m
Line 45: Line 45:
this.api.RegisterCommand("treasure", "Place a treasure chest with random items", "", PlaceTreasureChestInFrontOfPlayer, Privilege.controlserver);
this.api.RegisterCommand("treasure", "Place a treasure chest with random items", "", PlaceTreasureChestInFrontOfPlayer, Privilege.controlserver);
</syntaxhighlight>
</syntaxhighlight>
This is registering a treasure command with the server with a brief description that is used to describe the command for when the user types /help. The other important argument is the PlaceTreasureChestInFrontOfPlayer argument which is a reference to a method we haven't written yet. So lets add the following method below StartServerSide.
This is registering a '''treasure''' command with the server with a brief description that is used to describe the command for when the user types '''/help'''. The other important argument is the '''PlaceTreasureChestInFrontOfPlayer''' argument which is a reference to a method we haven't written yet. So lets add the following method below '''StartServerSide'''.
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
private void PlaceTreasureChestInFrontOfPlayer(IServerPlayer player, int groupId, CmdArgs args)
private void PlaceTreasureChestInFrontOfPlayer(IServerPlayer player, int groupId, CmdArgs args)
Line 51: Line 51:
}
}
</syntaxhighlight>
</syntaxhighlight>
This method will now be called when the user types /treasure command in the chat window. Wasn't that easy!!! Now we need to write the code to place our chest in that method.


== Hooking in to the world gen API ==
== Hooking in to the world gen API ==
256

edits