I think that's what your talking aboutZitat:
Zitat von Grimfate126
Printable View
I think that's what your talking aboutZitat:
Zitat von Grimfate126
okay, what is wrong with this?
I dont know how to make the randomization start...Code:yellow = Color.new(255, 255, 0)
math.randomseed(os.time() )
while true do
number = math.random(1,4)
if number == 1 then
screen:print(0, 0, "Poo", yellow)
end
if number == 2 then
screen:print(0, 0, "Monger", yellow)
end
if number == 3 then
screen:print(0, 0, "Turd", yellow)
end
if number == 4 then
screen:print(0, 0, "Face", yellow)
end
end
the random should be fine
i just tested it and it does work
forgot to hit edit.sorry for double post
I assume that the two previous posts were directed toward my question. Assuming so, that's not what I"m trying to do. I'm printing 4 random variables to the screen at one time and I don't want any of them to be the same as another. An example would be if you put each variable as equaling math.random(1,4) for all 4 variables to print to the screen it would print a random variable for each one put there is a chance you would get two 1's or two 2's or three 1's. I am trying to develop a system that would check if any of the variables are the same and repeat randomizing numbers until one is found that isn't already used.
function randomnumbers()
while true do
var1 = math.random(1,4)
var2 = math.random(1,4)
var3 = math.random(1,4)
var4 = math.random(1,4)
if var2 == var1 then
var2 = math.random(1,4)
end
if var2 == var3 then
var2 = math.random(1,4)
end
if var2 == var4 then
var2 = math.random(1,4)
end
if var3 == var1 then
var3 = math.random(1,4)
end
if var3 == var4 then
var3 = math.random(1,4)
end
if var4 == var1 then
var4 = math.random(1,4)
end
if var1~=var2 and var2~=3 and var1~=var3 and var1~=var4 and var2~=4 and var3~=var4 then
break
end
end
I need help. I can get everything to work but the dPad.
Code:--Basic Variables
white = Color.new(255,255,255)
titlePlay = Image.load("titlePlay.png")
titleInfo = Image.load("titleInfo.png")
titleExit = Image.load("titleExit.png")
titleNumber = 1
dPad = Controls.read()
--Main Menu
function mainMenu(titleNumber)
if titleNumber == 1 then
screen:blit(0,0,titlePlay)
screen:flip()
end
if titleNumber == 2 then
screen:blit(0,0,titleInfo)
screen:flip()
end
if titleNumber == 3 then
screen:blit(0,0,titleExit)
screen:flip()
end
if titleNumber < 1 or titleNumber > 3 then
screen:print(0,0,"error in titleNumber", white)
screen:flip()
end
end
--Main Menu D-Pad Controls
if dPad:right then
titleNumber = titleNumber + 1
mainMenu(titleNumber)
end
--I Dont Know
while true do
screen.waitVblankStart()
end
Disregaurd my question. I figured it out myself :icon_bigg .
Put everyting but the variable defines in the while true loop. Don't forget screen:clear()Zitat:
Zitat von siqq
testing...
[edit] It didnt work my code looks like this now.
Code:
--Basic Variables
white = Color.new(255,255,255)
titlePlay = Image.load("titlePlay.png")
titleInfo = Image.load("titleInfo.png")
titleExit = Image.load("titleExit.png")
titleNumber = 1
pad = Controls.read()
while true do
--Main Menu
function mainMenu(titleNumber)
if titleNumber == 1 then
screen:clear()
screen:blit(0,0,titlePlay)
screen:flip()
end
if titleNumber == 2 then
screen:clear()
screen:blit(0,0,titleInfo)
screen:flip()
end
if titleNumber == 3 then
screen:clear()
screen:blit(0,0,titleExit)
screen:flip()
end
if titleNumber < 1 or titleNumber > 3 then
screen:clear()
screen:print(0,0,"error in titleNumber", white)
screen:flip()
end
end
--Main Menu D-Pad Controls
if pad:right() and titleNumber < 3 then
titleNumber = titleNumber + 1
mainMenu(titleNumber)
end
if pad:left() and titleNumber > 1 then
titleNumber = titleNumber - 1
mainMenu(titleNumber)
end
end