30 lines
990 B
JavaScript
30 lines
990 B
JavaScript
/*
|
|
A simple minecraft plugin.
|
|
Usage: At the in-game prompt type ...
|
|
|
|
/jsp hello-module
|
|
|
|
... and a message `Hello {player-name}` will appear (where {player-name} is
|
|
replaced by your own name).
|
|
|
|
This example demonstrates the use of modules. In
|
|
example-1-hello-module.js we created a new javascript module. In
|
|
this example, we use that module...
|
|
|
|
* We load the module using the `require()` function. Because this
|
|
module and the module we require are n the same directory, we
|
|
specify `'./example-1-hello-module'` as the path (when loading a
|
|
module from the same directory, `./` at the start of the path
|
|
indicates that the file should be searched for in the same
|
|
directory.
|
|
|
|
* We assign the loaded module to a variable (`greetings`) and then
|
|
use the module's `hello` method to display the message.
|
|
|
|
*/
|
|
var greetings = require('./example-1-hello-module');
|
|
|
|
command('hello-module', function( parameters, player ){
|
|
greetings.hello(player);
|
|
});
|