# HG changeset patch # User Simon Cross # Date 1302378945 -7200 # Node ID 1c05b6c2b971b94a3ead06340d58769e61c9b323 # Parent 18427edff33a3a500644500fcadb730f13c88acb Start of drop item support. diff -r 18427edff33a -r 1c05b6c2b971 scripts/npc-test --- a/scripts/npc-test Sat Apr 09 21:53:19 2011 +0200 +++ b/scripts/npc-test Sat Apr 09 21:55:45 2011 +0200 @@ -59,13 +59,17 @@ print " Loaded %s." % (npc.dsm) def test_switch_to(npc_name): - assert npc_name in game.world.npcs + assert npc_name in game.world.npcs, "Unknown NPC %r" % (npc_name,) + + def test_drop_item(item_name): + assert item_name in game.world.items, "Unknown item %r" % (item_name,) my_locals = { "world": dsm.world, "state": dsm.states, "npcs": dsm.world.npcs, "switch_to": test_switch_to, + "drop_item": test_drop_item, } my_locals.update(DsmEvent().items) diff -r 18427edff33a -r 1c05b6c2b971 skaapsteker/dialogue.py --- a/skaapsteker/dialogue.py Sat Apr 09 21:53:19 2011 +0200 +++ b/skaapsteker/dialogue.py Sat Apr 09 21:55:45 2011 +0200 @@ -39,12 +39,18 @@ """Switch dialogue to another npc.""" OpenDialog.post(npc_name) + def _drop_item(self, item): + """Create a tail of the given type.""" + print "Dropping", item + self.world.get_item(item, to_level=self._me.level) + def event(self, ev): my_locals = { "state": self.states, "world": self.world, "npcs": self.world.npcs, "switch_to": self._switch_dialogue_to, + "drop_item": self._drop_item, } my_locals.update(ev.items) state = self.states[self.state]