rex_scenarioJEditor
Plugin, ACE table, Discussion thread
Dependence: None
Dependence: None
Introduction
Create Scenario-Json commands. These commnds (script) could be saved into a string variable or an external text file.
Scenario-Json is the next generation of rex_scenario plugin.
Create Scenario-Json commands. These commnds (script) could be saved into a string variable or an external text file.
Scenario-Json is the next generation of rex_scenario plugin.
Motivation
rex_scenario plugin runs external commands (script) in csv format, which can be edited in excel, open office, or google document. It could not handle control commands like for loop, while, if..else if ... else.. well. So I tried to find another command (script) format with a better editor. Then I found that I could use C2 event sheet to be the external commands (script) editor, and save commands (script) in JSON format.
This rex_scenarioJEditor plugin provides actions/conditions/expressions to build external commands (script), then gets the content of commands (script) in JSON string, runs it in rex_scenarioJEngine object.
rex_scenario plugin runs external commands (script) in csv format, which can be edited in excel, open office, or google document. It could not handle control commands like for loop, while, if..else if ... else.. well. So I tried to find another command (script) format with a better editor. Then I found that I could use C2 event sheet to be the external commands (script) editor, and save commands (script) in JSON format.
This rex_scenarioJEditor plugin provides actions/conditions/expressions to build external commands (script), then gets the content of commands (script) in JSON string, runs it in rex_scenarioJEngine object.
Usage
Uses these actions/conditions/expressions to build commands. Get commands by "Expression:Content" in a JSON string.
Condition:On function
Declare a function with an unique function name . Function is the first level of commands, all commands are put in a function body, excepted "Condition:On function". Nest function declarations are not allowed.
Declare a function with an unique function name . Function is the first level of commands, all commands are put in a function body, excepted "Condition:On function". Nest function declarations are not allowed.
Action:Call C2 function
Call a c2 function. Interface of this action is equal to "Action: Call function" of official function object.
Call a c2 function. Interface of this action is equal to "Action: Call function" of official function object.
Action:Wait
Suspend current execution until time-out if the input parameter is a number, otherwise it will wait until a specific signal fired ("Action:Fire signal" in rex_scenarioJEngine object)
Add a rex_timeline plugin into project if waiting time-out.
Suspend current execution until time-out if the input parameter is a number, otherwise it will wait until a specific signal fired ("Action:Fire signal" in rex_scenarioJEngine object)
Add a rex_timeline plugin into project if waiting time-out.
Variable types - local variables, task variables, global variables
There are 3 kinds of variables with different scope - local variables, task variables, global variables. All of them are index by a string name. i.e. a 1d dictionary. Variables can be wrote in commands, or read in expressions.
There are 3 kinds of variables with different scope - local variables, task variables, global variables. All of them are index by a string name. i.e. a 1d dictionary. Variables can be wrote in commands, or read in expressions.
Local variables
local variables will be created when program jumps into a function, destroyed them while left function. Parameters carried by a function call will be put into local variables.
local variables will be created when program jumps into a function, destroyed them while left function. Parameters carried by a function call will be put into local variables.
Task variables
Task variables are alive until the last command executed.
Task variables are alive until the last command executed.
Global variables
Global variables are alive until this rex_scenarioJEngine has been destroyed.
Global variables are alive until this rex_scenarioJEngine has been destroyed.
There are 4 types of a parameter-
- Number: a number, or an expression of C2 which returns a number
- Raw string: a string without any pre-processing. Specifics this type by "Expression:Raw( string )"
- Mustache string: a string with mustache pre-processing. Specifics this type by "Expression:Mustache( string )"
- Expression string: a string, which will be evaluated during run-time to get an expression. Specifics this type by "Expression:Eval( string )"
Default string type
String will be treated as "Mustache string" if property "Mustache" sets to "Yes" (default is "Yes").
String will be treated as "Mustache string" if property "Mustache" sets to "Yes" (default is "Yes").
Mustache string
Variables are noted in
Variables are noted in
- {{local.coin}} : replaced by local variable "coin"
- {{task.coin}} : replaced by task variable "coin"
- {{global.coin}} : replaced by global variable "coin"
Expression string
Expression string will be evaluated with javascript syntax, to get number or boolean value.
Variables are noted in
Expression string will be evaluated with javascript syntax, to get number or boolean value.
Variables are noted in
- local.coin : read value of local variable "coin"
- task.coin : read value of task variable "coin"
- global.coin : read value of global variable "coin"
Add condition block by these conditions "Condition:If", "Condition:Else if", and "Condition:Else".
Parameter in these conditions will be treated as expression string by default.
Parameter in these conditions will be treated as expression string by default.
Add conditions "Condition:Switch", "Condition:Case", and "Condition:Default" to create Switch block,
Parameter in "Condition:Switch" will be treated as expression string by default.
Parameter in "Condition:Case" will be treated as default string by default. i.e. mustache string or raw string, or put a number value directly.
Parameter in "Condition:Switch" will be treated as expression string by default.
Parameter in "Condition:Case" will be treated as default string by default. i.e. mustache string or raw string, or put a number value directly.
Add for loop block by "Condition:For". Commands under this for loop block will be ran repeated, Value of loop index is saved as local variable, which will start from "start" parameter, add "step" for each iterator, stop until the loop index exceed "stop" parameter, or get an "Action:Stop loop" command.
In this sample: start=10, stop=13, step=1. The loop index will become 10, 11, 12, 13.
Parameter of loop index will be treated as default string by default. Others (start, stop, step) will be treated as expression string by default, or put a number value directly.
In this sample: start=10, stop=13, step=1. The loop index will become 10, 11, 12, 13.
Parameter of loop index will be treated as default string by default. Others (start, stop, step) will be treated as expression string by default, or put a number value directly.
Add while loop block by "Condition: While". Commands under this while loop block will be ran repeated until the continue condition return 0, or get an "Action:Stop loop" command.
Parameter of continue-condition will be treated as expression string by default, or sets to 1 to run this while loop always.
Parameter of continue-condition will be treated as expression string by default, or sets to 1 to run this while loop always.
Write variables
Set default value of local variables by "Action:Set default value". It only affects when this local variable is not existed.
This command is useful for setting default value of input function parameters, since input function parameters will be stored into local variables.
This command is useful for setting default value of input function parameters, since input function parameters will be stored into local variables.
Set value of variable
Add command "Action:Set value" to set value to a specific local/task/global variables. Parameter of value will be treated as default string by default, or put a number value directly.
Add command "Action:Set value" to set value to a specific local/task/global variables. Parameter of value will be treated as default string by default, or put a number value directly.
Add to variable
Sample capx
Add command "Action:Add to" to add a value to a specific local/task/global variables. Parameter of value will be treated as expression string by default, or put a number value directly.
Sample capx
Add command "Action:Add to" to add a value to a specific local/task/global variables. Parameter of value will be treated as expression string by default, or put a number value directly.
Command of leaving current loop (while or for loop) is "Action:Stop loop".
"Action:Stop function" will leave current function body back to previous function. It is equal to "return" instruction.
"Action:Stop task" will turn off current execution. "Condition:On task done" or "Condition:On any task done" of rex_scenarioJEngine will be triggered.
"Action:Stop function" will leave current function body back to previous function. It is equal to "return" instruction.
"Action:Stop task" will turn off current execution. "Condition:On task done" or "Condition:On any task done" of rex_scenarioJEngine will be triggered.
Start task
Sample capx
Add command "Action:Start" to create a new task started from a function. Set task name to "" (empty string) will restart current task.
This command is similar with "Action: Call function". But command "Action: Call function" will push current scope into call-stack, command "Action:Start" will clean call-stack (i.e. re-start call-stack).
Sample capx
Add command "Action:Start" to create a new task started from a function. Set task name to "" (empty string) will restart current task.
This command is similar with "Action: Call function". But command "Action: Call function" will push current scope into call-stack, command "Action:Start" will clean call-stack (i.e. re-start call-stack).
Mustache
Left delimiter and right delimiter could be assigned in properties table, or set by "Action:Set delimiters".
Left delimiter and right delimiter could be assigned in properties table, or set by "Action:Set delimiters".