Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I add new texture for blocks on iPad? I’m pretty confused

Like the title suggests how do I add a new block texture?

Comments

  • dave1707dave1707 Mod
    Posts: 7,553

    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.

  • dave1707dave1707 Mod
    edited August 2018 Posts: 7,553

    @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.
    
  • 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")
    test2.setTexture (ALL,"Documents:cool")

  • dave1707dave1707 Mod
    Posts: 7,553

    @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

  • dave1707dave1707 Mod
    Posts: 7,553

    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.

  • dave1707dave1707 Mod
    Posts: 7,553

    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

  • dave1707dave1707 Mod
    Posts: 7,553

    @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.

  • @dave1707 yup this is exactly my issue too. I’m stuck there sadly. Maybe someone else will know what to do

  • dave1707dave1707 Mod
    Posts: 7,553

    @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.

  • JohnJohn Admin Mod
    Posts: 572

    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 addAssetPack() instead.

    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

    scene.voxels.blocks:addAsset("Documents:test2")
    local newBlockType = scene.voxels.blocks:new("NewBlockType")
    newBlockType.setTexture(ALL, "Documents:test2")

  • dave1707dave1707 Mod
    Posts: 7,553

    @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")
    
  • Currently I’m using this png renamed as test and it still isn’t working? It’s 128x128

  • I finally got it to work, I created a new png. The old one must have had issues
    Thanks,!!

    Also on a side note. In the original versions of the voxel app, wasn’t there supposed to be a mode in which you mine up blocks and they go into your inventory like Minecraft? Just wondering

  • dave1707dave1707 Mod
    Posts: 7,553

    @chrislightsaber Try using this to create the test image in the Dropbox folder.

    function setup()
        img=image(128,128)
        setContext(img)
        background(0, 140, 255, 255)
        fill(255)
        text("This is a test.",64,64)
        setContext()
        saveImage("Dropbox:test",img)
    end
    
    function draw()
        background(0)
        sprite(img,WIDTH/2,HEIGHT/2)
    end
    
  • Thanks all is working now besides the items icon, is there a command I need to set for that to work? Thank you a ton for all your help so far!

  • Never mind I got icons working!

    Finally, if I could ask for some advice.
    Do you know where I should start if I wanna implement a survival inventory system EX: have to gather blocks and craft stuff (kinda like Minecraft?/any survival game)

  • edited September 2018 Posts: 45

    Hey @dave1707 somehow I managed to fix the code (part by acccident I added I’m some code to make an FPS counter an dit fixed some of my issues) here’s the file if you wanna test it out
    Oops this was supposed to go in this thread https://codea.io/talk/discussion/comment/76242#Comment_76242
    I derped :neutral:

    0 FPS Thing.zip 1014.2K
Sign In or Register to comment.