In our last example we added a new scene command to the editor. However, if we use that scene command now it has no in-game effect because didn’t implement the logic for that command yet. To do that, we have to open the Script Editor under View > Script.

 

The script editor contains all editable game scripts defining the visual novel engine. See Script Documentation  for more info. In our case, we need to modify the command-interpreter so that it processes our new command. We can find the command-interpreter in Components > Component_CommandInterpreter. However, instead of directly modifying the that script we will create a new script in a new folder. So lets create a new folder"Custom " in"Components " folder and add a new script"Component_CommandInterpreterCardExtension ". Now lets puts the following script code in:

 

class Component_CommandInterpreterCardExtension extends gs.Component_CommandInterpreter

    constructor: () ->

        super()

        

    # We need to override this method to assign our command function to

    # the command.

    assignCommand: (command) ->

        super(command)

        

        switch command.id

            when "ext.ShowCard" then command.execute = @commandExtShowCard

      

    # Our method to handle the commands logic.      

    commandExtShowCard: ->

        card = RecordManager.cards[@interpreter.numberValueOf(@params.cardId)]

        x = @interpreter.numberValueOf(@params.position.x)

        y = @interpreter.numberValueOf(@params.position.y)

        

        console.log("Show Card executed!")

        console.log("Card: #{card.name}")

        console.log("Position: #{x}, #{y}")

        

        # Command Logic...

 

# This line is very important, we are overriding the current default class with our own

# implementation. So multiple extensions can add new commands independent from each other.

gs.Component_CommandInterpreter = Component_CommandInterpreterCardExtension

 

If we now use our new command in a scene, we can see something like this:

 

Show Card executed!

Card: My Card

Position: 10, 10

 

On the game's debug console (F12 or option+cmd+i). As we can see our new command is processed by the interpreter. We only need to finish the logic of the command and display the card’s image on screen. But that is not covered by this guide to keep this example simple as possible.