Sign In Register

How can we help you today?

Start a new topic

Cloud Script: adding field to object causes error

Hello.

I have the problem with CloudScript. The following code is not working:
    var realFootballerStatesData = challenge.getScriptData("RealFootballerStates");

    realFootballerStatesData.forEach(function(realFootballerStateData, index, array) {

        var footballerPosition = FindItem(footballerPositions, function(fp) { return fp.Id === realFootballerStateData.FootballerPositionId; });

        var footballerState = FindItem(footballerStates, function(fs) { return fs.Id === realFootballerStateData.FootballerStateId; });

        footballerPosition.RealFootballerState = footballerState;

    });


Both footballerPosition and footballerState are valid objects. However the last line:
footballerPosition.RealFootballerState = footballerState  - causes "An unexpected error has occurred" error.

I also tried footballerPosition["RealFootballerState"] = footballerState. It causes same error.
Also tried to add the appropriate field to footballerPosition object while initializing it:
        var footballerPosition = {

            "Id": footballerPositionData.Id,

            "Footballer": FindItem(footballers, function(f) { return f.Id === footballerPositionData.FootballerId; }),

            "Type": footballerPositionData.Type,

            "AttackGridCellIndex": new Vector2(footballerPositionData.AttackGridCellIndex),

            "DefenseGridCellIndex": new Vector2(footballerPositionData.DefenseGridCellIndex),

            "RealFootballerState": null,

            "PlannedFootballerState": null

        };


What can be the reason of the problem? Is it a bug in GameSparks or do I do something wrong?

Thanks.


Hey Anatolii,


It sounds like var footballerState just isnt initialized by the time you try to add it to your form. When you run this in the test harness, does it say what the value of footballerState is?

If you dont mind, could you let me know the event and module you are using here so i can check it out in your portal?


Thanks,
Sean

Hey Anatolii,

Have you managed to fix this?
Please let us know if you need any help.

Thanks,
Sean

 

Login to post a comment