Complete CRAFT reference

All,

Just for a laugh - modified and reposted a demo by @dave1707 with a Starwars theme, but angled at Craft (tongue in cheek).

Background image free from ‘Unsplash’ with this attribution Also in graffiti name.

@Bri_G NSFIPhone sadly

@UberGoober Not sure what you’re saying (NSF), but I’m assuming it doesn’t work on your iPhone. I made this change to get it to work on my iPhone 8 SE.

In the draw function.

sprite(galaxy,WIDTH/2,HEIGHT/2,700,400)

@dave1707 I was making a dumb play on words, like instead of NSFW it’s NSFIPhone. Dumb I know.

i thought it was clever

OK here’s what I think schedule does. It’s a function that can be called on voxel blocks to trigger their blockUpdate function a certain number of ticks from now. It’s useful for custom-scripted blocks.

Oh nice! That’s super useful!

Update: I’m still working on this on the weekends. My day job takes a lot of time and energy so it will take a while

In the 3D Asset Viewer there’s a bunch of undocumented stuff in this one place, I think:


            local b = v:get(craft.renderer).model.bounds
            b2 = bounds(b.min, b.max)
            b2:translate(v.position)
            scene.debug:bounds(b2, color(255,255,255,255))

I may be missing this stuff in the documentation, but it looks to me like there are undocumented features on every line here, starting with model.bounds, then bounds(min, max), then bounds:translate(position), and then scene.debug:bounds(bounds, color).

yeah that’s exactly the problem. its undocumented everywhere. gonna take a lot of time to put together.

Hey guys,

This is my fault since I added things to Codea/Craft here and there but failed to document all of them. I’m really awful at missing this kind of thing. Sorry it’s become such a bother for everyone

As a way to help sort out this mess I’ve created a repository over at https://github.com/JohnTM/Codea-Docs which has all the existing documentation and the source code for the Craft lua bindings, which contains literally every Craft API call that exists (please mind the messy code). It doesn’t say exactly what everything does but I can help illuminate that as well if anyone has a specific question

I’ve tried writing comprehensive documentation, manuals, tutorials, videos etc… before but along with juggling bug fixes, updates and new app releases (such as Shade), and my full time job I do find it hard to maintain motivation and consistency across the board. And for that I do apologise since this community means a lot to me

  • John

@John Thanks for the link. There’s a lot to look at.

@John thanks for dropping in to explain stuff!

The silver lining to me is that it’s fun to discover new things that Craft can do.

@dave1707 no worries. Yeah the bindings and documentation are massively monolithic. I guess that’s what happens when you keep adding to a project for this many years. Codea 4 has a much cleaner and elegant design, which will supersede this at some point

@UberGoober no worries. I do feel bad but its been pretty amazing how you guys have reverse engineered the undocumented stuff!

I’m not great at deciphering the bindings—my burning question is if the Craft shader format supports vertex buffers for variables—can anyone tell?

@UberGoober I’m not entirely sure what you mean? Craft doesn’t support arbitrary extra mesh buffers like the old shader system if that’s what you mean. You can use array uniforms to pass in an array of points though if that’s what you want

I think we’re on the same page: in the old shaders every variable could be buffered with a different value for every vertex, making some really amazing things possible.

People did some amazing shader stuff in the old days and the lack of those buffers is what’s keeping me from porting the most impressive ones, if I recall correctly.

Ah ok I see what you mean. Craft unfortunately doesn’t have this feature. The only thing you could do really is use the existing uv and color channels to store extra data. I could also add access to the second uv coordinate (currently not in the API). Can you link to examples that used the old shader system so I can see what it looks like?

I don’t know how to do array uniforms is what I’m missing I guess. They need one format in the lua part of the Craft shader and a different format in the shader code, I could never get them to work together.

@UberGoober looking into the code now, I noticed that array uniforms was originally a planned feature but never got fully implemented. So that makes sense that you couldn’t get it working. I’ll look into how hard it would be to finally add that feature

@John that would be great!