Help on if -- then and tables

Thanks Jay. Should I wait for the new course? or buy both?

As far as the code I put this

local bg = display.newImage (“bg.png”)
local cat = display.newImage (“cat.png”,80,10)
    cat:scale  (.5, .5)
    
local pics = {“sun.png”, “cat.png”, “tree.png”}

local i = math.random(#pics)
local chosenPic = pics[i]
local obj = display.newImage(chosenPic)

And nothing happens!

what am I doing wrong?

Victor

what am I doing wrong?

 Have no idea. Are the sun.png. etc., pics in the project? Or are they down in a folder? If so, then you need to include that folder name in there some where.

 Jay

I try this

local bg = display.newImage (“bg.png”)
local cat = display.newImage (“cat.png”,80,10)
    cat:scale  (.5, .5)
   
local pics = {“sun.png”, “cat.png”, “tree.png”, “bat.png”, “bee.png”, “ladyBug.png”, “ant.png”}
local i = math.random(#pics)
local chosenPic = pics[i]
local obj = display.newImage(chosenPic)

for i = 1, #pics do
    local i = math.random(#pics)
    local chosenPic = pics[i]
    local obj = display.newImage(chosenPic)
end

And it works!

I put the 3 lines you told me, inside a for i = #pics do ------------- end

and it works I can see a random image everytime I run the code – GREAT!

now:

I see the sun, and then the cat, on top of the sun, then the tree on top of the ant…

How do I show one image at a time?

thanks

Victor

How do I show one image at a time?

You are showing one image one at a time. Just because your eyes don’t send the messages to your brain fast enough for you to distinguish that isn’t the fault of the code.

So you need to ask a different question.

 Jay

PS - Not trying to be difficult, your question just doesn’t mean anything that I can interperet.

PPS - Why are all three images being shown? What in your code makes that happen? If you don’t want to show three images, then don’t do the thing that causes three images to show.

Thanks for taking the time to make me think in a different way.

I just don’t know a lot, in fact, I’m very new at all this. I don’t ask the “correct” questions

because I don’t know how to ask, or what to ask. – I’m learning.

And thanks to people like you, that takes the time, to teach me something

that’s how I know a few things.

I kept thinking, and I think the loop runs 4 times, so the code shows me 1 picture, then 1 more, and another and the last one

but it goes so fast, that I just see the last one, and all the other ones underneath.

I think that’s what’s happening.

So – and forgive me if I’m not asking the correct question –

How do I make a code that will pick just one random image from a table with a lot of images, and display just one

new one every time?

I hope you understand what I’m trying to do.

Thanks

Victor

I’m afraid that though this is the ‘newbie’ forum, far too many people are expecting help with newbie programming questions, when this is really for newbie ‘corona sdk’ questions…

you are asking how to play bach’s 5th concerto before you even know the letters on the keys…you need to learn lua and basic programming before you can help yourself…

Hi sean84

Thanks for the advice.

Would you please  tell me:

1.- Where can I go to learn “the letters on the keys…”?

2.- If this is “only” for “‘corona sdk’ questions…”, could you give me an example of what kind of questions I can ask?

3.- “far too many people are expecting help with newbie programming questions,” Where do I learn basic programming?

Thank you for your time and advice.

I’m learning and I don’t know where to start or where to look for.

Victor

Google is really useful. Look, I type LUA and hit enter. It spits out a gazillion entries. The first one however points me to : 

The LUA Programming Language - http://www.lua.org/ … That’s your answer to comment #1.

You need to to search more and see if you can develop some skills. Internet really is amazing when it comes to picking up technical skills. You need to know what to look for thats it.

You might want to consider registering for a programming 101 type course at your local community college or something. 

Thanks I’m going to study that.

Just by any chance, and I’m sorry for asking.

Do you know what’s this error mean.

The application wrapper must end in .app /var/folders/kh is invalid

I got this in Application loader on Xcode, trying to summit my app

Any ideas?

Vctor

Sorry. No I don’t know that error. 

thanks