Modding:WorldGen API: Difference between revisions

From Vintage Story Wiki
Line 40: Line 40:


== The /treasure command ==
== The /treasure command ==
Next we are going to add the /treasure command. To do this we must register a delegate so that we can be notified when the user types our command. We do this with the ICoreServerAPI.RegisterCommand method.
Next we are going to add the '''/treasure''' command. To do this we must register a delegate so that we can be notified when the user types our command. We do this with the '''ICoreServerAPI.RegisterCommand''' method.


In StartServerSide add the following line:
In '''StartServerSide''' add the following line:
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
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);
Line 52: Line 52:
}
}
</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.
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.
 


== Placing our chest ==
== Placing our chest ==