Untitled
unknown
plain_text
2 years ago
2.1 kB
11
Indexable
// Fonction007 : copie les variables d'un objet à un autre
void CopyVarsFromAtoB(object oA, object oB)
{
// Get the count of local variables on object oA
int nCount = NWNX_Object_GetLocalVariableCount(oA);
int i; // Declare the loop variable outside of the for loop
// Iterate through all local variables
for (i = 0; i < nCount; i++)
{
// Get local variable at index i
struct NWNX_Object_LocalVariable lv = NWNX_Object_GetLocalVariable(oA, i);
// Check the type of the variable and copy it accordingly
switch (lv.type)
{
case NWNX_OBJECT_LOCALVAR_TYPE_INT:
{
int intValue = GetLocalInt(oA, lv.key);
SetLocalInt(oB, lv.key, intValue);
break;
}
case NWNX_OBJECT_LOCALVAR_TYPE_FLOAT:
{
float floatValue = GetLocalFloat(oA, lv.key);
SetLocalFloat(oB, lv.key, floatValue);
break;
}
case NWNX_OBJECT_LOCALVAR_TYPE_STRING:
{
string stringValue = GetLocalString(oA, lv.key);
SetLocalString(oB, lv.key, stringValue);
break;
}
case NWNX_OBJECT_LOCALVAR_TYPE_OBJECT:
{
object objectValue = GetLocalObject(oA, lv.key);
SetLocalObject(oB, lv.key, objectValue);
break;
}
case NWNX_OBJECT_LOCALVAR_TYPE_LOCATION:
{
location locationValue = GetLocalLocation(oA, lv.key);
SetLocalLocation(oB, lv.key, locationValue);
break;
}
case NWNX_OBJECT_LOCALVAR_TYPE_JSON:
{
json jsonValue = GetLocalJson(oA, lv.key);
SetLocalJson(oB, lv.key, jsonValue);
// Implement handling for JSON variables as needed
break;
}
// No default case needed if all types are accounted for
}
}
}Editor is loading...
Leave a Comment