Raoul Simplicio
Raoul Simplicio

Reputation: 1

combine coordinates using lingo

Does anybody here who knows about Lingo Script? I'm actually a newbie on Lingo Script. And my problem is I don't have any idea on how to make an output in combining 3 coordinates. Example output: (x1,y1), (x2,y2), (x3,y3)

Upvotes: -1

Views: 64

Answers (1)

jtnimoy
jtnimoy

Reputation: 46

let's make an output in Lingo.

In a fresh project, I double click frame 1 and the behavior script editor opens up.

Adobe Director Lingo with behavior script on frame 1 in the timeline window

Enter this code:

on exitFrame me
  put [0,1] , [2,3] 
end

The output in the Message window will look like this:

 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]
 -- [0, 1] [2, 3]

So that's how you know the syntax works, and the little XY coordinates are compiling into structures the computer understands.

Now let's try to do some maths on them.

on exitFrame me
  put [5,8] * [2,3] 
  put [5,8] / [2,3] 
  put [5,8] + [2,3] 
  put [5,8] - [2,3] 
  put [5,8] < [2,3] 
end

where the output is:

 -- [10, 24]
 -- [2, 2]
 -- [7, 11]
 -- [3, 5]
 -- 0

Okay, let us try to add a third coordinate, and change the code so it addresses the coordinates as variables.

on exitFrame me
  set a = [5,8]
  set b = [2,3]
  set c = [44, 66]
  put (a * b) + c
end

where the output is [54,90].

Perhaps we want to do something that talks about the components of the coordinates, in this case, X and Y. We do this using the square bracket operator, and in this case, we pass in index, 1 (number in first slot is the X value), or 2 (number in second slot is Y value).

set xAverage = (a[1] + b[1] + c[1]) / 3.0
put xAverage

Upvotes: 0

Related Questions