Page 1 of 2
Sheep Herder
Posted: Sun May 11, 2014 11:56 am
by 44www
Hello
I am new to this forum and to livecode. I have no programing experience but livecode seamed easy to learn.
I have bought the sheep herder tutorial from livecode Academy but i get this error: (intersect: two objects are required) near "&", char 83
I still get this error after i copy the code from the pdf I got for livecode.
I am using Livecode community 6.7
Re: Sheep Herder
Posted: Sun May 11, 2014 12:02 pm
by Klaus
Hi 44www,
1. welcome to the forum!
2. Could you please post the relevant part(s) of the script that causes errors?
Not everyone has the Sheepherder stack at hand
Best
Klaus
Re: Sheep Herder
Posted: Sun May 11, 2014 12:08 pm
by 44www
Hello
I get the error here: if intersect (button("sheep"&x), graphic"pen","255") is false and intersect(button"sheep"&x),group"groupControls","0") is false then the problems seams to be in the red text.
I hope this helps you.
Re: Sheep Herder
Posted: Sun May 11, 2014 12:14 pm
by Klaus
Hi 44www,
hmm, syntax looks correct!?
Sorry, no idea without looking at the rest of the stack/scripts.
Best
Klaus
Re: Sheep Herder
Posted: Sun May 11, 2014 12:19 pm
by 44www
The code so far:
local sLevel
on levelIncrease
put empty into sLevel
add 10 to sLevel
sheepGenerate
end levelIncrease
on sheepGenerate
lock screen
repeat with x=1 to sLevel
repeat
clone button templateSheep
set the name of the last button to ("sheep"& x)
set the loc of last button to random(320), random(480)
set the visible of the last button to true
if intersect (button("sheep"&x), graphic"pen","255") is false and intersect(button"sheep"&x),group"groupControls","0") is false then
exit repeat
end if
delete button ("sheep"&x)
end repeat
end repeat
unlock screen
end sheepGenerate
Re: Sheep Herder
Posted: Sun May 11, 2014 12:24 pm
by Klaus
AH, I think I got it!
Ther are parens missing:
...
## if intersect (button("sheep"&x), graphic"pen","255") is false and intersect(button"sheep"&x),group"groupControls","0") is false then
if intersect (button ("sheep" & x), graphic "pen","255") is false and intersect(button
("sheep" & x)),group "groupControls","0") is false then
...
See the difference?
Hint: Add some spaces to your scripts for better readability!
Best
Klaus
Re: Sheep Herder
Posted: Sun May 11, 2014 12:27 pm
by 44www
The script that I put here was coppied from their pdf.... Great i paid for a lesson with errors in it. I thought about that too....
Re: Sheep Herder
Posted: Sun May 11, 2014 12:31 pm
by Klaus
So it works now?
Re: Sheep Herder
Posted: Sun May 11, 2014 12:39 pm
by 44www
No the problem is still there
Re: Sheep Herder
Posted: Sun May 11, 2014 12:42 pm
by 44www
The strange part is that I olso received a video tutorial. And in the video tutorial he doesn't get this error......
Re: Sheep Herder
Posted: Sun May 11, 2014 12:46 pm
by Klaus
44www wrote:No the problem is still there
Hm, OK, then it was not this...
Re: Sheep Herder
Posted: Sun May 11, 2014 1:29 pm
by 44www
Good news.
I instaled 6.5 and put this script :
Local sLevel
on levelIncrease
put empty into sLevel
add 1 to sLevel
sheepGenerate
end levelIncrease
on sheepGenerate
lock screen
repeat with x = 1 to sLevel
repeat
clone button templateSheep
set the name of the last button to ("sheep"& x)
set the loc of last button to random(320), random(480)
set the visible of the last button to true
if intersect (button("sheep"&x),graphic"pen","255") is false and intersect(button("sheep"&x),group"groupControls","0") is false then
exit repeat
end if
delete button("sheep"& x)
end repeat
end repeat
unlock screen
end sheepGenerate
And it works fine.The problemed seamed to be with the 6.7(dp3)
Re: Sheep Herder
Posted: Mon May 12, 2014 10:58 am
by 44www
And there is a new problem.
The code that is presented in the tutorial does the opposite of what the tutorial says that it does

.
I submitted a ticket , I hope they respond quickly........
Re: Sheep Herder
Posted: Mon May 12, 2014 5:09 pm
by 44www
Good news.
The problem with the script is me

. I was tired and didn't pay good atention to the tutorial and instead of > I placed a <......
Can someone explain this to me:
if the top of button ("sheep"&x) < the top of this card then
set the top of button ("sheep"&x) to the left of this card
end if
if the left of button ("sheep"&x) < the left of this card then
set the left of button ("sheep"&x) to the left of this card
end if
if the right of button ("sheep"&x) > the right of this card then
set the right of button ("sheep"&x) to the right of this card
end if
if the bottom of button ("sheep"&x) > the bottom of this card then
set the bottom of button ("sheep"&x) to the bottom of this card
Why in the blue code they are using < and in the red code they are using >. Does it have something to do with the right and left of the screen?
Thank you in advance.
Re: Sheep Herder
Posted: Mon May 12, 2014 5:41 pm
by sefrojones
This is because the left of the card is 0 and the top is also 0. This means that the top left of your card is the location 0,0
so if you do something like this in the message box:
It will give you a number in a format like this : 0,0,480,800
this is the left,top,right,bottom
Hopefully this helps,
Sefro