Skip to content

Commit 6f03493

Browse files
committed
updated api docs from build
1 parent eb9ced4 commit 6f03493

File tree

1 file changed

+51
-85
lines changed

1 file changed

+51
-85
lines changed

docs/API-Reference.md

Lines changed: 51 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Walter Higgins
4747
* [inc.js](#incjs)
4848
* [program.js](#programjs)
4949
* [Important](#important)
50-
* [module name resolution](#module-name-resolution)
5150
* [events Module](#events-module)
5251
* [events.on() static method](#eventson-static-method)
5352
* [Events Helper Module (CanaryMod version)](#events-helper-module-canarymod-version)
@@ -418,11 +417,11 @@ Walter Higgins
418417
* [Examples](#examples)
419418
* [Fireworks Module](#fireworks-module)
420419
* [Examples](#examples-1)
421-
* [Inventory Module](#inventory-module)
422-
* [Usage](#usage-2)
423420
* [Classroom Plugin](#classroom-plugin)
424421
* [jsp classroom command](#jsp-classroom-command)
425422
* [classroom.allowScripting() function](#classroomallowscripting-function)
423+
* [Inventory Module](#inventory-module)
424+
* [Usage](#usage-2)
426425
* [Asynchronous Input Module](#asynchronous-input-module)
427426
* [Lightning module](#lightning-module)
428427
* [Usage](#usage-3)
@@ -959,38 +958,6 @@ module specification, the '.js' suffix is optional.
959958

960959
[cjsmodules]: http://wiki.commonjs.org/wiki/Modules/1.1.1.
961960

962-
### module name resolution
963-
964-
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-
994961
## events Module
995962

996963
The Events module provides a thin wrapper around CanaryMod's or
@@ -4006,10 +3973,10 @@ pasting the copied area elsewhere...
40063973

40073974
#### Parameters
40083975

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
40133980

40143981
#### Example
40153982

@@ -4766,11 +4733,10 @@ The utils.at() function will perform a given task at a given time in the
47664733

47674734
#### Parameters
47684735

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)
47744740

47754741
#### Example
47764742

@@ -4844,42 +4810,6 @@ location. For example...
48444810

48454811
![firework example](img/firework.png)
48464812

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-
48834813
## Classroom Plugin
48844814

48854815
The `classroom` object contains a couple of utility functions for use
@@ -4925,9 +4855,9 @@ delete files* and *Guest access* checkboxes. Click *Create Share*
49254855
button to close the sharing options dialog. Students can then access
49264856
the shared folder as follows...
49274857

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/
49314861

49324862
... where {serverAddress} is the ip address of the server (this is
49334863
displayed to whoever invokes the classroom.allowScripting() function.)
@@ -4961,7 +4891,7 @@ Javascript.
49614891

49624892
#### Parameters
49634893

4964-
* canScript : true or false
4894+
* canScript : true or false
49654895

49664896
#### Example
49674897

@@ -4977,6 +4907,42 @@ To disallow scripting (and prevent players who join the server from using the co
49774907
Only ops users can run the classroom.allowScripting() function - this is so that students
49784908
don't try to bar themselves and each other from scripting.
49794909

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+
49804946
## Asynchronous Input Module
49814947

49824948
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...
61546120
/time set 4000
61556121
/weather sun
61566122
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
61586124
`{1}` refers to the first parameter provided with the `cw` alias, `{2}`
61596125
refers to the second parameter and so on. So `cw 4000 sun` is converted to
61606126
`time set 4000` and `weather sun`.

0 commit comments

Comments
 (0)