- The .py files are moved in a folder called 'src' - Schematics: Adds schematics. They are compatible with minetest's mts format. A Schematic object can import a mts file, read binary data, export its data into a BytesIO stream, and write its binary data to a file readable by minetest - Map: MapInterfaces can now be requested to copy a part of a map delimited by two positions in space into a Schematic object, later usable and savable. Mapblocks' nodes now show their correct position in the world. Mapblocks also store their mapblock position and the integer representing that position in the mapblock grid. MapVessels' methods' naming convention is also unified - Test: The picture building function is removed. Messages are added to the test functions, and a new one is implemented, removing all unknown items once provided with a map.sqlite file and another file containing all known nodes' itemstrings (dumped from the minetest server) - Tools: A mod was developed to be used in minetest in order to dump the known nodes list. Copy the mod and use /dumpnodes for this
62 lines
1.3 KiB
Python
62 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- encoding: utf8 -*-
|
|
###########################
|
|
## Metadata for Python-MT
|
|
##
|
|
##
|
|
#
|
|
|
|
from inventory import InvRef
|
|
from utils import Pos
|
|
|
|
|
|
class NodeMetaRef:
|
|
def __init__(self, spos = None, meta = None, inv = None):
|
|
self.data = meta or dict()
|
|
self.pos = spos or Pos()
|
|
self.inv = inv or InvRef()
|
|
|
|
def get_raw(self, key):
|
|
return self.data.get(key)
|
|
|
|
def set_raw(self, key, val):
|
|
self.data[key] = val
|
|
|
|
def get_string(self, key):
|
|
# Gather the integers into a string
|
|
data = self.data.get(key)
|
|
if not data:
|
|
return None
|
|
|
|
res = ""
|
|
for c in data:
|
|
if c >= 256 or c < 0:
|
|
return data # IT IS A NUMBER AAAAAH
|
|
|
|
res += chr(c)
|
|
return res
|
|
|
|
def set_string(self, key, val):
|
|
self.data[key] = [ord(b) for b in val]
|
|
|
|
def get_int(self, key):
|
|
return int(self.data.get(key))
|
|
|
|
def set_int(self, key, val):
|
|
self.data[key] = int(val)
|
|
|
|
def get_float(self, key):
|
|
return float(self.data.get(key))
|
|
|
|
def set_float(self, key, val):
|
|
self.data[key] = float(val)
|
|
|
|
def get_inventory(self):
|
|
return self.inv
|
|
|
|
def to_table(self):
|
|
return self.meta
|
|
|
|
def from_table(self, tab = {}):
|
|
self.meta = tab
|