You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When resolving module names to file paths, ScriptCraft uses the following rules...
965
-
966
-
1. if the module does not begin with './' or '/' then ...
967
-
968
-
1.1 Look in the 'scriptcraft/lib' directory. If it's not there then...
969
-
1.2 Look in the 'scriptcraft/modules' directory. If it's not there then
970
-
Throw an Error.
971
-
972
-
2. If the module begins with './' or '/' then ...
973
-
974
-
2.1 if the module begins with './' then it's treated as a file path. File paths are
975
-
always relative to the module from which the require() call is being made.
976
-
977
-
2.2 If the module begins with '/' then it's treated as an absolute path.
978
-
979
-
If the module does not have a '.js' suffix, and a file with the same name and a .js sufix exists,
980
-
then the file will be loaded.
981
-
982
-
3. If the module name resolves to a directory then...
983
-
984
-
3.1 look for a package.json file in the directory and load the `main` property e.g.
985
-
986
-
// package.json located in './some-library/'
987
-
{
988
-
"main": './some-lib.js',
989
-
"name": 'some-library'
990
-
}
991
-
992
-
3.2 if no package.json file exists then look for an index.js file in the directory
993
-
994
961
## events Module
995
962
996
963
The Events module provides a thin wrapper around CanaryMod's or
@@ -4006,10 +3973,10 @@ pasting the copied area elsewhere...
4006
3973
4007
3974
#### Parameters
4008
3975
4009
-
* name - the name to be given to the copied area (used by `paste`)
4010
-
* width - the width of the area to copy
4011
-
* height - the height of the area to copy
4012
-
* length - the length of the area (extending away from the drone) to copy
3976
+
* name - the name to be given to the copied area (used by `paste`)
3977
+
* width - the width of the area to copy
3978
+
* height - the height of the area to copy
3979
+
* length - the length of the area (extending away from the drone) to copy
4013
3980
4014
3981
#### Example
4015
3982
@@ -4766,11 +4733,10 @@ The utils.at() function will perform a given task at a given time in the
4766
4733
4767
4734
#### Parameters
4768
4735
4769
-
* time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while
4770
-
9:30 pm is '21:30', midnight is '00:00' and midday is '12:00'
4771
-
* callback : A javascript function which will be invoked at the given time.
4772
-
* worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
4773
-
* repeat : (optional) true or false, default is true (repeat the task every day)
4736
+
* time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while 9:30 pm is '21:30', midnight is '00:00' and midday is '12:00'
4737
+
* callback : A javascript function which will be invoked at the given time.
4738
+
* worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
4739
+
* repeat : (optional) true or false, default is true (repeat the task every day)
4774
4740
4775
4741
#### Example
4776
4742
@@ -4844,42 +4810,6 @@ location. For example...
4844
4810
4845
4811

4846
4812
4847
-
## Inventory Module
4848
-
This module provides functions to add items to, remove items from and check the
4849
-
contents of a player or NPC's inventory.
4850
-
4851
-
### Usage
4852
-
The inventory module is best used in conjunction with the items module. See below for examples of usage.
4853
-
4854
-
```javascript
4855
-
var inventory =require('inventory');
4856
-
var items =require('items');
4857
-
var utils =require('utils');
4858
-
4859
-
// gives every player a cookie and a baked potatoe
4860
-
utils.players(function(player){
4861
-
inventory(player)
4862
-
.add( items.cookie(1) )
4863
-
.add( items.bakedPotato(1) )
4864
-
});
4865
-
4866
-
// give a player 6 cookies then take away 4 of them
4867
-
4868
-
inventory(player)
4869
-
.add( items.cookie(6) )
4870
-
.remove ( items.cookie(4) )
4871
-
4872
-
// check if a player has any cookies
4873
-
4874
-
var hasCookies =inventory(player).contains( items.cookie(1) );
4875
-
4876
-
```
4877
-
The inventory module exposes a single function which when passed a player or NPC will return an object with 3 methods:
4878
-
4879
-
* add : Adds items to the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4880
-
* remove : removes items from the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4881
-
* contains : checks to see if there is the specified type and amount of item in the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4882
-
4883
4813
## Classroom Plugin
4884
4814
4885
4815
The `classroom` object contains a couple of utility functions for use
button to close the sharing options dialog. Students can then access
4926
4856
the shared folder as follows...
4927
4857
4928
-
* Windows: Open Explorer, Go to \\{serverAddress}\players\
4929
-
* Macintosh: Open Finder, Go to smb://{serverAddress}/players/
4930
-
* Linux: Open Nautilus, Go to smb://{serverAddress}/players/
4858
+
* Windows: Open Explorer, Go to \\{serverAddress}\players\
4859
+
* Macintosh: Open Finder, Go to smb://{serverAddress}/players/
4860
+
* Linux: Open Nautilus, Go to smb://{serverAddress}/players/
4931
4861
4932
4862
... where {serverAddress} is the ip address of the server (this is
4933
4863
displayed to whoever invokes the classroom.allowScripting() function.)
@@ -4961,7 +4891,7 @@ Javascript.
4961
4891
4962
4892
#### Parameters
4963
4893
4964
-
* canScript : true or false
4894
+
* canScript : true or false
4965
4895
4966
4896
#### Example
4967
4897
@@ -4977,6 +4907,42 @@ To disallow scripting (and prevent players who join the server from using the co
4977
4907
Only ops users can run the classroom.allowScripting() function - this is so that students
4978
4908
don't try to bar themselves and each other from scripting.
4979
4909
4910
+
## Inventory Module
4911
+
This module provides functions to add items to, remove items from and check the
4912
+
contents of a player or NPC's inventory.
4913
+
4914
+
### Usage
4915
+
The inventory module is best used in conjunction with the items module. See below for examples of usage.
4916
+
4917
+
```javascript
4918
+
var inventory =require('inventory');
4919
+
var items =require('items');
4920
+
var utils =require('utils');
4921
+
4922
+
// gives every player a cookie and a baked potatoe
4923
+
utils.players(function(player){
4924
+
inventory(player)
4925
+
.add( items.cookie(1) )
4926
+
.add( items.bakedPotato(1) )
4927
+
});
4928
+
4929
+
// give a player 6 cookies then take away 4 of them
4930
+
4931
+
inventory(player)
4932
+
.add( items.cookie(6) )
4933
+
.remove ( items.cookie(4) )
4934
+
4935
+
// check if a player has any cookies
4936
+
4937
+
var hasCookies =inventory(player).contains( items.cookie(1) );
4938
+
4939
+
```
4940
+
The inventory module exposes a single function which when passed a player or NPC will return an object with 3 methods:
4941
+
4942
+
* add : Adds items to the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4943
+
* remove : removes items from the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4944
+
* contains : checks to see if there is the specified type and amount of item in the inventory (Expects parameters of type `net.canarymod.api.inventory.Item` - I strongly recommend using the `items` module for constructing items)
4945
+
4980
4946
## Asynchronous Input Module
4981
4947
4982
4948
The `input` module provides a simple way to prompt players for input at the
@@ -6154,7 +6120,7 @@ it called `cw` (short for set Clock and Weather) which when invoked...
6154
6120
/time set 4000
6155
6121
/weather sun
6156
6122
6157
-
Aliases can use paramters as above. On the right hand side of the `=`, the
6123
+
Aliases can use parameters as above. On the right hand side of the `=`, the
6158
6124
`{1}` refers to the first parameter provided with the `cw` alias, `{2}`
6159
6125
refers to the second parameter and so on. So `cw 4000 sun` is converted to
0 commit comments