Like the title suggests how do I add a new block texture?
Whatever new textures you find, you can save them in the Documents or Dropbox folders. From there you can use them in your Codea code.
Thanks, but What command would I call to set the texture from my Dropbox file.
@chrislightsaber Here’s an example of a cube that uses the Planet Cute:Icon image for a texture. To use Dropbox, use Dropbox:imageName where imageName is the name of your image in the Dropbox folder. See the 2 lines of code near the bottom for cube.texture.
Removed code because it didn’t apply.
@dave1707 yup this is exactly my issue too. I’m stuck there sadly. Maybe someone else will know what to do
@chrislightsaber I think Dropbox can be used, but there’s a lot of other code that needs to be added to allow it. Just looking thru the code for allowing Blocks, there’s a lot of code in some of the other tabs. More than I want to try adding for Dropbox. I tried adding another texture to the Blocks folder, but it wouldn’t let me.
Hi @chrislightsaber, hopefully I can help with this one.
If you want to add a single texture from documents or dropbox you can do the following
scene.voxels.blocks:addAsset("Documents:My Asset") local newBlockType = scene.voxels.blocks:new("NewBlockType") newBlockType.setTexture(ALL, "Documents:My Asset")
I just tried this with a random image from my documents folder and it appeared to work. At the moment the image must be a PNG, which it will warn you about it you try to use some other image type. You can also create a custom asset pack and use the Files app to place it in Codea which would allow you to use
Have a look at this thread if you want to see how to make a new asset pack: https://codea.io/talk/discussion/9218/project-asset-packs
Thanks @John sadly when I try this the block places but has not texture still :neutral:
That black square is a hole in the ground that I can fall through. It’s where I placed the new block I made with the texture that I added. If I change the texture to be one from the blocks pack this does not happen though
This is the exact code I’m using. Also no item icon appears its empty in my inventory but I can place it
local newBlockType = scene.voxels.blocks:new(“NewBlockType”)
That works fine if I’m making a normal cube, but i was trying to do this in the voxe, terrain project. I tried adding a block with custom image but it doesn’t work
This is my code:
local test2 = scene.voxels.blocks:new(“Test2”)
@chrislightsaber I found this code in the example Block Library, basic tab. I wonder if you need something like this for the Dropbox folder.
-- Assets must be added to the voxel system for them to be available scene.voxels.blocks:addAssetPack("Blocks")
Ive tried this but it errors when I add it in sadly
It says unable to find asset named documents:rock moss
The rock moss is the first texture from the blocks asset pack so maybe I need to change something
Do you have Documents capitalized and do you have rock moss in the Documents folder. I’m just guessing at all this stuff because I haven’t played around with changing anything in the examples.
Yes and no I don’t have moss in the assets folder.
Look at the Basic tab in the Block Library example. That might give you some ideas. That seems to be where everything is created.
@dave1707 That’s where I’ve tried to do everything. The issue is that new textures can not be set other than the ones from the blocks assets. And if I try to add a new asset it errors. I’m quite uncertain what to do I’ve tried everything I can think of
@chrislightsaber I was able to change the textures on the blocks in the Block Library example, but only if I used a texture from Blocks. If I tried a texture from Dropbox, I didn’t get an error, but the block didn’t show a texture.
@chrislightsaber I used this code and my texture worked. My test image had a size of 128x128 pixels. Not sure if the size matters or if it has to be a multiple of 2.
I tried an image with a size of 256x256 and it just made a black square, no textured cube.
scene.voxels.blocks:addAsset("Dropbox:test") local newBlockType = scene.voxels.blocks:new("NewBlockType") newBlockType.setTexture(ALL, "Dropbox:test")