on mouseDown
clone group "tMOVE"
put fld "fLAP" into XXX
set the name of the last group to ("t" & XXX)
set the left of the last group to ((the left of group "tMOVE") + 50)
set the top of the last group to ((the top of group "tMOVE") + 50)
end mouseDown
Now, while that will CLONE the group, the code in the cloned group needs to be changed.
on mouseDown
clone group "tMOVE"
put fld "fLAP" into XXX
set the name of the last group to ("t" & XXX)
set the left of the last group to ((the left of group "tMOVE") + 50)
set the top of the last group to ((the top of group "tMOVE") + 50)
add 1 to fld "fLAP"
put fld "fMOVECODE_1" into MC1
put fld "fMOVECODE_2" into MC2
set the script of img "moveBACK65.png" of group ("t" & XXX) to (MC1 & XXX & MC2)
end mouseDown
We now have to modify the script in the cloned group to make sure it can be dropped into the graphic rectangle drop-target, or deleted.
As it is not possible to delete an object from within its own script, we need to rename a group we wish not to use and 'park' it off screen: it can be deleted at a later time.
on mouseDown
if exists(group "HAPPY") then
delete group "HAPPY"
end if
clone group "tMOVE"
put fld "fLAP" into XXX
set the name of the last group to ("t" & XXX)
set the left of the last group to ((the left of group "tMOVE") + 50)
set the top of the last group to ((the top of group "tMOVE") + 50)
add 1 to fld "fLAP"
put fld "fMOVECODE_1" into MC1
put fld "fMOVECODE_2" into MC2
put fld "fMOVECODE_3" into MC3
put fld "fMOVECODE_4" into MC4
put fld "fMOVECODE_5" into MC5
set the script of img "moveBACK65.png" of group ("t" & XXX) to (MC1 & XXX & MC2 & XXX & MC3 & XXX & MC4 & XXX & MC5)
end mouseDown
You will see that ALL the new script components of the cloned group are stored in a series of fields:
-
Screenshot 2024-07-03 at 15.59.00.png (77.28 KiB) Viewed 15971 times
-
This is obviously an extremely inefficient way of doing things.
It should also be clear that every time one clones a group it should end up on a different drop-target.
-
Screenshot 2024-07-03 at 16.21.52.png (175.52 KiB) Viewed 15966 times
on mouseDown
if exists(group "HAPPY") then
delete group "HAPPY"
end if
clone group "tMOVE"
put fld "fLAP" into XXX
set the name of the last group to ("t" & XXX)
set the left of the last group to ((the left of group "tMOVE") + 50)
set the top of the last group to ((the top of group "tMOVE") + 50)
add 1 to fld "fLAP"
put fld "fMOVECODE_1" into MC1
put fld "fMOVECODE_2" into MC2
put fld "fMOVECODE_3" into MC3
put fld "fMOVECODE_4" into MC4
put fld "fMOVECODE_5" into MC5
put fld "fMOVECODE_6" into MC6
put fld "fMOVECODE_7" into MC7
set the script of img "moveBACK65.png" of group ("t" & XXX) to (MC1 & XXX & MC2 & XXX & MC3 & XXX & MC4 & XXX & MC5 & XXX & MC6 & XXX & MC7)
end mouseDown
on mouseDown
if exists(group "HAPPY") then
delete group "HAPPY"
end if
clone group "tMOVE"
put fld "fLAP" into XXX
set the name of the last group to ("move" & XXX)
set the left of the last group to ((the left of group "tMOVE") + 50)
set the top of the last group to ((the top of group "tMOVE") + 50)
add 1 to fld "fLAP"
put the X1 of button "MOVE_CODE" into MC1
put the X2 of button "MOVE_CODE" into MC2
put the X3 of button "MOVE_CODE" into MC3
put the X4 of button "MOVE_CODE" into MC4
put the X5 of button "MOVE_CODE" into MC5
put the X6 of button "MOVE_CODE" into MC6
put the X7 of button "MOVE_CODE" into MC7
set the script of img "moveBACK65.png" of group ("move" & XXX) to (MC1 & XXX & MC2 & XXX & MC3 & XXX & MC4 & XXX & MC5 & XXX & MC6 & XXX & MC7)
end mouseDown
on mouseDown
if exists(group "SAD") then
delete group "SAD"
end if
clone group "xTURN"
put fld "fLAP" into XXX
set the name of the last group to ("turn" & XXX)
set the left of the last group to ((the left of group "xTURN") + 50)
set the top of the last group to ((the top of group "xTURN") + 50)
add 1 to fld "fLAP"
put the X1 of button "TURN_CODE" into TC1
put the X2 of button "TURN_CODE" into TC2
put the X3 of button "TURN_CODE" into TC3
put the X4 of button "TURN_CODE" into TC4
put the X5 of button "TURN_CODE" into TC5
put the X6 of button "TURN_CODE" into TC6
put the X7 of button "TURN_CODE" into TC7
set the script of img "turnBACK65.png" of group ("turn" & XXX) to (TC1 & XXX & TC2 & XXX & TC3 & XXX & TC4 & XXX & TC5 & XXX & TC6 & XXX & TC7)
end mouseDown
AND we must load the new code for the cloned TURN group into the custom properties of a button called 'TURN_CODE'.
-
Screenshot 2024-07-04 at 18.16.30.png (491.78 KiB) Viewed 15947 times
on mouseEnter
lock screen
set the coloroverlay["color"] of me to blue
set the coloroverlay["opacity"] of me to "75"
unlock screen
end mouseEnter
on mouseLeave
set the outerGlow of me to empty
set the colorOverlay of me to empty
end mouseLeave
on mouseDown
set the ink of me to notsrcor
end mouseDown
-
Screenshot 2024-07-05 at 16.29.38.png (49.09 KiB) Viewed 15920 times
This restricts the choices available to an end-useer:
The distances available are 1, 2,3, and 4.
As the distance between the centre of one square and an adjacent one is 120 pixels, the turtle will move in multiples of 120.
-
Screenshot 2024-07-22 at 15.53.31.png (124.54 KiB) Viewed 15187 times
-
The angles available are 90, 180, 270 degrees.
As angles such as 154 would involve quite complicated calculations to ensure the turtle travelled exactly to the centre of the nearest square these types of possibilities are best avoided.