Code: Show/Hide # demo from asss import * # magic numbers rTIL = 0x4C495472 rNAM = 0x4D414E72 rNAW = 0x57414E72 rBSE = 0x45534272 rAWP = 0x50574172 chat = get_interface(I_CHAT) mapd = get_interface(I_MAPDATA) def mm_attach(arena): arena.wbgoal = mapd.FindRegionByName(arena, "wbgoal") # i should have all of these arena.rAWP = mapd.RegionChunk(arena.wbgoal, rAWP) arena.rBSE = mapd.RegionChunk(arena.wbgoal, rBSE) arena.rNAM = mapd.RegionChunk(arena.wbgoal, rNAM) arena.rTIL = mapd.RegionChunk(arena.wbgoal, rTIL) # i shouldn't have any rNAW arena.rNAW = mapd.RegionChunk(arena.wbgoal, rNAW) # let's see what we get chat.SendArenaMessage(arena, "rAWP" + str(type(arena.rAWP))) chat.SendArenaMessage(arena, "rBSE" + str(type(arena.rBSE))) chat.SendArenaMessage(arena, "rNAM" + str(type(arena.rNAM))) chat.SendArenaMessage(arena, "rTIL" + str(type(arena.rTIL))) chat.SendArenaMessage(arena, "rNAW" + str(type(arena.rNAW))) |
Code: Show/Hide Plareplane> ?|attmod -d demo|rmmod demo|insmod <py> demo|attmod demo Module demo detached. Module demo unloaded successfully Module <py> demo loaded successfully rAWP<type 'str'> rBSE<type 'str'> rNAM<type 'NoneType'> rTIL<type 'NoneType'> rNAW<type 'NoneType'> Module demo attached. Plareplane> ?py print(a.rAWP) E <pymod> error in command handler for 'py' Plareplane> ?py print(a.rBSE) Plareplane> ?py print(a.rNAM) None Plareplane> ?py print(a.rTIL) None Plareplane> ?py print(a.rNAW) None |
Code: Show/Hide Traceback (most recent call last): File "/home/plareplane/software/asss/bin/exec.py", line 46, in c_py chat.SendMessage(player, l) TypeError: argument 2 must be string without null bytes, not str |
Code: Show/Hide int (*RegionChunk)(Region *rgn, u32 ctype, const void **datap, int *sizep);
/* pyint: region, int, bufp out, int buflen out -> void */ |
Quote: |
The type error is pretty clear: your chunk has nul bytes in it. Strings are the most efficient way to pass around binary data in python, and so RegionChunk returns strings (or None, if the chunk isn't there). |
Quote: |
Chunks can contain binary data, but strings used for messages can't (actually, that's the first time I heard of that restriction, but it makes sense). |
Code: Show/Hide x, y, name = unpack("hh16s", aw) |