How would I do that
Where are you expecting the Yes/No values from. Do you have a Yes and a No button. More info please.
Here’s a yes/no option from parameter boxes, text boxes, or the keyboard.
function setup()
showKeyboard()
rectMode(CENTER)
parameter.action("Yes",yes)
parameter.action("No",no)
print("Press y or n on the keyboard")
print("tap the yes or no parameter box")
print("tap the yes or no text box")
end
function yes()
print("yes")
end
function no()
print("no")
end
function draw()
background(0)
fill(255)
rect(100,500,80,30)
fill(255,0,0)
text("Yes",100,500)
fill(255)
rect(200,500,80,30)
fill(255,0,0)
text("No",200,500)
end
function keyboard(k)
if k=="y" then
yes()
end
if k=="n" then
no()
end
end
function touched(t)
if t.state==BEGAN then
if t.x>60 and t.x<140 and t.y>485 and t.y <515 then
yes()
end
if t.x>160 and t.x<240 and t.y>485 and t.y <515 then
no()
end
end
end
I prefer this way:
function checkFalseOrTrue(value)
if value then
-- It's true
else
-- it's false
end
end
And call the function with checkFalseOrTrue(false)
@TokOut - there’s no need for that function at all.
And dave’s example was for a yes/ no button on the screen, which is different.
But this way works too.
No it doesn’t. How does the user tell the program yes or no? By pressing a button. That’s what dave programmed.
Besides which, to test if A is true using your function, you would write
if checkFalseOrTrue(A) then
when you could simply say
if A then
So why do you need your function at all?
This is another one of those questions that doesn’t have enough information to give a correct answer. As I said in my first response above, Where are you expecting the Yes/No values from
. Another Yes/No response could come from tilting the iPad in a certain direction or just smashing the iPad on the floor for a I don't care
response.
No it doesn’t. How does the user tell the program yes or no? By pressing a button. That’s what dave programmed.
Then why you need any function at all?
when you could simply say
if A then
To safe place.
Sounds like you should read about how “if statements” work and boolean logic, @TokOut