Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_scenario

Plugin, ACE table, Discussion thread
Dependence:
  • rex_timeline plugin
  • official function plugin, or rex_function2 plugin

Introduction
This plugin will parse commands from a csv format string, then execute them through function object (official function plugin, or rex_function2 plugin). Csv could be created by excel or google document.
It is an advance plugin, user need to know how to use function object first.

Usage
In event sheet,
  1. use "Action:Load commands" to load commands first,
  2. then call "Action:Start scenario" to start commands execution.

Commands
The supported commands in csv string are listed below.
Delay-execution
Sample capx
It will execute function with parameters while time-out. The format of delay-execution is
单击此处进行编辑.

    
The parameters will be treat to string if "eval mode" setting at properties table to "No". Otherwise, parameters will be parsed by "eval" function of javascript (like csv plugin).
  • number: 10
  • string: 'hi'
  • javascript function: Math.random() -- it return a number

Wait
Sample capx
Wait command will pause the execution of scenario. The format of wait command is

    
wait,key
The execution will be paused and locked with key, until "Action:Continue with key", or "Action:Continue all" had been run in event sheet. It is used to wait input from player usually.
The key parameter could be ignored to set by default value "" (empty string).
"Condition:On waiting any start" or "Condition:On waiting start" will be triggered when executing Wait command.
"Condition:Is waiting any", "Condition:Is waiting" will return true if waiting for now.

Tag ... exit
Sample capx
Tag command provide an start entry of execution for "Action:Load commands". Exit command will stop and leave the execution, it will trigger "Condition:On execution completed". The format of these commands is

    
It will run at first command if the tag is "" in "Action:Load commands" (i.e. tag "" is start from first command), therefor do not use "" for tag_name.

If ... else if ... else ... end if
Sample capx
These commands provide single-level if-condition. (The MEM[name] in this sample capx will be listed below) The format of these commands is

    
It need to set "Eval mode" to "Yes" to enable the eval function for these if-conditions. If the eval_condition is "true", run commands block under this if-condition.
Note that, tag could not be put into if-block.

Goto
Sample capx
This command could change the execution flow by jumping to target tag.
It could be used to make a loop, or a condition branch.

    
"tag_name" is like parameters in delay-execution. It will be treat to string if "eval mode" to "No". Otherwise, it will be parsed by "eval" function of javascript.
  • string: 'tag0'
  • MEM[name]
  • Call(...)
"MEM" and "Call" will be describe at next section. They could be used to get tag_name from a variable.

And moreover...
Load commands
Sample capx
Call "
Action:Load commands" to clean and load new commands.
Or call "Action:Append commands" to append new commands at the tail of current commands.

MEM
Sample capx
It is an interface to pass values into csv commands. Call "
Action:Set value" to set the value by name, then it could be read by MEM[name] in parameter in delay-execution command, or if-condition command. Remember to set "Eval mode" to "Yes" in properties table.

Call
Sample capx
The "Call" is just like "Expression:Call" in official function plugin, to call a function and get return value. It is used to get value from other data storage plugin like
array/dictionary/csv plugin usually through "Condition:On function" and "Action:set return value".
Remember to set "Eval mode" to "Yes" in properties table, too.

Debug
Set "Debug mode" to "Yes" in proper to log execution flow of commands at console.

Mustache
Sample capx
String value could be rendered by mustache syntax. It is an easy to embed variable value into a string. Sets property "Mustache" to enable this feature.
For example, string "hello {{name}}" with MEM.name to "rex" will be rendered to "hello rex".
Evaluated command name
Sample capx
Command name, i.e. the first cell of each row, is a number for delay-execution or one of these words -- wait, tag, exit, if, else if ,else, end if, goto usually.
It also supports "eval" on this field to get evaluated result while
property "Eval mode" is "Yes".
For example,

Math.random(),function_name,parameter0,parameter1 ...
it puts Math.random at first cell to get a random delay.

Save and Load
This plugin supports official save/load system. User could save the execution status automatically with official save action.

Sync timescale
This behavior could be affected by timescale of this instance, if "Sync timescale" sets to "Yes" in properties table. It is another way to pause or resume scenario, or slow down/go fast the execution.
This scenario will also be affected by timeline object.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About