Sheep Herder

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

44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Sheep Herder

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sheep Herder

Post by Klaus »

Hi 44www,

1. welcome to the forum! :D

2. Could you please post the relevant part(s) of the script that causes errors?
Not everyone has the Sheepherder stack at hand 8)


Best

Klaus
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post 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.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sheep Herder

Post by Klaus »

Hi 44www,

hmm, syntax looks correct!?
Sorry, no idea without looking at the rest of the stack/scripts.


Best

Klaus
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sheep Herder

Post 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! 8)


Best

Klaus
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post 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....
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sheep Herder

Post by Klaus »

So it works now?
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post by 44www »

No the problem is still there
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post by 44www »

The strange part is that I olso received a video tutorial. And in the video tutorial he doesn't get this error......
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sheep Herder

Post by Klaus »

44www wrote:No the problem is still there
Hm, OK, then it was not this...
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post 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)
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post 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........
44www
Posts: 11
Joined: Sun May 11, 2014 11:39 am

Re: Sheep Herder

Post by 44www »

Good news.

The problem with the script is me :D . I was tired and didn't pay good atention to the tutorial and instead of > I placed a <...... :oops:

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.
sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Sheep Herder

Post 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:

Code: Select all

put the rect of this card
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
Post Reply