Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Script:GM Code"

From Roll20 Wiki

Jump to: navigation, search
(Created page with "{{stub}}")
 
(tagged as "discontinued API")
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{stub}}
+
{{deprecated|dev|name=GMCode}}
 +
{{script overview
 +
|name=GMCode
 +
|author={{user profile|268993|Tristan Beard}}
 +
|version=1.0
 +
|lastmodified=2015-01-07}}
 +
 
 +
'''GMCode''' generates a unique code to authenticate the GM. The code may then be used to identify the GM for elevated privileges in other scripts.
 +
<br clear="all">
 +
 
 +
=== Syntax ===
 +
{{syntaxbox top|GMCode|formal=true}}
 +
{{API command|gmcodehelp}}<br>
 +
{{API command|gencode}} {{API parameter|name=code|optional=true}}<br>
 +
{{API command|clearcode}} {{API parameter|name=code|optional=true}}<br>
 +
{{API command|custcode}} {{API parameter|name=code</em> {{API parameter|name=new code}}<em>|optional=true}}
 +
{{Formal API command|
 +
{{token|S}} {{rarr}} gmcodehelp<br>
 +
{{token|S}} {{rarr}} gencode {{token|optional code|-}}
 +
{{token|S}} {{rarr}} clearcode {{token|optional code|-}}
 +
{{token|S}} {{rarr}} custcode {{token|code change|-}}
 +
{{token|code change}} {{rarr}} {{epsilon}}
 +
{{token|code change}} {{rarr}} {{token|code}} {{token|code|-}}
 +
{{token|optional code}} {{rarr}} {{epsilon}}
 +
{{token|optional code}} {{rarr}} {{token|code|-}}
 +
{{token|code}} {{rarr}} {{integer}}
 +
}}
 +
{{syntaxbox end}}
 +
 
 +
{{param description top}}
 +
{{param description|name=code|value=Optional if no GM code exists, required otherwise. The value of the generated code, which can be seen in the API console log.}}
 +
{{param description|name=new&nbsp;code|value=Value to change the GM code to.}}
 +
{{param description bottom}}
 +
 
 +
If no GM code exists, the ''code'' parameter is optional in all of the above commands, and the script will generate a new code if it is omitted (regardless of which command besides <code>!gmcodehelp</code> is used).
 +
 
 +
<code>!gencode</code> will regenerate the GM code, while <code>!clearcode</code> will wipe the code out and <code>!custcode</code> will set the code to a specified value.
 +
 
 +
=== Example ===
 +
The GM code is useful for verifying that the user has GM permissions, as the only means to see the code is in the API console log, which is only accessible by a GM. The value of the GM code can be accessed with <code>state.gmcode</code>, which you can then compare against user input to verify identity, similar to a PIN.
 +
<pre data-language="javascript">
 +
on('chat:message', function(msg) {
 +
    var parameters = msg.content.splitArgs(),
 +
        command = parameters.shift().substring(1).toLowerCase();
 +
 
 +
    if (msg.type === 'api' && command === 'mycommand') {
 +
        if (state.gmcode && parameters[0] === state.gmcode) {
 +
            // GM authenticated
 +
        }
 +
    }
 +
});
 +
</pre>
 +
[[Category:Discontinued API Scripts]]

Latest revision as of 15:24, 17 June 2020

API ScriptAuthor: Tristan Beard
Version: 1.0
Last Modified: 2015-01-07
Code: GMCode
Dependencies: None
Conflicts: None

GMCode generates a unique code to authenticate the GM. The code may then be used to identify the GM for elevated privileges in other scripts.

[edit] Syntax

!gmcodehelp
!gencode [code]
!clearcode [code]
!custcode [code <new code>]
Formally:

S

→ gmcodehelp

S

→ gencode optional code


S

→ clearcode optional code


S

→ custcode code change


code change

→ ε

code change

code
code


optional code

→ ε

optional code

code


code

integer
Parameter Values
code Optional if no GM code exists, required otherwise. The value of the generated code, which can be seen in the API console log.
new code Value to change the GM code to.

If no GM code exists, the code parameter is optional in all of the above commands, and the script will generate a new code if it is omitted (regardless of which command besides !gmcodehelp is used).

!gencode will regenerate the GM code, while !clearcode will wipe the code out and !custcode will set the code to a specified value.

[edit] Example

The GM code is useful for verifying that the user has GM permissions, as the only means to see the code is in the API console log, which is only accessible by a GM. The value of the GM code can be accessed with state.gmcode, which you can then compare against user input to verify identity, similar to a PIN.

on('chat:message', function(msg) {
    var parameters = msg.content.splitArgs(),
        command = parameters.shift().substring(1).toLowerCase();

    if (msg.type === 'api' && command === 'mycommand') {
        if (state.gmcode && parameters[0] === state.gmcode) {
            // GM authenticated
        }
    }
});