找回密码
 点一下
查看: 1330|回复: 12

boolean怎么写?

[复制链接]
发表于 2009-2-18 17:48:16 | 显示全部楼层 |阅读模式
http://www.islga.org/bbs/read.php?tid=23522

多个判断怎么写喔?我做的时候都放在函数里面的.不写在函数里怎么写呢?
发表于 2009-2-18 17:52:18 | 显示全部楼层
and 且
or 或
回复

使用道具 举报

 楼主| 发表于 2009-2-18 17:55:14 | 显示全部楼层
引此为何处于2009-01-14 09:34发表的  :
lz的意思应该是这样,XXX and XXX 如果前面的是false 后面的无论是什么都为false 其他语言在这种情况下后面的代码就不会执行 他问jass是否也这样。比如 i=-1,  ( i > 0 ) and ( a[ i ] >0 )
回复

使用道具 举报

发表于 2009-2-18 17:59:49 | 显示全部楼层
恩 and 全部成立 才成立 如果有false 就不会继续判断了
or 一个成立 就成立 如果有true 也不会继续判断了
另外 格式是
if (表达式A and 表达式B) then
endif
回复

使用道具 举报

 楼主| 发表于 2009-2-18 18:11:38 | 显示全部楼层
意思是啥?即是(*)and(*)and(*)……用and的必须要返回true吗?用or的则相反?

我该怎么写啊.
回复

使用道具 举报

发表于 2009-2-18 18:23:11 | 显示全部楼层
..意思是 如果全用 and 连接(所有表达式均为true 才会返回true)
那么 所有表达式里 一旦出现 false 那么 就不会继续判断直接返回 false
如果全用or连接(任意一个表达式会true 即返回true)
那么 所有表达式里 一旦出现 true 那么 也不会继续判断直接返回 true

例子
true and false 那么 就是 false
true or false 那么 就是true

例子2
if (10>5 and 1<0) then
代码1
else
代码2
endif
那么执行 代码2

if (10>5 or 1<0) then
代码1
else
代码2
endif
那么执行 代码1
回复

使用道具 举报

 楼主| 发表于 2009-2-18 18:26:01 | 显示全部楼层
那么,写判断时一定要1行写1条咯?
回复

使用道具 举报

发表于 2009-2-18 18:28:06 | 显示全部楼层
不需要啊...
用and 和 or 连接表达式就可以了
回复

使用道具 举报

 楼主| 发表于 2009-2-18 18:34:35 | 显示全部楼层
[jass]不懂.
function Arsw_E takes nothing returns boolean
    local unit u = GetFilterUnit()
    if (not(IsUnitType(u,UNIT_TYPE_STRUCTURE) == false)) then
        return false
    endif
    if (not(IsUnitType(u,UNIT_TYPE_GIANT) == false)) then
        return false
    endif
    if GetUnitAbilityLevel(u,'BOvd') > 0 then
        return false
    endif
    if GetUnitAbilityLevel(u,'Bcyc') > 0 then
        return false
    endif
    if GetUnitAbilityLevel(u,'B00C') < 0 then
        return false
    endif
    if GetUnitState(u,UNIT_STATE_LIFE) == 0 then
        return false
    endif
    if (not(IsUnitAlly(u,GetOwningPlayer(I2U(GetStoredInteger(udg_GC,I2S(H2I(GetExpiredTimer())),"TriggerUnit")))) == false)) then
        return false
    endif
    set u = null
    return true
endfunction[/jass]
回复

使用道具 举报

发表于 2009-2-18 18:39:54 | 显示全部楼层
你全部用and连接就可以了啊
比如
[jass]if (IsUnitType(u,UNIT_TYPE_STRUCTURE) == false and IsUnitType(u,UNIT_TYPE_GIANT) == false and GetUnitAbilityLevel(u,'BOvd') > 0 and GetUnitAbilityLevel(u,'Bcyc') > 0 and GetUnitAbilityLevel(u,'B00C') < 0 and GetUnitState(u,UNIT_STATE_LIFE) == 0 and IsUnitAlly(u,GetOwningPlayer(I2U(GetStoredInteger(udg_GC,I2S(H2I(GetExpiredTimer())),"TriggerUnit")))) == false) then
代码1
else
代码2
endif[/jass]
回复

使用道具 举报

 楼主| 发表于 2009-2-18 18:42:12 | 显示全部楼层
我去试下先,不过现在不试了,今晚先,我记得我试过写在一起的,但是没成功.所以才上来问的.
回复

使用道具 举报

发表于 2009-2-18 22:43:11 | 显示全部楼层
其实,如果需要判断的东西比较多,我还是觉得分开判断,有false就返回false比较好
如果要判断的少就直接用and连

另外可以用多个变量,把每个分判断用一个变量取值,然后再串起来

最后,明显感觉lz的逻辑一塌糊涂,4楼这种莫名其妙的问题都有………………
回复

使用道具 举报

 楼主| 发表于 2009-2-23 17:46:04 | 显示全部楼层
我还是不知道该怎么写.我能不能求下演示啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-21 16:29 , Processed in 0.030506 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表