Scripting System

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Implemented code proposal.png This article features an already implemented code proposal.

Implemented Proposals have had code checked in to the SVN repository. The Implemented Proposals should serve as documentation for the actual implementation. Developers should strive to update these as needed.


Contents

Description

Implementing a system that executes a set of actions when a certain condition is met.

Implementation

Scripts are set for each map and are in a yaml file with the following format "<map_name>_scripts.yaml" where map_name is the file name of the map without the extension.

Each script file has 2 sections Scripts and Conditions.

Scripts

This section contains a list of scripts which themselves contain a list of actions.

An Action is represented by a list and has the following format:

<name>, <parameters>, <time to wait after the action>[, <command to execute before the action is run>, <parameters for the command>]

The Name, Parameters, and Time are mandatory the rest is optional.

The parameters, both for the action and the command, are a string that is being passed to the python eval() function which is run within the Scripting Environment.

Example of a script section:

Scripts:
    janie_greet:
        - [Talk, Janie, 0, approach, 'Janie.fifeagent, PlayerCharacter.fifeagent.behaviour.agent']

Conditions

This section contains a list of conditions.

A Condition is represented by a list and has the following format:

<evaluation string>, <script to execute>

The evaluation string is a string that is being passed to the python eval() function which is run within the Scripting Environment.

If the evaluation string evaluates to True then the script with the given name is being executed.

Example of a condition section:

Conditions:
    - ["not met('Janie')", "janie_greet"]

Example of a complete script file:

Scripts:
    janie_greet:
        - [Talk, Janie, 0, approach, 'Janie.fifeagent, PlayerCharacter.fifeagent.behaviour.agent']
Conditions:
    - ["not met('Janie')", "janie_greet"]
Personal tools