MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / SetToken

Method SetToken

Code/CryEngine/CryAction/GameTokens/ScriptBind_GameToken.cpp:45–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43};
44
45int CScriptBind_GameToken::SetToken(IFunctionHandler* pH)
46{
47 SCRIPT_CHECK_PARAMETERS(2);
48 const char* tokenName = 0;
49 if (pH->GetParams(tokenName) == false)
50 {
51 GameWarning("[GameToken.SetToken] Usage: GameToken.SetToken TokenName TokenValue]");
52 return pH->EndFunction();
53 }
54 ScriptAnyValue val;
55 TFlowInputData data;
56
57 if (pH->GetParamAny(2, val) == false)
58 {
59 GameWarning("[GameToken.SetToken(%s)] Usage: GameToken.SetToken TokenName TokenValue]", tokenName);
60 return pH->EndFunction();
61 }
62 switch (val.type)
63 {
64 case ANY_TBOOLEAN:
65 {
66 bool v;
67 val.CopyTo(v);
68 data.Set(v);
69 }
70 break;
71 case ANY_TNUMBER:
72 {
73 float v;
74 val.CopyTo(v);
75 data.Set(v);
76 }
77 break;
78 case ANY_TSTRING:
79 {
80 const char* v;
81 val.CopyTo(v);
82 data.Set(string(v));
83 }
84 break;
85 case ANY_TVECTOR:
86 {
87 Vec3 v;
88 val.CopyTo(v);
89 data.Set(v);
90 }
91 case ANY_TTABLE:
92 {
93 float x, y, z;
94 IScriptTable* pTable = val.table;
95 assert(pTable != 0);
96 if (pTable->GetValue("x", x) && pTable->GetValue("y", y) && pTable->GetValue("z", z))
97 {
98 data.Set(Vec3(x, y, z));
99 }
100 else
101 {
102 GameWarning("[GameToken.SetToken(%s)] Cannot convert parameter type '%s' to Vec3", tokenName, ScriptAnyTypeToString(val.type));

Callers

nothing calls this directly

Calls 12

stringClass · 0.85
GetParamAnyMethod · 0.80
SetOrCreateTokenMethod · 0.80
ScriptAnyTypeToStringFunction · 0.70
GameWarningFunction · 0.50
GetParamsMethod · 0.45
EndFunctionMethod · 0.45
CopyToMethod · 0.45
SetMethod · 0.45
GetValueMethod · 0.45
FindTokenMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected