# HG changeset patch # User Simon Cross # Date 1302167154 -7200 # Node ID a661b6621ec4afe395db6e3e36a3ec6c63c516f8 # Parent 8ea658969f4717949ca23bd8f89dc11e59fc9eef Add testing of triggers and entry / exit functions. diff -r 8ea658969f47 -r a661b6621ec4 scripts/npc-test --- a/scripts/npc-test Thu Apr 07 11:05:31 2011 +0200 +++ b/scripts/npc-test Thu Apr 07 11:05:54 2011 +0200 @@ -50,6 +50,18 @@ print "Checking", npc_name, "...", npc = getattr(game.world.npcs, npc_name) dsm = DSM(npc_name, game.world, npc.dsm, npc.state) + print " Loaded %s." % (npc.dsm) + + my_locals = { "world": dsm.world, "state": dsm.states, "npcs": dsm.world.npcs } + my_locals.update(DsmEvent().items) + for state_name, state in dsm.states.items(): + print " Testing triggers for state %s" % state_name + for trigger in state.triggers: + eval(trigger._matches, {}, my_locals.copy()) + eval(trigger._next_state, {}, my_locals.copy()) + print " Test on_entry and on_exit for state %s" % state_name + state.enter(my_locals) + state.leave(my_locals) print "ok" print