Mercurial > skaapsteker
changeset 476:1c05b6c2b971
Start of drop item support.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 21:55:45 +0200 |
parents | 18427edff33a |
children | 0e94bc0a103f |
files | scripts/npc-test skaapsteker/dialogue.py |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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]