Howdy, Stranger!

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

Getting black screen in Craft?

edited November 3 in Questions Posts: 31

So I recently got into Codea, tried making a simple scene. Any reasons i'm getting a black screen?

function setup()

    scene = craft.scene()

    scene.camera.position = vec3(0, -10, 0)

    scene.sun.rotation = quat.eulerAngles(45,0,45)
    scene.ambientColor = color(255)

    scene.fogEnabled = true
    scene.fogNear = 10
    scene.fogFar = 50
    scene.fogColor = color(0,205,255)

    skyMaterial = scene.sky.material
    skyMaterial.sky = color(0, 55, 255)
    skyMaterial.horizon = color(0,200,250)
end
function update(dt)
    scene:update(dt)
end
function draw()
    update(DeltaTime)
end

Comments

  • Posts: 31

    forgot to include, I already have this
    function startup()
    code here
    end

  • dave1707dave1707 Mod
    edited November 1 Posts: 8,671

    @Exyon Your above code should work. I guess the color values need changing, but there’s nothing to really show. Here’s some basic code to play with. You can modify the code to try different things.

    When you post code, put ~~~ ( 3 tildes) on a line before and after the code so it formats correctly. I added them to your above code.

    viewer.mode=FULLSCREEN
    
    function setup()
        assert(OrbitViewer, "Please include Cameras as a dependency")
    
        scene = craft.scene()
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
        v.rx,v.ry=20,20
    
        c=scene:entity()
        c.model = craft.model.cube(vec3(25,10,10))
        c.material = craft.material(asset.builtin.Materials.Standard)
        c.material.map = readImage(asset.builtin.Blocks.Trunk_White_Top)
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()
        fill(255)
        text("Drag your finger on the screen to rotate the box",WIDTH/2,HEIGHT-100)
    end
    
    function update(dt)
        scene:update(dt)
    end
    
  • Posts: 31

    @dave1707 Thanks! I'm having trouble figuring out what things do; the reference in Codea doesn't include everything. Is there anywhere I can find all fo them? Also, is there some way to contact you other than in this website? Ex. Discord. I need helping making my own textures.

  • Posts: 31

    Also, now it's getting a black screen even with your code alone.

  • dave1707dave1707 Mod
    Posts: 8,671

    @Exyon When you were getting the black screen, did you have my exact code above. Did you try to close the project, exit Codea, go back into Codea, load my code, and it worked OK. I reported a similar problem where I had a black screen on a lot of different projects. When I exited Codea and got back in, I tried everything and they all worked.

    PS. What type of iPad do you have, what version of iPadOS, and what version of Codea.

  • dave1707dave1707 Mod
    Posts: 8,671

    @Exyon The reference is all there is. I would suggest that you look thru the Craft examples or search for Craft examples in this forum. As for creating textures, you might want to look at Shade, also by TwoLivesLeft. You might find examples on Facebook, or Twitter. I don’t use Shade, but then I’m not after a lot of different textures other than what’s in Codea. As for contacting me, there’s PM. Just tap on my name and it should bring up another page with Message in the upper right. Tap that, enter text and send. I don’t normally do PM because any questions and answers might also be important to the other users on the forum. You can just ask questions in the forum. Just don’t start a different discussion for different questions, keep them together.

  • Posts: 31
    @dave1707 Hey, sorry busy with work. Yes, I only have your code, nothing else. I tried putting the scene update on a different function draw from text, but that didn't work. It's not an error code so I believe your code is good. I closed Codea and reopened it but still no luck, and I'm using an iPhone 11 on iOS 14.2. Also, about the textures, I was able to import them, whoever, when importing materials from Shade, it doesn't load. One last thing, do you know how to create models? I have blender on my pc, but it's broken atm. Anything on iOS you recommend?
  • dave1707dave1707 Mod
    Posts: 8,671

    @Exyon Are you getting the black screen on any of the Codea Craft examples. I don’t mess around with models or textures other than what’s in Codea. I’m sure others will reply to your questions.

  • edited November 2 Posts: 31
    @dave1707 Nope, only on the project with your code, the voxel terrain generator works just fine. And thanks, i'll see what i can find.
  • Posts: 31
    Well I deleted the project and copied the code you made again and was able to get it to work. Maybe there was something wrong with the files of the other project, but I don't know how it works so i can't say for sure. Thx
  • dave1707dave1707 Mod
    Posts: 8,671

    @Exyon You can ask all your questions in this discussion. I’m deleting your question in the other discussion. and moving it here.

    Hi uh, didn't wanna start another post so I decided to comment on your post since you seem good at coding. Anyhow, just wondering if you could explain what "self.speed" or "self.maxForce" means. Is "self." a variable to itself? and how are they set?

    Self is a variable used in a class. Functions and variables in a class can have many copies of itself, and the self variable refers to one instance of those variables. I’m not sure how much experience you have with classes, but they make coding easier for larger programs where you have a lot of occurrences of an object.

  • Posts: 31
    @dave1707 Oh sorry, I didn't wanna keep bothering you. Well, I know how to create a class and use it on another object, as a matter of fact, I'm having a class related problem. So two questions, so "self" is basically a "local" but only for the class? and lastly, i keep getting an error saying it doesn't know what "add" is, I checked to see if i'm missing something but i've got no idea. anything wrong with it?
    ~~~
    player = scene:entity():add(BasicPlayer, scene.camera:get(craft.camera), 40, 20, 40)
    ~~~
  • dave1707dave1707 Mod
    edited November 2 Posts: 8,671

    @Exyon You’re not bothering me. No matter where you post your questions, I’ll see them and will answer them if I can. You’re correct in saying that self is local for that class. As for your other question, I’m not sure what the problem is. There’s too many things there without see more of the code. Maybe one of the other users will be able to give you the answer.

    I noticed that a similar line is in several of the Craft example projects and BasicPlayer is a class. Do you have the BasicPlayer class.

  • Posts: 31
    @dave1707 I hope i'm not haha. Oh, so do they work the same as a variable? also, the code error was on my part. Quick question, how do I change the textures on the craft examples?
  • Posts: 31
    i have my textures in documents btw
  • dave1707dave1707 Mod
    Posts: 8,671

    For instance, in my above example, if you tap on (asset.builtin.Blocks.Trunk_White_Top) between the ( ) it brings up a asset list of what you can use. In your case, select the Documents folder and tap on what you want.

  • Posts: 31
    @dave1707 there's no purple thing, check the example "block library" and look under "Basic" I tried changing it to (ALL, "Documents:Test") but it loads an invisible texture.
    ~~~
    local stone = scene.voxels.blocks:new("Stone")
    stone.setTexture(ALL, "Blocks:Stone")
    ~~~
  • dave1707dave1707 Mod
    Posts: 8,671

    Blocks is something different, you’ll have to look thru that code and figure out what needs to be done. I haven’t tried doing anything with it.

  • AnatolyAnatoly Mod
    Posts: 891

    Renamed title

    @Exyon avoid "Help" and "Nothing works" in title in the future, always be precise :)

  • Posts: 31
    @Anatoly Hi, sorry, I'm new to the community and the site is a little confusing. @dave1707 been messing with craft and managed to get my own textures and such. Is there a way for me to resize existing blocks to be smaller without creating new ones?
  • Posts: 31
    I couldn't find a way so I just scaled the player instead, made simple blocks so that the increase in voxels wouldn't lag. and made the terrain a lot bigger :) now I just need to make my own hotbar since I deleted the previous one because I didn't need an inventory but the only way to use it was by having one. I'll let you know how it goes
Sign In or Register to comment.