-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor some setBlocks code into the next API #7
Comments
Some comments on the code
Towards an alternative implementationThink CSS (which is in any case a useful skill). We have a box / rectangular region, and we're padding it. I think something like this might work (except for the troublesome global class Padding:
def __init__(self, interior, vec1, vec2):
# To follow.
pad = Padding(box, (-1, -1, 0), (1, 1, 0))
pad.block = material To put up another set of walls pad2 = pad + vec
pad2.block = material |
Well, the primary question should be an architectural one. Do we want a collection of useful functions like Or do we want an OOP style where you can create |
Sorry, @dbrgn, but it's not clear to me what you mean. Perhaps you could provide an example or two. |
A functional approach would be def create_walls(mc, x, y, z, width, depth, height):
# do stuff with mc reference An object oriented example would be: class Walls:
def __init__(self, mc, width, depth, height):
# do stuff
def place_at(self, x, y, z):
# create walls on `mc` instance The first approach is a clear command to the referenced minecraft instance: Create walls with the specified dimensions at the specified place. The second approach requires to understand classes, instances and methods. I think the functional approach is easier to understand than creating objects and manipulating the contained data via method calls. As I'd focus on children and beginners, I'd favor a "flat", non-OOP style (e.g. not using vector classes by deafult) even though as a software engineer I know that object orientation has a lot of benefits. |
Here's some code from castle.py in https://bitbucket.org/MattHawkinsUK/rpispy-misc/.
This task in this issue is to refactor this fragment (and agree on the outcome).
The text was updated successfully, but these errors were encountered: