KO API UO GetGlobal - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
UO.GetGlobal
C# ์๊ทธ๋์ฒ
string UO.GetGlobal(object? name);
dynamic UO.GetGlobal(object? globalRegion, object? varName);
๋์ ๋ฐ ๋ฐํ๊ฐ
SetGlobal๊ณผ GetGlobal์ ๋ชจ๋ ์คํฌ๋ฆฝํธ, ํ๋กํ๊ณผ Full Client/Client ํ๋ก์ธ์ค์์ ๊ณต์ ํฉ๋๋ค. ๊ฐ์ ๋ฌธ์์ด์ด๊ณ ์๋ ํค๋ "N/A"์ ๋๋ค. ํค๋ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ฉฐ region ํ์์ region/name ์์ ๋๋ค. Manager/Game Manager/CSharp/globals.json์ ํ๋ก์ธ์ค ๊ฐ ์ ๊ธ์ผ๋ก ์๋ก ์ฝ๊ณ ์ฌ์์ ํ์๋ ๋ณด์กดํฉ๋๋ค. Shared ํ์๋ ๊ฐ์ ์ ์ฅ์์ ๋๋ค.
๋งค๊ฐ๋ณ์
globalRegionโ ํค ์ด๋ฆ๊ณผ ๊ฒฐํฉํ๋ ๋ค์์คํ์ด์ค.nameโ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ ๊ณต์ ํค ์ด๋ฆ.varNameโ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ ๊ณต์ ํค ์ด๋ฆ.
๊ฐ ์ฝ๋ ๋ธ๋ก์ ์์ ํ ๋ ๋ฆฝ .csx์ ๋๋ค. ์์ serial, type๊ณผ ์ขํ๋ฅผ ๋ฐ๊พธ์ธ์. ์ธ์ ์์์ C# ๋ช ๋ช ๋ ์ธ์๋ ์๊ทธ๋์ฒ๋ฅผ ๋ฐ๋ฆ ๋๋ค.
์ฑํ ๋ช ๋ น
#getglobal team.target
#get global team.message
์์ ํ C# ์์
๊ฐ ์ฝ๋ ๋ธ๋ก์ ์์ ํ ๋ ๋ฆฝ .csx์ ๋๋ค. ์์ serial, type๊ณผ ์ขํ๋ฅผ ๋ฐ๊พธ์ธ์. ์ธ์ ์์์ C# ๋ช ๋ช ๋ ์ธ์๋ ์๊ทธ๋์ฒ๋ฅผ ๋ฐ๋ฆ ๋๋ค.
1
string value = UO.GetGlobal("team.target");
UO.Print(value);
2
string value = UO.GetGlobal("team.delay");
if (int.TryParse(value, out int milliseconds))
UO.Print(milliseconds.ToString());
3
UO.Print(Convert.ToString(UO.GetGlobal("team", "delay")));
4
new CommandSample().Execute(UO);
sealed class CommandSample
{
public void Execute(global::ClassicUO.CSharp.CSharpGameApi api)
{
string value = api.GetGlobal("team.target");
api.Print(value);
}
}
๋ด๋ถ ํธ์ถ
CSharpGameApi.GetGlobal
-> CSharpScriptGlobals
-> InjectionScript.Runtime.InjectionApiUO.RegisterClientApiCompatibility
-> InjectionScript.Runtime.State.Globals.GetGlobal
Globals -> SharedGlobalStore -> named mutex -> atomic JSON replacement