Skip to content

Instantly share code, notes, and snippets.

@calebhsu
Last active October 11, 2015 03:59
Show Gist options
  • Save calebhsu/fe5e5a2c4c6d385d6bff to your computer and use it in GitHub Desktop.
Save calebhsu/fe5e5a2c4c6d385d6bff to your computer and use it in GitHub Desktop.
Shelves using CraftML tags
<craft>
<info>
<title>Bookshelf</title>
</info>
<style>
* {color: brown;}
</style>
<param name="shelves" type="int" default="3"/>
<param name="width" type="int" default="50"/>
<param name="depth" type="int" default="15"/>
<param name="thickness" type="int" default="2"/>
<param name="back" type="int" default="1"/>
<g l="centerX()">
<!-- Back -->
<script>
if ($params.back)
this.add('<cube size="{{width}} 1 {{(10 * shelves) + (thickness * (shelves + 1))}}"/>');
</script>
<g l="centerXY()">
<!-- Sides -->
<row spacing="{{width}}">
<repeat n="2">
<cube size="{{thickness}} {{depth}} {{(10 * shelves) + (thickness * (shelves + 1))}}"/>
</repeat>
</row>
<!-- Shelves -->
<stack spacing="10">
<repeat n="{{shelves + 1}}">
<cube size="{{width}} {{depth}} {{thickness}}"></cube>
</repeat>
</stack>
</g>
</g>
</craft>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment