So I recently got into Codea, tried making a simple scene. Any reasons i’m getting a black screen?
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)
forgot to include, I already have this
@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.
assert(OrbitViewer, "Please include Cameras as a dependency")
scene = craft.scene()
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
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)
text("Drag your finger on the screen to rotate the box",WIDTH/2,HEIGHT-100)
@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.
Also, now it’s getting a black screen even with your code alone.
@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.
@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.
@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?
@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.
@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.
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
@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.
@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)
@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.
@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?
i have my textures in documents btw
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.
@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")
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.
@Exyon avoid “Help” and “Nothing works” in title in the future, always be precise