Package pajammin :: Package ai :: Package script :: Module script :: Class Script
[show private | hide private]
[frames | no frames]

Class Script


A script that controls the behavior of one or more entities in a level. Each script starts out containing a list of tasks that should be performed in sequential order. To complete a given task, the script repeatedly calls the task's act() method, which performs actions in an attempt to complete the task. Each time the act() method is called, it returns a TaskResult, indicating what action should be taken next by the script:

Note that DoFirst and DoInstead can be used to spawn sub-tasks, leading to a depth-first "tree" of tasks.

When the last task is complete, the script will loop back to the beginning; if you don't want the script to loop, then add an EndTask to the end of the the script's task list.

To Do: Add interrupts

Method Summary
  __init__(self, *tasks)
Create a new script.
  check_interrupts(self, level)
  check_timeouts(self, level, duration)
  step(self, level, duration)
Perform a single action for this script.
  _debug_get_depth(self, task)
  _handle_result(self, result, level)

Instance Variable Summary
  interrupts: A list of 'interrupts' that we should check (how often?).
  update_delay: How long has it been since the last time this script's update was called.
  update_interval: How long should the game engine wait between calls to this script's update.

Class Variable Summary
bool debug = False

Method Details

__init__(self, *tasks)
(Constructor)

Create a new script.

check_interrupts(self, level)

check_timeouts(self, level, duration)

step(self, level, duration)

Perform a single action for this script.

_debug_get_depth(self, task)

_handle_result(self, result, level)


Instance Variable Details

interrupts

A list of 'interrupts' that we should check (how often?). Each interrupt is a pair (Condition, task), where we'll jump streight to task & report the interrupt.

update_delay

How long has it been since the last time this script's update was called.

update_interval

How long should the game engine wait between calls to this script's update.

Class Variable Details

debug

Type:
bool
Value:
False