How to Press button to just add one thing?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Fri Aug 02, 2013 12:14 am

How to Press button to just add one thing?

Post by no1g8tor96 » Sat Aug 04, 2018 5:36 pm

Hello All,

I a working on a Baccarat Training Tool that put old shoes in and allows the person to do one hand at time to play the next hand. I already figured out how to populate it all at once using "Repeat with" statements but I need to put one at a time in and press the button each time to put the next "Dot" in place.


here is the code for the "show complete shoe" and it works perfect. Is there a way to to have the repeat with statements wait for a button press each time or how would i do this one by one. The button sets all the variables and clears the grid as well. Just want to hit it each time and have a dot appear in the right spot. This way the user can see just one hand at a time like playing in a casino.

Thanks again so much. This is the last step and its done except to make it look pretty..lol

Mike

-- Show complete shoe
Put "1" into ShoeColumn
Put "1" into shoeLine
put " " into field "BacCard"
Set the itemDel to space
put "0" into tNoHands
put "0" into tNoBankers
put "0" into tNoPlayers

--set P or B start of Game
put char 1 of fld "ShoeInfoFromList2" into PBstart
delete char 1 of fld"ShoeInfoFromList2"
delete char 1 of fld"ShoeInfoFromList2"
--how many colums are to populate
put the number of items of fld "ShoeInfoFromList2" into tmpcolums


repeat with col = 1 to tmpcolums
Set the itemDel to space
Put item col of fld "ShoeInfoFromList2" into tmpcolums2
repeat with lin = 1 to tmpcolums2
Set the itemDel to tab
put tNoHands +1 into tNoHands
--swith between colors
if PBstart = "B" then
put "1141" into PBColor
put tNoBankers +1 into tNoBankers
else if PBstart = "P" then
put "1142" into PBColor
put tNoPlayers +1 into tNoPlayers
end if
put "1" into of char 1 of item col of line lin of field "BacCard"
set the imagesource of char 1 of item col of line lin of field "BacCard" to PBColor
end repeat
--switch color
if PBstart ="B" then
Put "P" into PBstart
else if PBstart ="P" then
Put "B" into PBstart
end if
end repeat
--populate stats
Put tNoHands into fld "NoHands"
put tNoBankers into fld"NoBankers"
Put tNoPlayers into fld"NoPlayers"
Attachments
pic all hands.PNG

Xero
Posts: 41
Joined: Sat Jun 23, 2018 2:22 pm

Re: How to Press button to just add one thing?

Post by Xero » Mon Aug 06, 2018 7:17 am

I'm no Klaus, but can't you just use the "repeat" sections in an "on mousedown" section? And keep track of columns using a variable?
I am not sure exactly what is going on with the code per se... I'd be better if I had a stack rather than an image... but if the repeat is doing something, then returning to the top of the repeat, and continuing until a point, it would make sense to do a mousedown command, with an if statement to check the number of columns so you don't go too far.

Code: Select all

on mousedown
if -- the number of columns-- < tmpcolumns then
--do stuff--
else
exit mousedown
end mousedown
which should only do stuff if: a) a mousedown is detected and b) the number of columns is under a certain amount, effectively allowing it to "repeat" a function until a certain point is reached.
Again... I'm no Klaus...
BB
XdM

bogs
Posts: 3483
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to Press button to just add one thing?

Post by bogs » Mon Aug 06, 2018 12:59 pm

Xero wrote:
Mon Aug 06, 2018 7:17 am
I'm no Klaus
Me either, I'm not even a Xero :P

I agree with your assessment though, a repeat loop and conditional statements would be used to determine what gets put when and how. Lets wait till we find out what Klausimusius says about it though :wink:
Image

no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Fri Aug 02, 2013 12:14 am

Re: How to Press button to just add one thing?

Post by no1g8tor96 » Wed Aug 08, 2018 3:27 am

Hey Guys

Sorry for the late reply. I got the project done and its amazing. It maybe a tool to sell. I did not know Baccarat was as big as it is.

Thanks again to all of you for your help.

Mike

bogs
Posts: 3483
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to Press button to just add one thing?

Post by bogs » Wed Aug 08, 2018 4:54 am

Congrats Mike :)
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”