Underneath

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: FourthWorld, heatherlaine, Klaus, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Mon Aug 29, 2016 6:42 pm

I suggest an other way without cloning
The more recipes for achieving one goal the better; even if only to prove how versatile
Livecode is.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Tue Aug 30, 2016 9:01 am

it can't be removed once placed
I solved that by putting empty into the script of the letter tile once it has been placed
as I could think of no other way to perform an "ungrab".

To do that I had to both modify the code in the field "fscrip" and introduce the button "CHANGER".

I also popped a colorOverlay routine in there so that the cloned tile did not blend into the background
of the tile templates.
CRAZYL3.jpg

Removed link as replaced by file in later posting.
Last edited by richmond62 on Tue Aug 30, 2016 7:49 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Tue Aug 30, 2016 9:08 am

Things still to do:

1. Prevent the possibility of piling multiple piles in one location [is this strictly necessary?].

What does one do for chronic piles?

2. Further suggestions Please!

3. This [cooperative programming] should be at the heart of Open Source software.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Underneath

Post by sturgis » Tue Aug 30, 2016 2:40 pm

One more thing you might consider, get rid of field fscrip entirely. Since you're doing a name change of the new tile, its easy enough to add a conditional to your code.. if the short name of me contains ".jpg" then do the clone stuff.. (and "set the script of.." will no longer be necessary) and of course the else would contain the stuff that you had in field fscrip.

This gives the benefit that your script can be edited all in one place. And in fact, if you move it to the stack or card script you won't have to update the script for each tile, the script will truly be a one off. (a behavior would work for this too) If using it in a card script use "the target" instead of "of me." You'd still be checking the name to determine what to do on mousedown and mouseup, to make sure you ignore anything that is NOT a tile.

