forked from walterhiggins/ScriptCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-5-hello-using-module.js
41 lines (29 loc) · 1.28 KB
/
example-5-hello-using-module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*************************************************************************
## Example Plugin #5 - Re-use - Using your own and others modules.
A simple minecraft plugin. Using Modules.
### 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.
Source Code...
var greetings = require('./example-1-hello-module');
command( 'hello-module', function( parameters, player ) {
greetings.hello( player );
});
***/
var greetings = require('./example-1-hello-module');
command( 'hello-module', function( parameters, player ) {
greetings.hello( player );
});