- Unreal Development Kit Game Programming with UnrealScript:Beginner's Guide
- Rachel Cordone
- 181字
- 2021-08-27 11:59:09
Time for action – Using if/else
Let's write some code to see if/else in action for ourselves.
- Take the following code:
var int Int1, Int2; function PostBeginPlay() { if(Int1 > Int2) 'log("Int1 is greater than Int2"); else if(Int1 == Int2) 'log("Int1 is equal to Int2"); else 'log("Int1 is less than Int2"); } defaultproperties { Int1=5 Int2=2 }
- What would we expect the result to be? Let's look at the log for the answer:
[0007.72] ScriptLog: Int1 is greater than Int2
What just happened?
We can see that the if
statement is executed and not the else if
or else
statements. Notice that in this example we didn't use the curly brackets in our statements. If there is only one line after the if, else if, or else statements brackets aren't necessary. However, if there are two or more lines, we would need to use brackets.
推薦閱讀
- Istio入門與實戰
- 圖解西門子S7-200系列PLC入門
- 龍芯應用開發標準教程
- FPGA從入門到精通(實戰篇)
- Learning Stencyl 3.x Game Development Beginner's Guide
- Hands-On Motion Graphics with Adobe After Effects CC
- Spring Cloud實戰
- 觸摸屏應用技術從入門到精通
- 計算機電路基礎(第2版)
- 嵌入式系統原理及應用:基于ARM Cortex-M4體系結構
- Arduino項目案例:游戲開發
- The Applied Artificial Intelligence Workshop
- The Machine Learning Workshop
- Nagios系統監控實踐(原書第2版)
- Hands-On Markov Models with Python