Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CommandShell/Help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ The following utility functions are provided for convenience:
Calls write(s, to) and logs each line of s to the API console.
writeErr(s):
Shorthand for writeAndLog(s, "gm").
sendChat(speakingAs, input):
Wrapper around built-in sendChat, which will execute CommandShell-aware
API commands.
tokenize(s):
Splits the string s into an array based on whitespace. Quotes preserve
spaces, and adjacent quotes are merged (as with POSIX shell command
Expand Down
2 changes: 1 addition & 1 deletion CommandShell/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CommandShell",
"version": "1.1",
"version": "1.2",
"description": "Framework for chat commands",
"authors": "manveti",
"roll20userid": "503018",
Expand Down
26 changes: 23 additions & 3 deletions CommandShell/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ var Shell = Shell || {
Shell.writeAndLog(s, "gm");
},

sendChat: function(speakingAs, input){
if ((input.length <= 0) || (input.charAt(0) != '!')){
return sendChat(speakingAs, input);
}
function processCommand(msgs){
var doSend = true;
for (var i = 0; i < msgs.length; i++){
if (Shell.handleApiMessage(msgs[i])){
doSend = false;
}
}
if (doSend){ sendChat(speakingAs, input); }
}
sendChat(speakingAs, input, processCommand);
},


// command registration

Expand Down Expand Up @@ -271,9 +287,7 @@ var Shell = Shell || {
return false;
},

handleChatMessage: function(msg){
if (msg.type != "api"){ return; }

handleApiMessage: function(msg){
// tokenize command string
var tokens = Shell.tokenize(msg.content);
if (typeof(tokens) == typeof("")){
Expand All @@ -294,6 +308,12 @@ var Shell = Shell || {

// execute command callback
Shell.commands[tokens[0]].callback(tokens, _.clone(msg));
return true;
},

handleChatMessage: function(msg){
if (msg.type != "api"){ return; }
Shell.handleApiMessage(msg);
},

init: function(){
Expand Down
11 changes: 9 additions & 2 deletions ExtendedExpressions/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ var ExExp = ExExp || {
if (err){ return err; }
return parseHelper();
}
return "Error: Unrecognized token: " + s.tok.text;
return "Error: Unrecognized token: " + s.tok.text + (s.tok.type == "raw" ? s.s.split(" ", 1)[0] : "");
}

// if we were given a string, construct a state object
Expand Down Expand Up @@ -299,6 +299,10 @@ var ExExp = ExExp || {
sendChat(from, who + s.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>"));
},

sendChat: function(speakingAs, input){
return sendChat(speakingAs, input);
},

sendCommand: function(chunks, asts, evalResults, inline, from, labels){
// constants
var FUNCTION_FUNCTIONS = {
Expand Down Expand Up @@ -680,7 +684,7 @@ var ExExp = ExExp || {
return ExExp.sendCommand(chunks, asts, [], inline, from, labels)
}
// if we got here, we're done evaluating everything; submit results via sendChat
sendChat(from, chunks.join(""));
ExExp.sendChat(from, chunks.join(""));
},

showHelp: function(who){
Expand Down Expand Up @@ -793,6 +797,9 @@ var ExExp = ExExp || {
if (Shell.write){
ExExp.write = Shell.write;
}
if (Shell.sendChat){
ExExp.sendChat = Shell.sendChat;
}
}
else{
on("chat:message", ExExp.handleChatMessage);
Expand Down
2 changes: 1 addition & 1 deletion ExtendedExpressions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ExtendedExpressions",
"version": "0.4",
"version": "0.5",
"description": "Extended roll expression syntax, supporting conditionals, variable references, bitwise operators, and more.",
"authors": "manveti",
"roll20userid": "503018",
Expand Down
82 changes: 82 additions & 0 deletions ObjectProperties/Help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
ObjectProperties

ObjectProperties allows the user to get and set properties of specified objects.
This provides quick access to token IDs, image URLs, etc., as well as the
ability to set token bar values, move tokens, and various other tricks which
would otherwise require (very small) specialized scripts.

It is recommended that this script be used in conjunction with the CommandShell
module, which will improve output formatting and command discovery.


Commands:

!getprop [options] [property1] [property2] ...
Gets specified properties (or all properties, if none specified) of
specified (or selected) object(s).

!setprop [options] property1 value1 [property2 value2] ...
Sets specified properties of specified (or selected) object(s) to the
specified values.

Valid properties can be found in the API documentation. ObjectProperties only
accesses directly-accessible properties, so BLOB properties like "bio", "notes",
and "gmnotes" are inaccessible, as are properties the API can't access (like
"_defaulttoken").

The above commands accept the following options:

-h, --help Displays a help message and exits.

-t T, --type T Specifies the type (e.g. graphic) of objects
specified after this argument. Can be passed
multiple times to get properties of objects of
different types (see examples below). Does not
directly specify any objects (use -i, -n, etc.,
described below).

-i ID, --id ID Specifies the ID of an object. This should come
after a -t option to specify the type for more
efficient lookup. Can be passed multiple times
to specify multiple objects.

-n NAME, --name NAME Specifies the name of an object, for types which
have a "name" property. This should come after
a -t option in order to be unique (without a
type, this will affect all objects with the
specified name).

-r, --relative When setting properties, the new value will be
added to the existing value, rather than
overwriting it.


Examples:

!getprop
Will display all properties of each selected object.

!getprop -t graphic -i -Jp3illTx5IjO2NMoxEC name
Will display the name of the specified graphic object (token).

!getprop -n Fighter _id _type
Will display the ID and type of all objects named "Fighter" (e.g. a
character and its associated tokens).

!getprop _pageid
Will display the ID of the page containing the selected object (an easy way
for a GM to get the ID of the page currently being viewed).

!setprop -r top 70 left -70
Will move the selected object(s) one square down and one square left.

!setprop top +70 left -70
CAUTION: Unlike the previous command, this will move the selected object(s)
to the coordinates (-70,70), or off the left edge of the map along the first
horizontal grid line.

!setprop -r bar1_value -3
Will subtract 3 from bar 1 of the selected token(s).

!setprop bar1_value -3
CAUTION: Will set bar 1 of the selected token(s) to "-3".
10 changes: 10 additions & 0 deletions ObjectProperties/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "ObjectProperties",
"version": "0.1",
"description": "Get and set properties of selected/specified Roll20 objects.",
"authors": "manveti",
"roll20userid": "503018",
"dependencies": {},
"modifies": {},
"conflicts": []
}
Loading