Jump to content

Trying to add root attribute to firewood gives 'unable to cast JObject to JArray' error (incorrect path?)


Recommended Posts

Posted (edited)

I'm trying to add an 'transitionablePropsByType' attribute to firewood (similar to what the driedpeat mod does), but because it's in the root of the object, it seems I can't seem to get the path right. '/', and '/-' neither work (but according to the documentation, addMerge shouldn't care?) and they give the error:

"[Error] Exception: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Newtonsoft.Json.Linq.JArray'."

How can I fix this? Also does anyone know what the 'freshHours' attribute does?

 [
    {
        "op": "replace",
        "path": "/combustibleProps/burnTemperature",
        "value": 600,
        "file": "game:itemtypes/resource/firewood.json",
        "side": "Server"
    },
    {
        "op": "addMerge",
        "path": "/",
        "value": {
            "transitionablePropsByType": {
                "*":
                    [{
                        "type": "Cure",
                        "freshHours": { "avg": 0 },
                        "transitionHours": { "avg": 120 },
                        "transitionedStack": { "type": "item", "code": "game:agedfirewood" },
                        "transitionRatio": 1
                    }]
            }
        },
        "file": "game:itemtypes/resource/firewood.json",
        "side": "Server"
    }
 ]
Edited by Stroomschok
  • Stroomschok changed the title to Trying to add root attribute to firewood gives 'unable to cast JObject to JArray' error (incorrect path?)
Posted
30 minutes ago, Stroomschok said:

I'm trying to add an 'transitionablePropsByType' attribute to firewood (similar to what the driedpeat mod does), but because it's in the root of the object, it seems I can't seem to get the path right. '/', and '/-' neither work (but according to the documentation, addMerge shouldn't care?) and they give the error:

"[Error] Exception: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Newtonsoft.Json.Linq.JArray'."

How can I fix this? Also does anyone know what the 'freshHours' attribute does?

The path is incorrect. Your first instinct wasn't too bad, you want to add something at the root after all, but you do that by inserting the key you want to add directly into the path.

"path": "/transitionablePropsByType",

That of course means, that the value has to be adjusted as well, starting it with

"*":

instead. (Don't forget to remove the trailing bracket "}" either.)

"freshHours" is pretty straight-forward. This numbers sets up the time an item has before it spoils.

For firewood "Cure" is the wrong kind of "type", though. If you look at the bowstave, you can see that for wood and such "Dry" is being used. That's also the reason why you probably want to set the number to 0, so that the firewood starts transitioning right away.

  • Thanks 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.