Follows is a card script (in the script of the card containing all the tiles" that demonstrates. Actually commented this time.

Code: Select all

on mouseDown
   lock screen
   -- all images except the letter tiles seem to start with a special char.  exit mousedown if not a tile
   if  (char 1 of the short name of the target is among the items of "%,^,$,&,*,!,+,#") then exit "mousedown"
   
   set the itemdel to "."
   switch
      -- if its an original tile do this
      case item 2 of the short name of the target contains "png"
         -- clone the target
         clone the target 
         --set the name and position the original
         set the  name of the target to item 1 of the short name of the target
         -- position the clone to take over for the target
         set the loc of the last img to the loc of the target
         -- offset the target to make the chane visible
         set top of the target to the top of the last img -5
         set the left of the target to the left of the last img + 5
         -- move the clone behind the target
         set the layer of the last img to the layer of the target
         -- take advantage of fall through...
      case char 1 of the short name of the target is not among the items of "%,^,$,&,*,!,+,#"
         -- grab the now renamed target
         -- if the first if doesn't exit the hander, and the first case doesn't match, still grab the target
         -- also, when a tile is placed it is renamed, check for this and don't pick up the tile again.
          grab the target
   end switch
   unlock screen
end mouseDown


on mouseUp
   -- if not a valid tile, exit the handler
   --if  (char 1 of the short name of the target is among the items of "%,^,$,&,*,!,+,#") then exit to top
   if  (char 1 of the short name of the target is among the items of "%,^,$,&,*,!,+,#") then exit to top
   --if  not (the short name of the target contains "placed_") then exit to top
   
   local targes
   put the short name of the target into IMENA
   put the long id of the target into tId
   put empty into fld "targes"
   -- create the list of mutable characters
   put "%,^,$,&,*,!,+,#" into tMute
   -- build the list to check the tile against
   repeat for each item tItem in tMute
      if exists(img (tItem & IMENA)) then
         put the short name of img (tItem & IMENA) & cr after targes
      end if
   end repeat
   delete the last char of targes   
   ----->>>--X--<<<-----
   
   -- determine if the drop location matches for the specific tile
   put 0 into WHATNEXT
   repeat for each line tLine in targes 
      if the mouseloc is within the rect of img tLine then
         --if intersect(tId, img tLine) then
         put 1 into WHATNEXT
         set the loc of the target to the loc of img tLine
         
         -- tag tile with % to mark tile as uncloneable/ungrabable
         -- tag with  .placed to identify for cleanup using "clearTiles" command
         set the name of the target to ("%" & the short name of the target & ".placed")
      end if
   end repeat
   if WHATNEXT = 0 then
      -- if there was no match, delete the tile
      -- no send required because the script is not running in the tile to be deleted
      delete tId -- could "delete the target" instead of storing the long id previously
      --send ("delete tId") to this card in 0
   end if
end mouseUp

command clearTiles
   set the itemdel to "."
   put the number of images of this card into tNum
   repeat with i = tnum down to 1
      if the last item of the short name of image i is "placed" then delete img i
   end repeat
end clearTiles

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Tue Aug 30, 2016 6:07 pm

One more thing you might consider, get rid of field fscrip entirely.
Yes, of course, except for the thing that I am a very conservative chap who ettles after "seeing his laundry hingin on the line".

Also, as I am not working with millions and millions of line of code (which I have elsewhere) I am not desperately trying
to shave microseconds off processor time. "Elegant" code is most definitely NOT my thing, Code that works IS my thing.
I would not doubt that there are folk who can spend days (and are prepared to) refining my offerings into far faster, far more efficient
things; but some person told me after I'd spent a day making cotter pins with iron rods, a mall and a vice that I cud hae ordred them
fae a supplier in Aberdeen; to qhilk I reponed, "Aye, and wait fae twa week til the boat fae Aberdeen til Kirkwall gets here wi yon pins,
an then I've ta tak the bus intil the toun, shoogle doun til the docks an keek aroun til ah've foun yon mon wi the pins, by qhilk ah've lost
twa days an mun be 50 pound, an ah'll ahe a scunner o a migraine forbye o the bars.' And eftir that collogue I juist connectit ma tractor
til the wain and drove doun til Linksetter fae the stane gatherin wi'oot a glisk ahint masel.


I probably learnt as much, that has subsequently served, working on a farm on Orkney, as I learnt at the 3 Universities I hold degrees from.

That is why my older son went off to work at the cash desk in a supermarket in the Turkish quarter of Berlin before he went to Munich:

https://www.youtube.com/watch?v=DShXdnUjdBc

https://www.youtube.com/watch?v=MwI6Qnu2AAA

https://www.youtube.com/watch?v=KNLdWusK8CU

https://www.youtube.com/watch?v=ebTuzhGyxlM

Lest you be mistaken, he's the one with the Mohican.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Tue Aug 30, 2016 7:50 pm


jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Underneath

Post by jmburnod » Tue Aug 30, 2016 9:14 pm

Hi Richmond,
Did you try CRAZY LETTERS001 ?
1. Prevent the possibility of piling multiple piles in one location [is this strictly necessary?].
Yes it is necessary and fixed in CRAZY LETTERS001 ?
2. Further suggestions Please!
The user have to maintain mousedown to grab a letter. That is often not easy for children
It is not necessary in CRAZY LETTERS001
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Wed Aug 31, 2016 7:16 am

The user has to maintain mousedown to grab a letter. That is often not easy for children
I don't know about that: I am dealing with children of 5 years and up, and they have sufficient motor control
that they can keep the mouse button pressed.

NO: I'm very sorry, I'm dancing around like a cat on a hotplate right now getting things up-and-running for my
new school year.

I promise (!) to take a look at your variant within 3 days.
Last edited by richmond62 on Wed Aug 31, 2016 1:14 pm, edited 1 time in total.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Underneath

Post by jmburnod » Wed Aug 31, 2016 10:45 am

Hi Richmond,
NO: I'm very sorry, I'm dancing around like a cat on a hotplate right now geting things up-and-running for my
new school year.
Dont worry. That is the same for me (new year, new students, new teachers)
...I am dealing with children of 5 years and up, and they have sufficient motor control
that they can keep the mouse button pressed.
Yes, but I think accessibility is an important point
I promise (!) to take a look at your variant within 3 days.
NO ! Just do it :D
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Wed Aug 31, 2016 1:19 pm

NO ! Just do it
I did, and the first thing that happened was that my right index finger
twitched so I did 2 mouseDowns on the "E.png" template and got in trouble:
Burnod2.png

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Underneath

Post by jmburnod » Wed Aug 31, 2016 1:43 pm

first thing that happened was that my right index finger
twitched so I did 2 mouseDowns on the "E.png" template and got in trouble:
I just tested and it works here
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Wed Aug 31, 2016 7:35 pm

I cloned the letter 'E', and then clicked on the new 'E' and got what I posted earlier:

This should be reduplicatable.

In fact it would be of great help if one or two other people downloaded your version and tried it out
and then posted some feedback here.
Burnod.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9444
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Underneath

Post by richmond62 » Wed Aug 31, 2016 8:22 pm

I owe Mike Bonner an apology for not looking at his "bash" at this stack until now.

It's always fantastic to learn something new.
Bonner1.jpg
And THAT is SO, SO much more elegant than my nonsense:

put the short name of me into IMENA
delete the last char of IMENA
delete the last char of IMENA
delete the last char of IMENA
delete the last char of IMENA
clone me

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Underneath

Post by jmburnod » Wed Aug 31, 2016 9:54 pm

Yes. Itemdel is a good way but don't forget to set the itemdel to the previous

Code: Select all

put the itemdel into tOID
set the itemdel to "."
--do something
set the itemdel to tOID
I fixed the bug in debMoveLetterMU. Sometimes tUnderID is empty :D
Thank you

Code: Select all

--•• btn "bMoveLetter" mouseup
on debMoveLetterMU 
   set the top of grc "indic" to 2000
   set the uMyJob of this cd to empty
   put getBtnLetterID(the uMyLetter of btn "bMoveLetter") into tUnderID
   if tUnderID <> empty then --•• add after v.001
      if the short name of btn id tUnderID = the uMyLetter of btn "bMoveLetter" then
         set the icon of btn id tUnderID to the icon of btn "bMoveletter"
      end if
   end if
   hide btn "bMoveletter"
end debMoveLetterMU
https://alternatic.ch

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”