其他 2007-01-08 ChenReal 463

[3D]Lingo字典zz


Lingo 的运算符

运算符是Lingo语言中最基本的要素,可实现变量值的运算、比较、分配等功能,核心运算符及功能如下表所示:

符号功能
#定义符号
-负号
--说明符号(注释)
&连接两字符串
&&连接两字符串,且中间加一个空格键
*乘号
+加号
/除号
-减号
<小于
<=小于等于
<>不等于
=等于
>大于
>=大于等于
[ ]阵列符号
\连接两行指令为同一表达式
( )括弧(指定执行优先级)

各运算符详细说明

# 符号

语法:#symbol Name 定义符号(Director中的一种对象类型),处理速度比字符串快,可替代字符串使用。

  • 基础使用:#newType 表示符号newType,可赋值给变量:put #newType into newType;
  • 阵列结合使用:[#a:1, #b:2, #c:3] 表示含内容的property list阵列,符号作为数值的描述文字。

- 符号

语法:-expression 算术负号,将数值转为负数,具备算术减号性质。

-- 符号

语法:--[comment] 注释符号,用于为程序添加说明文字,-- 后的内容不会被执行,便于程序维护。

& 符号

语法:expression1 & expression2 字符串连接符,将两个字符串拼接为一个新字符串。 示例:put "This is" & "a book." into Thisbook,结果为This is a book。

&& 符号

语法:expression1 && expression2 带空格的字符串连接符,拼接两个字符串时,中间自动添加一个空格。 示例:put "This is" && "a book." into Thisbook,结果为"This is a book."。

* 符号

语法:expression1 * expression2 算术乘号,执行乘法运算。

+ 符号

语法:expression1 + expression2 算术加号,执行加法运算。

/ 符号

语法:expression1 / expression2 算术除号,执行除法运算。

< 符号

语法:expression1 < expression2 算术小于号,用于数值比较。

<= 符号

语法:expression1 <= expression2 算术小于等于号,用于数值比较。

<> 符号

语法:expression1 <> expression2 算术不等于号,用于数值比较。

= 符号

语法:expression1 = expression2 算术等于号,用于数值比较。

> 符号

语法:expression1 > expression2 算术大于号,用于数值比较。

>= 符号

语法:expression1 >= expression2 算术大于等于号,用于数值比较。

[ ] 符号

语法:[entry1, entry2, entry3, ...] 阵列(List)定义符号,支持两种阵列类型:

  • 线性阵列:[1, 3, 5],每个项目为单纯数值;
  • 含内容的阵列:[#one:1, #three:3, #five:5],每个项目包含符号(描述)和对应数值。

\ 符号

用于Script视窗中,将两行指令连接为同一个表达式(解决单行指令过长问题)。

( ) 符号

语法:(expression) 括号,指定指令执行优先级,括号内的指令优先执行。

Lingo的指令(A~C)

abort

语法:abort 中断Handler中剩余指令的执行,触发后直接退出当前Handler。 示例:

on flyUp
  [statements]
  if stopFly = TRUE then
    abort
  end if
  go to the frame
end

abs

语法:abs (numericExpression) 获取数值的绝对值。

actorList

语法:the actorList 存储可执行perFrameHook指令的对象,播放头移到新镜头时,自动执行阵列中所有对象的指令。

  • 添加对象:add the actorList, birth (script"MovingBall", 1, 200, 200);
  • 清空对象:set the actorList = [ ]。

add

语法:add linearList, value 向线性阵列(Linear List)末尾添加一个数值。 示例:

set newList = [4, 3, 2]
add newList, 1
-- 结果:[4, 3, 2, 1]

addAt

语法:addAt list, position, value 向线性阵列指定位置添加数值。 示例:

set newList = [4, 3, 2]
addAt newList, 2, 1
-- 结果:[4, 1, 3, 2]

addProp

语法:addProp list, property, value 向含内容的阵列(property list)添加项目(符号+数值)。 示例:

set newList = [#four:4, #three:3, #two:2]
addProp newList, #one, 1
-- 结果:[#four:4, #three:3, #two:2, #one:1]

ancestor

语法:property ancestor 子对象引用父程序之外Handler的属性,可将部分handlers放在其他script中,供子对象调用。 示例(父程序Animal):

property legCount
on birth me
  return me
end birth
on eat me, what
  put"Eating" & what
end

子对象脚本(man):

property race, ancestor
on birth me
  set race to "African"
  set ancestor to birth (script"Animal")
  set the legCount of me to 2
  return me
end birth

调用示例:

set manChild to birth (script"man")
put the legCount of manChild -- 结果:2
put the race of manChild -- 结果:"African"
eat manChild,"apple" -- 结果:"Eating apple"

and

语法:logicalExpression1 and logicalExpression2 逻辑“与”运算,判断前后两个逻辑值的与结果。

append

语法:append list, value 将数值添加到线性阵列最后位置(无论阵列是否排序)。 示例:

set newList = [4, 3, 2]
append newList, 1
-- 结果:[4, 3, 2, 1]

atan

语法:atan(number) 获取数值弧度的角度值(范围:-π/2 ~ π/2)。

backColor of cast

语法:set the backColor of cast castName to colorNumber 设定文本对象的背景颜色。

backColor of sprite

语法:the backColor of sprite whichSprite 设定分镜(sprite)的背景颜色(需先将分镜设为Puppet),适用于向量图形等,设定后需用updateStage更新舞台。

BACKSPACE

语法:BACKSPACE 代表键盘上的退格键。

beep

语法:beep[numberOfTimes] 控制电脑内置喇叭发声,参数为发声次数。

beepOn

语法:the beepOn 设定为真时,若操作未启动的分镜图形,喇叭会发出提示音。

put...before

语法:put expression before chunkExpression 将指定值插入到目标位置前(支持字符串、文本卡司成员等)。 示例:

put "This is book." into thisBook
put "a" before word 3 of thisBook
-- 结果:"This is a book."

birth

语法:birth (script parentScriptName, value1, value2, ...) 产生子对象,子对象可调用父程序的handler。 示例(父程序Bird):

on birth me
  return me
end
on fly me
  put "I am flying"
end

子对象调用:

set myBird to birth (script "Bird")
fly myBird -- 结果:"I am flying"

blend of sprite

语法:the blend of sprite 设定分镜融合程度(数值范围:0~100)。

bottom of sprite

语法:the bottom of sprite whichSprite 查询分镜图形最低点到视窗上方边界的距离(仅查询,不可设定)。

buttonStyle

语法:the buttonStyle 设定按钮交互样式:

  • 0:按住鼠标拖动经过其他按钮时,其他按钮显示被按下,放开时触发对应按钮指令;
  • 1:按住鼠标拖动经过其他按钮时,其他按钮无反应。

cast

语法:the property of cast whichCastmember 操作卡司成员属性,whichCastmember可为名称/数字,property为背景色、前景色、大小等属性。

cast backColor

语法:set the backColor of cast castName to colorNumber 设定文本卡司成员的背景颜色。 示例:set the backColor of cast 1 to 10(设定第一个卡司成员背景色为调色板第10色)。

cast castType

语法:the castType of cast cast member 查询卡司成员类型(返回符号),类型对应如下:

符号说明符号说明
#bimap点矩阵图形#palette调色板
#button按钮#picture图片
#digitalVideo数字影片#scriptLingo程序
#empty空的卡司成员#shape向量图形
#filmLoop循环影片#sound声音
#movie电影#soundLevel properties声音的大小

示例:put the castType of cast 1 into TypeSymbol。

cast depth

语法:the depth of cast cast member 查询卡司成员的颜色深度(1-bit=黑白、2-bit=4色、4-bit=16色、8-bit=256色)。

cast fileName

语法:the fileName of cast cast member 查询链接卡司成员对应的文件名称(含路径)。

cast forecolor

语法:set the foreColor of cast castName to colorNumber 设定文本卡司成员的前景颜色。

cast height

语法:the height of cast whichCastmember 查询卡司成员的高度(仅查询,不可设定)。

cast hilite

语法:hilite chunkExpression 将卡司成员或其部分内容反白。 示例:hilite word 1 of field 1(反白第一个文本卡司成员的第一个字)。

cast loaded

语法:the loaded of cast whichCastMember 测试卡司成员是否已载入内存(返回布尔值,仅查询)。

cast name

语法:the name of cast WhichCastmember 设定/查询卡司成员的名称。

cast number

语法:the number of cast whichCastmember 设定/查询卡司成员的编号。

cast palette

语法:the palette of cast whichCastMember 查询卡司成员使用的调色板(正数=自定调色板,负数=系统内定调色板)。

cast picture

语法:the picture of cast whichCastmember 设定点矩阵图形/PICT图形的内容。

cast purgePriority of cast

语法:the purgePriority of cast whichCastMember 设定卡司成员从内存移出的优先级:

号码功能说明
0Never purge不移出内存
1Purge last最后一个移出内存
2Purge next下一个移出内存
3Purge normal依正常方式移出内存

cast rect

语法:

  • rect (left, top, right, bottom )
  • rect (point1, point2) 定义卡司成员的位置。 示例1:put the rect of cast 2 into newRec(获取第二个卡司成员位置); 示例2:put rect (firstPoint, secondPoint)(通过两个点定义矩形区域)。

cast regPoint

语法:the regPoint of cast whichCastMember 查询/设定卡司成员的对齐点位置。 示例:set the regPoint of cast 2 = point(300, 400)。

cast scriptText

语法:the scriptText of cast whichCastMember 指定卡司成员的Script,可复用其他成员的脚本。 示例:set the scriptText of cast2 = the scriptText of cast 1。

cast text

语法:the text of cast whichCastMember 查询/设定文本卡司成员的文字内容。

cast width

语法:the width of cast whichCastMember 查询卡司成员的宽度。

castNum of sprite

语法:the castNum of sprite whichSprite 查询分镜使用的卡司成员编号。

castType of cast

语法:the castType of cast cast member 查询卡司成员类型(返回符号,同cast castType)。

center of cast

语法:the center of cast castName 配合the crop of cast使用:当the crop of cast为真时,设定为真可截掉影片超出分镜矩形的部分。

centerStage

语法:the centerStage 查询/设定舞台位置:真=舞台居中,假=舞台不居中。

char...of

语法:

  • char whichCharacter of chunkExpression
  • char firstCharacter to lastCharacter of chunkExpression 提取字符串中的单个字符或指定范围字符。 示例:put char 3 of "This is a book." into newChar。

chars

语法:chars (stringExpression, firstCharacter, lastCharacter) 提取字符串中指定范围的子串。 示例:put chars ("This is a book.", 6, 7) into newChar(结果:"is")。

charToNum

语法:charToNum (stringExpression) 将字符转换为对应的ASCII码值。

checkBoxAccess

语法:the checkBoxAccess 设定复选框/单选按钮的操作权限:

数值说明
0可开关按钮
1仅可开,不可关
2不可开关

checkBoxType

语法:the checkBoxType 设定复选框/单选按钮的选中样式:

数值说明
0加X符号
1加黑色边方块
2加填满黑色的方块

checkMark of menuItem

语法:the checkMark of menuItem whichItem of menu whichMenu 设定自定义菜单子项是否显示勾选标记(真=显示,假=不显示)。

clearGlobals

语法:clearGlobals 将所有全局变量重置为初始值(0)。

clickLoc

语法:the clickLoc 返回上一次鼠标点击的屏幕位置(格式:Point(x, y))。

clickOn

语法:the clickOn 返回用户点击的Sprite编号(仅当Sprite设定为真时有效)。

close window

语法:close window windowIdentifier 关闭指定视窗。

closeXlib

语法:closeXlib [whichFile] 关闭Xlibrary(Windows下为.dll文件)。

  • 关闭所有:closeXlib;
  • 关闭指定:closeXlib"Sample"(关闭sample.dll)。

colorDepth

语法:the colorDepth 查询当前计算机的颜色深度:

数值说明数值说明
1黑白8256色
24种颜色1632768色
416色3216777216色

constrainH

语法:constrainH(whichSprite, integerExpression) 判断数值是否在分镜图形左右边界内:

  • 在内:返回原数值;
  • 小于左边界:返回左边界值;
  • 大于右边界:返回右边界值。 示例:分镜1左右边界为100/200,put constrainH (1, 90) into newPosition(结果:100)。

constraint of sprite

语法:the constraint of sprite whichSprite 设定分镜可移动范围(设为0取消限制)。

constrainV

语法:constrainV(whichSprite, integerExpression) 与constrainH类似,判断数值是否在分镜图形上下边界内。

contains

语法:stringExpression1 contains stringExpression2 判断字符串1是否包含字符串2(真=包含,假=不包含)。

continue

语法:continue 结束pause暂停,继续播放影片。

controlDown

语法:the controlDown 判断Ctrl键是否被按下(真=按下,假=未按下)。

controller of cast

语法:the controller of cast castName 设定QuickTime影片的控制按钮显示状态(0=隐藏,1=显示)。

copyToClipBoard

语法:copyToClipBoard cast castMember 将卡司成员内容复制到剪贴板。

cos

语法:cos (angle) 计算角度的余弦值。

count

语法:count (list) 计算阵列中的项目数量。

crop of cast

语法:the crop of cast 设定数字影片在分镜矩形中的显示方式:

  • 假:挤压/放大影片适配矩形;
  • 真:截掉影片超出矩形的部分。

cursor

语法:

  • cursor [castNumber]
  • cursor [castNumber, maskCastNumber]
  • cursor whichCursor 设定光标形状,预设数值对应样式:
数值意义数值意义
0不设定光标3十字条状光标
-1箭头光标4漏斗形光标
1I字光标200光标消失
2十字形光标--

自定义光标(Windows):需制作16*16、1bit的卡司成员,示例:

  • 透明光标:cursor [1];
  • 不透明光标:cursor [1, 2]。

cursor of sprite

语法:

  • the cursor of sprite whichSprite to [castNumber]
  • the cursor of sprite whichSprite to [castNumber, maskCastNumber]
  • the cursor of sprite whichSprite to whichCursor 仅当光标悬停在指定Sprite上时,显示自定义光标(用法同cursor)。

评论 (0)

发表评论

验证码
返回