如果否則If Else | Roblox大典
文章推薦指數: 80 %
记得认识了这个先吧: 运算符号/字句Operator 当该一句子是对的时候才会运作当"如果"不正确时, 就会转入"否则" 一个"如果"不够,就要"否则如果" 假设某人想根据玩家的 ...
Roblox大典
導覽
首頁
討論
所有頁面
社區
互動式地圖
近期網誌
大典版規
熱門頁面
最近更新
活躍條目
HKIslandEast
都巴NR810線
ADLEnviro500MMC
ADLEnviro500
丹尼士三叉戟
新快運49A線
利寶輪Centroliner
最新博客
特色條目
香港Roblox界俗稱列表
玩不同的遊戲應該穿什麼衣服
文章分類
Roblox功能
Roblox香港現實巴士遊戲
Roblox香港虛擬巴士遊戲
SunshineIslands陽光群島
Hanwick恆域
Westdoorcity西門市
DerryDistrict德里鎮
RobloxStudioScripting教學
RobloxScripting比賽/訓練
FANDOM
遊戲
電影
電視
wiki
探索wiki
社群中心
建立wiki
註冊
尚未註冊?
登入
Advertisement
分類:
RobloxStudioScripting教學
臺灣正體
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
如果否則IfElse
檢視原始碼
歷史
討論(0)
觀看 01:36
We'reGettingMutantsintheMCU-TheLoop
您喜歡這個影片嗎?
開啟音效
記得認識了這個先吧:運算符號/字句Operator
目次
1If如果
1.1基本用法
1.2例子
2Else否則
3Elseif否則如果
3.1多餘檢查
4小遊戲
5學習更多
If如果
基本用法
當該一句子是對的時候才會運作
ifconditionthen
--condition正確時執行
end
例子
Code
Output
if2+3==5then
print("2+3=5")
end
2+3=5
if5>2then
print("5>2")
end
5>2
if5<2then
print("5<2")
end
if5==2+3and6>3then
print("5=2+3and6>3")
end
5=2+3and6>3
if5==2+3and6<3then
print("5=2+3and6<3")
end
if5==2+3or6<3then
print("5=2+3or6<3")
end
5=2+3or6<3
|-
|
iftries<=3then
elseiftries>3andtries<=5then
如果真的執行到第3行,第1行的條件肯定為false(如果true的話就不會到第3行)。
所以,tries>3肯定正確(因為tries<=3肯定錯誤),不用再檢查,直接寫成
elseiftries<=5then
再留意第5行。
elseiftries>5then
同樣道理,到了第5行,第1和3行的條件肯定為false,所以tries一定大於5,可以直接寫成
else
更改後
iftries<=3then
print("Verygood")
elseiftries<=5then
print("OK")
else
print("Tryagain")
end
大道理:使用elseif時,上面檢查過的條件肯定為false,可以直接省去。
小遊戲
1.以下script的output是?
locala=false
ifathen
print("Yes")
else
print("No")
end
答案
原因
No
a是False
2.以下script的output是?
locala=5
localb='5'
ifa==bthen
print("Equal")
else
print("NotSame")
end
答案
原因
NotSame
'5'不等於5
3.以下script的output是?
locali=0
localj=2
localk=i
localz=12
if(i==0and(j==7or(k>0or(z%3==0andnot(j+2*12>i)then
print("YES")
else
print("No")
end
答案
原因
No
4.以下script的output是?
locali=0
ifi==0
print("end")
end
答案
原因
ERROR
漏咗then
學習更多
RobloxStudioScripting教學
Roblox更新/教學Facebook
分類:
RobloxStudioScripting教學
除非另有註明,否則社區內容均使用CC-BY-SA授權條款。
Advertisement
FanFeed
1
Westdoorcity西門市
2
DerryDistrict德里鎮
3
Hanwick恆域
MinecraftWiki
淡江人維基網
D4DJ維基
FollowonIG
TikTok
JoinFanLab
延伸文章資訊
- 1程式特攻隊3:如果否則迷宮 - 博客來
書名:程式特攻隊3:如果否則迷宮,原文名稱:SECRET CODERS: SECRETS & SEQUENCES,語言:繁體中文,ISBN:9789864795802,頁數:112,出版社:小天...
- 2使用IF 搭配AND、OR 及NOT 函數
如果A4 (25) 大於0,或B4 (75) 小於50,則傳回TRUE,否則傳回FALSE。 在此案例中,只有第一個條件為TRUE,但因為OR 只需要一個引數為True,所以公式會傳回TRUE ...
- 3Scratch 如果,如果否則
Scratch 如果,如果否則--- 這一堂課我們來說明scratch最基本的判斷積木,如果、如果-否則的運用。 --- ![](https://i.imgur.com/ijSnSOn.
- 4if / else 如果…否則
否則. if/else比基本if指令允許更多的控制分支,允許多個判斷組合在一起。例如,如果輸入 ...
- 5如果否則If Else | Roblox大典
记得认识了这个先吧: 运算符号/字句Operator 当该一句子是对的时候才会运作当"如果"不正确时, 就会转入"否则" 一个"如果"不够,就要"否则如果" 假设某人想根据玩家的 ...