-
Notifications
You must be signed in to change notification settings - Fork 0
API StrComp zh tw
Codex edited this page Oct 3, 2026
·
1 revision
Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
ClassicUO • Runtime API
比較名稱或命令的精確相等性與順序。
StrComp(left:String, right:String) -> Integer
-
left— 左側 String。 -
right— 右側 String;兩者必填,沒有第三個比較模式引數。
Integer -1/0/1 表示在前/相等/在後,以區分大小寫的 UTF-16 序數順序比較。不是 Boolean:相等需 result = 0;If StrComp(...) 在兩字串不同時為真。
- 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
- 與介面語言無關,不做語言排序;要忽略大小寫請明確使用 LCase/UCase。輸入不變。
String.Compare 使用 Ordinal,再用 Math.Sign 化為 -1、0 或 1。
String.Compare 使用 Ordinal,再用 Math.Sign 化為 -1、0 或 1。
Integer -1/0/1 表示在前/相等/在後,以區分大小寫的 UTF-16 序數順序比較。不是 Boolean:相等需 result = 0;If StrComp(...) 在兩字串不同時為真。
專案原始碼: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; 函式 BasicStrComp / String.Compare / Math.Sign.
與介面語言無關,不做語言排序;要忽略大小寫請明確使用 LCase/UCase。輸入不變。
# 辨識命令
#
# 比較名稱或命令的精確相等性與順序。
#
# Integer -1/0/1 表示在前/相等/在後,以區分大小寫的 UTF-16 序數順序比較。不是 Boolean:相等需 result = 0;If StrComp(...)
# 在兩字串不同時為真。
SUB Main()
# Trim/LCase 將 " STOP " 化為 stop;與 0 比較得到 True (1),不會停止腳本。
# 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
Dim action = LCase(Trim(" STOP "))
If StrComp(action, "stop") = 0 Then
Return True
End If
Return False
END SUB參數與執行說明:
- Trim/LCase 將 " STOP " 化為 stop;與 0 比較得到 True (1),不會停止腳本。
- 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
# 排列兩個名稱
#
# 比較名稱或命令的精確相等性與順序。
#
# Integer -1/0/1 表示在前/相等/在後,以區分大小寫的 UTF-16 序數順序比較。不是 Boolean:相等需 result = 0;If StrComp(...)
# 在兩字串不同時為真。
SUB Main()
# zinc 排在 iron 後,交換變數得到 iron|zinc。
# 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
Dim first = "zinc"
Dim second = "iron"
If StrComp(first, second) > 0 Then
Dim saved = first
first = second
second = saved
End If
Return first & "|" & second
END SUB參數與執行說明:
- zinc 排在 iron 後,交換變數得到 iron|zinc。
- 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
# 查找精確名稱
#
# 比較名稱或命令的精確相等性與順序。
#
# Integer -1/0/1 表示在前/相等/在後,以區分大小寫的 UTF-16 序數順序比較。不是 Boolean:相等需 result = 0;If StrComp(...)
# 在兩字串不同時為真。
SUB Main()
# ContainsExact 以 | 分割清單,精確找到 Ore,傳回 True (1);ore 不等於 Ore。
# 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
Return ContainsExact("ore|Ore|wood", "Ore")
END SUB
Function ContainsExact(names, wanted)
For index = 0 To GetWordCount(names, "|") - 1
If StrComp(GetWord(names, index, "|"), wanted) = 0 Then
Return True
End If
Next
Return False
End Function參數與執行說明:
- ContainsExact 以 | 分割清單,精確找到 Ore,傳回 True (1);ore 不等於 Ore。
- 僅在本機處理範例資料並傳回值;不傳送聊天、不停止腳本、不移動物品,也不連線至伺服器。
ClassicUO
Bad Newbie & Basic IDE
Найти в справочнике
Клиент и скрипты
Каталоги значений
Разработка и помощь