Author Topic: PyBLS (Blockland Save File Library for Python)  (Read 7556 times)

It is most certainly not impossible

For example my brick creator automatically generates the uiname (along with the category and subcategory) for the brick based on it's dimensions, and also has a function to do the reverse, getting the dimensions from the uiname.

and for bricks like "Lamp Brick" with the UI name? And the custom tree bricks, and the props. Look it's not my fault if they go into eachother, it'd be a waste of time and memory to locate the BLB file and check the dimmensions for each UI name, after 100 UI names it would clog up and die.

do you have to manually add all those lines...

do you have to manually add all those lines...
all what lines?


If you really don't want to go through all that colorset stuff by following simple instructions, grab it from one of your saves.

I could probably make something like this in C#, but with less manual stuff and more brick options, like events and naming.

Why the hell are you stating the colorset in a file? Define a type for storing the colorset which you can pass to the instanciator or in a method call to a "save file instance" in order to apply it. Also, don't use such a static structure. Use a class that represents a "virtual brick space" with methods to add, modify, remove, save and load bricks.

For example, how usage should be like:

Code: [Select]
# Import modules.
import blsavelib, os

# Define a 64-color colorset filled with (200, 200, 200, 255) as a list.
c = [(200, 200, 200, 255) for x in range(64)]

# Create a brick container, passing the colorset.
a = blsavelib.BrickContainer(c)

# Create a brick.
b = a.add_brick('32x Baseplate', (0, 5.5, 3))

# Set it's color.
a.set_property(b, 'color', 5)

# Add an event to the brick.
a.add_event(b, 'onActivate', 'Player', 'Kill')

# Save everything.
a.save(os.path.join(os.curdir, 'myfile.bls'))

If you want to be really fancy, use kwargs, such as:
a.add_brick(name='32x Baseplate', position=(0, 0.5, 3), rotation=2, ...)
« Last Edit: May 22, 2012, 10:24:34 AM by Port »