Created
April 6, 2011 16:02
-
-
Save squiddy/905926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/bravo/packets.py b/bravo/packets.py | |
| index 400f09b..43d04e5 100644 | |
| --- a/bravo/packets.py | |
| +++ b/bravo/packets.py | |
| @@ -73,6 +73,9 @@ metadata = Struct("metadata", | |
| ), | |
| Const(UBInt8("terminator"), 0x7f), | |
| ) | |
| +from construct import StringAdapter, RepeatUntil, Field | |
| +metadata = StringAdapter(RepeatUntil(lambda obj, ctx: obj == "\x7f", | |
| + Field("metadata", 1))) | |
| # Build faces, used during dig and build. | |
| faces = { | |
| diff --git a/bravo/plugins/use_test.py b/bravo/plugins/use_test.py | |
| new file mode 100644 | |
| index 0000000..2480a77 | |
| --- /dev/null | |
| +++ b/bravo/plugins/use_test.py | |
| @@ -0,0 +1,22 @@ | |
| +from zope.interface import implements | |
| + | |
| +from bravo.ibravo import IUseHook | |
| +from bravo.packets import make_packet | |
| + | |
| + | |
| +class Test(object): | |
| + implements(IUseHook) | |
| + | |
| + name = "test" | |
| + targets = ("Player", ) | |
| + | |
| + def use_hook(self, factory, player, target, alternate): | |
| + if alternate: | |
| + packet = make_packet("metadata", eid=target.eid, metadata="\x00\x00\x7F") | |
| + else: | |
| + packet = make_packet("metadata", eid=target.eid, metadata="\x00\x01\x7F") | |
| + | |
| + factory.broadcast(packet) | |
| + | |
| + | |
| +test = Test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment