Parental Gate for Apple - Math problem

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Parental Gate for Apple - Math problem

Post by stephenelkins » Thu Nov 13, 2014 10:34 am

I'm trying to figure out how to go about this parental gate for Apple. I'm still a little new with LiveCode and app development in general. With that, the parental gate I'm going to do is the question "what numbers are divisible by three?" I'm using this webpage as an example ... parentalgate<dot>com/wp-content/uploads/2013/09/parental_gate_ios_appstore1.png

So, how would I go about this? For mine, I will have the numbers 3,6,9 that would need to be pressed to essentially unlock the page. I'm not even sure where to begin. I have created buttons numbering 1-9. But, due to overuse, my brain is blank:D Any help/push in the right direction is deeply appreciated.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Parental Gate for Apple - Math problem

Post by dunbarx » Thu Nov 13, 2014 3:13 pm

Hi.

Could not access the full URL. Something is wrong with it.

Are you asking for a stack that will only allow access to the webpage if the question is answered correctly? Where are you with LC? Can you create objects on a card? Can you edit the scripts of those objects and compose a handler? Write back. The gadget you are requesting, if I have it right, will be a handler of about five lines in a button. But before we just hand that to you, let us know where you are in your learning curve.

This should be moved to the beginner's section. Klaus?

Craig Newman

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Thu Nov 13, 2014 5:26 pm

Hi Craig!
Thanks for your reply. I would say I am late beginner. Still have a long ways to go, but have done a bit with scripting and creating objects. Sorry about the link ... I replaced "com" with "<dot>com" because I'm restricted from posting links. Anyway to remove that restriction? My bad about posting in the wrong section. I saw "Talking Live Code" and just now realized it is under Intermediate section.

I am going to work on the buttons again. Only spent a little bit on them late last night since I spent the bulk of my day trying to figure out how to hold down on screen with 2 fingers for 3 seconds to move to another card for parental gate. Couldn't figure that out either. Any suggestions for that too? Would get close but then something would break.

So, I'm going to work more on the buttons. If you have any suggestions on where to start that would be awesome. I like to figure things out as I go so, yeah, I'm definitely not expecting anybody to hand the answer to me. Just wanting to learn more.

Thanks again Craig!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Parental Gate for Apple - Math problem

Post by Simon » Thu Nov 13, 2014 9:32 pm

Hi stephenelkins,
Here is the lesson on multi-touch;
http://lessons.runrev.com/m/4069/l/1149 ... one-object
Now that lesson is very skimpy on details, it has 2 blocks of code with only 1 line different. But look closely at the names of the handlers.
on touchStart pTouchId...
what is not said explicitly is that you can have multiple pTouchId's all at the same time, each of them are unique and referenced by that number.

Make sense?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Thu Nov 13, 2014 11:41 pm

Hey Simon. Thanks for the reply. That's the tutorial I started with. Then, I went into dictionary within LiveCode and figured out more. I actually had no problem with the multi-touch part itself. I couldn't make it so you had to hold down with 2 fingers for 3 seconds before it would go to next card. Every time, it would open with a tap 3 seconds later. I tried so many different variations that I don't remember everything I tried now. I know it's probably a line or two of code that'll make it work but I just can't get it. If I can remember what I tried I'll post it ... should have taken notes, but I thought it was gonna be fairly easy for me.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Parental Gate for Apple - Math problem

Post by Simon » Thu Nov 13, 2014 11:59 pm

Rats!
This is a fun one but I'm not supposed to solve it for you.
I wish I had a need for it... heck maybe I'll just try. :)

I'm thinking you need 2 touchId's to be constant for 3 seconds.
touchend would reset the counter if it contained one of the Id's before 3 seconds were up.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Parental Gate for Apple - Math problem

Post by Simon » Fri Nov 14, 2014 1:21 am

Hi stephenelkins,
I wouldn't say this was easy.
I did it but I used "send in time" and "number of items" which may be easy for some.
Here is my outline
touchStart
put the id's into a var
if there are 2 items in the var start the timer

touchStop
if 1 of the id's is in my var then reset timer put empty into the var

timer
if the var is empty leave the timer
else
send timer to me in 100 millisec -- do your counting as well

Ok so that reads very poorly, but it has all the elements. If you were able to decipher multiple touches had different id's from that lesson you should get this. :)

Craig, see I did this without posting any real code :)

I dislike HTH (dunno why) but it is the intent.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Parental Gate for Apple - Math problem

Post by dunbarx » Fri Nov 14, 2014 6:57 am

Simon.

I am not so hard-hearted. Give him what he needs. Just make him work for it, is all. That seems only fair, and is what I really want newbies to have to do. I want them to get fired up, and work all night, because they are compelled to and want to. If that happens, then handing over working scripts is just fine.

Craig

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Fri Nov 14, 2014 2:53 pm

Simon,
Thank you so much for your help. I look forward to messing with the code today. You gave me a great direction to follow. If I am able to get this down, I will be able to create the gate sample that Apple provided, and probably get approved. I do have a couple questions about my "divisible by 3" scenario ...

1) This is probably easy, but, when a correct button is pushed, what function would "hold" button down until the other answers are selected to proceed?
2) My plan is to take user back to main menu as soon as wrong answer is selected. Got that code, or course. But, once again, probably simple, how would I contain the answers until all 3 right answers are chosen?

Once again, thanks for sharing your wisdom with me, Simon.


Craig,
No worries here. I want to work on this code. If it's handed to me, I've learned nothing. I really appreciate the atmosphere on LiveCode forums. A direction is all I need to get going, to unlock new ways of writing code. Thanks for keeping the integrity of the site with us "noobs:)"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Parental Gate for Apple - Math problem

Post by dunbarx » Fri Nov 14, 2014 4:42 pm

stephenelkins

That's the attitude, all right.

I do not develop for mobil, so I am always a bit off. But when you say "hold" the button down, do you mean just as visible feedback? You can always set the hilite of the button, and clear it later. Or set its backColor.

For the second, have you started playing with custom properties?

Code: Select all

if the answer is "no" then getGoing
Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7266
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Parental Gate for Apple - Math problem

Post by jacque » Fri Nov 14, 2014 5:48 pm

The first thing we tell new users is to study other people's scripts. I don't think of the forums as a classroom but rather a place to share. See StackOverflow for what I consider a good example.

No need to apologize if you post code. If you have a neat solution to a question why not show everyone?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Fri Nov 14, 2014 6:07 pm

Craig,

What I'm thinking with "holding" the button is more about can I store a button push until the remainder of the buttons that need to be pushed are pushed (there's gotta be a better way to say that:D) So, an example ...

Parental Permission Required
What numbers are divisible by three?
I then have random buttons from 1 to 9. The buttons that need to be pushed are 3,6,9. So, if I push 3, I need to write code that holds off on going to the "Parents Section" until the 6 and 9 are pushed. I'm thinking it's probably going to be a string of "if" statements. Like ...

on mouseUp
if button 3 is pressed and
if button 6 is pressed and
if button 9 is pressed then

go to card "ParentsMenu"
end if
end mouseUp

I feel like my knowledge of syntax is limited at this point because I'm not sure how to turn that into workable code yet. I know what I need to do, I just don't have enough knowledge yet to get there. I'm on the cusp, just need more syntax absorption time:D Which is why I really appreciate the help you and Simon have both offered. Thanks!

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Fri Nov 14, 2014 6:11 pm

Hmmm ... custom properties. I feel like I need to play with this. I think my Saturday morning is now planned;P

stephenelkins
Posts: 11
Joined: Wed Nov 12, 2014 6:28 pm

Re: Parental Gate for Apple - Math problem

Post by stephenelkins » Fri Nov 14, 2014 6:51 pm

So, here's the code I have so far. It does what I want to hilite the buttons. But, won't move to next card. I get no errors, but no movement.

** each button script **
on mouseUp
set the hilite of me to true
put me into tButtons
end mouseUp

** card script **
local tButtons
on tButtons
if the hilite of button "button3" + button "button6" + button "button9" is true then
go to card "ParentMenu"
end if
end tButtons

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Parental Gate for Apple - Math problem

Post by dunbarx » Fri Nov 14, 2014 7:03 pm

Hi.
if the hilite of button "button3" + button "button6" + button "button9" is true then
That is a perfectly good way to attack the problem, at least intellectually. About the syntax, though, what did Wolfgang Pauli once say? Ah yes: "...it isn't even wrong".

We never want to add the hilites of buttons together. That would be bad, like crossing the streams. But you are on track. Write back when you have this fixed.

Also, I would think you want to check the validity of the current suite of button presses right at each press, not at another press of another "checking" button. Can you rewrite your handlers to make this happen?

As for custom properties and your weekends, do play with them. They are immensely powerful and simple. Once you have fixed the issue above, rewrite it using a custom property. There are about a million way to do that, and you should not stop until you have three, but the real issue is to understand how a custom property can hold information, be updated, and then interrogated to good purpose. How are these similar to fields? How are they different? Could you use a field?

Craig

Post Reply

Return to “Talking LiveCode”