forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.py
More file actions
33 lines (23 loc) · 1.04 KB
/
Copy pathitems.py
File metadata and controls
33 lines (23 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from ctypes import *
from dftypes import *
libdfhack.Items_getItemDescription.argtypes = [ c_void_p, c_uint, c_void_ptr, _arr_create_func ]
libdfhack.Items_getItemDescription.restype = c_char_p
libdfhack.Items_getItemClass.argtypes = [ c_void_p, c_int, _arr_create_func ]
libdfhack.Item_getItemClass.restype = c_char_p
class Items(object):
def __init__(self, ptr):
self._i_ptr = ptr
def get_item_description(self, itemptr, materials):
def get_callback(count):
item_string = create_string_buffer(count)
return byref(item_string)
item_string = None
callback = _arr_create_func(get_callback)
return libdfhack.Items_getItemDescription(self._i_ptr, itemptr, materials, callback)
def get_item_class(self, index):
def get_callback(count):
item_string = create_string_buffer(count)
return byref(item_string)
item_string = None
callback = _arr_create_func(get_callback)
return libdfhack.Items_getItemClass(self._i_ptr, index, callback)