Page MenuHomeFeedback Tracker

EnScript::SetClassVar function doesn't work on array as if it should
Closed, ResolvedPublic

Description

Hello,

EnScript::SetClassVar function should be able to put an element in an array, Or currently, it's not working correctly.

This could be used with the new json api, when you parse array.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce

The class used:

class TestClassArray
{
	autoptr TIntArray m_TestArray = new TIntArray;
}

The code used to see if it's working :

TestClassArray testArray = new TestClassArray;
		
GetGame().GetMission().OnEvent( ChatMessageEventTypeID, new ChatMessageEventParams( CCDirect, "", "testArray.m_TestArray.Count() : " + testArray.m_TestArray.Count(), "" ) );

bool success = EnScript.SetClassVar(testArray, "m_TestArray", 0, 40);
GetGame().GetMission().OnEvent( ChatMessageEventTypeID, new ChatMessageEventParams( CCDirect, "", "success : " + success, "" ) );

bool success2 = EnScript.SetClassVar(testArray, "m_TestArray", 1, 60);
GetGame().GetMission().OnEvent( ChatMessageEventTypeID, new ChatMessageEventParams( CCDirect, "", "success2 : " + success2, "" ) );

GetGame().GetMission().OnEvent( ChatMessageEventTypeID, new ChatMessageEventParams( CCDirect, "", "testArray.m_TestArray.Count() : " + testArray.m_TestArray.Count(), "" ) );

This is actually what is printing, it should print success: true for the two success and have a higher count in the array after that.

Event Timeline

NiiRoZz created this task.Jun 6 2020, 12:19 PM
NiiRoZz edited Steps To Reproduce. (Show Details)
NiiRoZz changed Category from General to Scripting.Jun 6 2020, 12:23 PM
NiiRoZz updated the task description. (Show Details)Jun 8 2020, 10:12 AM
Geez closed this task as Resolved.Jun 8 2020, 10:32 AM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello NiiRoZz.
SetClassVar API for arrays is for static ones, not dynamic
for dynamic arrays, you need to get it using GetClassVar and then use Insert.
Regards,
Geez