Call

The call action allows you to call your very own javascript functions.

    
    - call function_name:
      param1: value1
      param2: value2
      ...

The function must be located in the file RenJS/CustomContent.js, inside the map customContent defined there.

RenJS.customContent = {
	//put here your own functions

	function_name: function (params) {
	  console.log(params.param1);
	  console.log(params.param2);
	  RenJS.resolve();
	}

}

You can do anything inside this function. The most important thing to remember is to call RenJS.resolve() after all your processing is finished. This usually means it should be at the end of the function, but it could be in a callback for an asynchronous method. The RenJS.resolve() function tells the automat that it can continue with the story and execute the next action after the call.

Interesting resources

RenJS provides all of the information and state of the game for you to use in your own function, some of the most important things to check are:

  • RenJS.waitForClick(callback): This function will make the game wait until the player clicks anywhere on the screen. If callback is not defined, the action executed after the click will be RenJS.resolve(). Similar to this function there’s also waitTimeout(time,callback) and waitForClickOrTimeout(time,callback).
  • RenJS.logicManager.vars: This is the map of all the story variables set during the game with the action var.
  • RenJS.bgManager.current: The current background sprite. RenJS.bgManager.backgrounds contains all of the backgrounds.
  • RenJS.bgManager.showing: A map with all the characters currently on screen with look, position and if it’s flipped. RenJS.bgManager.characters contains all of the characters, with name, speechColour and looks (as a map of Sprites).
  • RenJS.cgsManager.current: A map with all the cgs currently on screen. RenJS.bgManager.cgs contains all of the cgs sprites.
  • RenJS.save(slot) and RenJS.load(slot): Saves and load on a specific slot.
  • RenJS.setBlackOverlay() and RenJS.removeBlackOverlay(): Fades in and out a black overlay over everything in the game, including the GUI.
  • RenJS.pause() and RenJS.unpause(): Pauses and unpauses the game.
  • RenJS.onInterpretActions: Map of functions called every time an action is interpreted, meaning on each step of the story. The only defined function at the start of the game is ‘updateStack’ which controls the execution stack of the story, but you can add and remove functions that would then execute every time an action is interpreted.

Phaser

As RenJS is built over Phaser, you can use any Phaser method to do whatever you want. Just be careful not to break everything!