routine
index
/home/thindil/Projekty/anaria/server/lib/pymodules/routine.py

routine.py
 
This is a module for setting up one-time or repeatable routines for mobs. This
can include walking a path, forging a sword, singing verses of a song, or
anything else. This was primarily meant to be for path-following, but I figured
it was worth the time to generalize it out for more complex actions

 
Modules
       
auxiliary
event
mud
mudsys
storage

 
Classes
       
RoutineAuxData

 
class RoutineAuxData
    Holds character data related to character routines.
 
  Methods defined here:
__init__(self, set=None)
copy(self)
copyTo(self, to)
read(self, set)
store(self)

 
Functions
       
cmd_routine(ch, cmd, arg)
Appends a routine onto a character. The second argument needs to be an
evaluable list statement. Put it in parentheses to avoid being cut off
as spaces, since parse treats it as a single word. Example:
 
  > routine man "['say hi', (3, 'say I am a little teapot')]" True
 
this will say hi after the default delay, and I am a little teapot after
a delay of 3. It will then loop through this process indefinitely.
Alternatively, these commands can be replaced with function calls.
do_step(ch)
Performs the current step increments
register_routine_check(check)
adds a routine check to the global list. Must be a function taking one
argument, which is the character doing the routine. Return should be
True if the check succeeded (i.e., we should not do a routine)
routine_event(owner, data, arg)
this is the event that perpetuates NPC routines. Each NPC that has a
routine running has one of these events tied to him or her. When the
routine time expires, a check is made to see if the routine can go on.
If it can, the routine step is performed and the step number is
incremented
set_routine(ch, routine, repeat=False, checks=None)
Sets a routine to a character. Routine steps can constain commands
(character strings), functions (one argument, ch), or tuples
(delay, string | function). If a tuple is not supplied, the default
step time is used
start_routine(ch)
starts a character routine event in motion
try_step(ch)
Checks to see if we can perform a step in the routine. Returns true or
false if it did or not

 
Data
        __dflt_routine_step_time__ = 10
__global_routine_checks__ = [<function <lambda>>]