Skip to content

Commit

Permalink
Allow setting behaviorGraph's operator
Browse files Browse the repository at this point in the history
  • Loading branch information
uellenberg committed Nov 20, 2021
1 parent 47501f4 commit 2ecc5d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/modules/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const noRegisterSetBehaviorValAction: TemplateObject = {
/**
* Create a graph of this object.
* If only one body is defined, the graph will use 1=body1, and body1=body2 otherwise.
* Usage: behaviorGraph!(name: string, body1: ActionBody, body2?: ActionBody);
* Usage: behaviorGraph!(name: string, body1: ActionBody, operator?: string, body2?: ActionBody);
*/
export const behaviorGraph: TemplateObject = {
function: (args, state: TemplateState, context) => {
Expand All @@ -183,7 +183,8 @@ export const behaviorGraph: TemplateObject = {

const name = getString(args, state, 0, "A behavior name is required!").trim().toLowerCase();
const body1 = getString(args, state, 1, "An action body is required!");
const body2 = getString(args, state, 2);
const operator = getString(args, state, 2);
const body2 = getString(args, state, 3);

behaviorCheck(state, name);

Expand All @@ -194,7 +195,7 @@ export const behaviorGraph: TemplateObject = {
inline function g_raphgamepost${idx}2(x, y) {
${body2 ? body2 : body1}
}
graph { g_raphgamepost${idx}1(x, y) } = { g_raphgamepost${idx}2(x, y) };`;
graph { g_raphgamepost${idx}1(x, y) } ${operator || "="} { g_raphgamepost${idx}2(x, y) };`;
});

return "";
Expand Down

0 comments on commit 2ecc5d8

Please sign in to comment.