Modding Help Making an alternate difficulty mod!

Discussion in 'Starbound Modding' started by ToddAndChips, Apr 12, 2018.

  1. ToddAndChips

    ToddAndChips Tentacle Wrangler

    Hi all,

    I posted on here a while back and got some really useful help and tips for my first ever Starbound mod (an extraction station that allows you to retrieve some ore from bars) which is now functioning smoothly! Thanks to DrPvtSkittles and projectmayhem for their help :)

    That mod was built based off the Concoction Station mod I found on steam (as I had no idea what I was doing with coding at the time), however the one I'm working on now I've been writing from scratch, after a lot of research and learning how to write .patch files.

    I've been successful in learning and creating .patch files so far, and I've tested them using Kawa's Starbound JSON Lab (http://helmet.kafuka.org/sbmods/json/patch.html), and patches are coming through successful on there. However, launching the game causes a crash, and some entries in the log file I don't understand. The error is this:

    [05:46:08.571] [Error] Application: exception thrown, shutting down: (JsonException) Improper conversion to double from array

    I can't seem to find online exactly what this refers to (or I'm finding it and not quite understanding it). Am I right in thinking the "Improper conversion to double from array" is something to do with a formatting issue in one of my patches?

    Here are my .patch files, in case any of you talented code wizards are able to quickly spot something I'm missing!


    [
    {
    "op": "add",
    "path": "/paneLayout/labelForgivingMode",
    "value": { }
    },
    {
    "op": "add",
    "path": "/paneLayout/labelForgivingMode/type",
    "value": "label"
    },
    {
    "op": "add",
    "path": "/paneLayout/labelForgivingMode/position",
    "value": [77, 85]
    },
    {
    "op": "add",
    "path": "/paneLayout/labelForgivingMode/zlevel",
    "value": [1]
    },
    {
    "op": "add",
    "path": "/paneLayout/labelForgivingMode/value",
    "value": "FORGIVING"
    },
    {
    "op": "replace",
    "path": "/paneLayout/labelCasualMode/position",
    "value": [20, 85]
    },
    {
    "op": "replace",
    "path": "/paneLayout/labelSurvivalMode/position",
    "value": [133, 85]
    },
    {
    "op": "replace",
    "path": "/paneLayout/labelHardcoreMode/position",
    "value": [190, 85]
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1",
    "value" : { }
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/id",
    "value": 1
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/image",
    "value": ""
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/text",
    "value": ""
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/position",
    "value": [19, 0]
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/data",
    "value": { }
    },
    {
    "op": "add",
    "path": "/paneLayout/mode/buttons/1/data/description",
    "value": "Eat to survive, but keep items on death."
    },
    {
    "op": "replace",
    "path": "/paneLayout/mode/buttons/0/position",
    "value": [-38, 0]
    },
    {
    "op": "replace",
    "path": "/paneLayout/mode/buttons/2/id",
    "value": 2
    },
    {
    "op": "replace",
    "path": "/paneLayout/mode/buttons/2/position",
    "value": [75, 0]
    },
    {
    "op": "replace",
    "path": "/paneLayout/mode/buttons/3/id",
    "value": 3
    },
    {
    "op": "replace",
    "path": "/paneLayout/mode/buttons/3/position",
    "value": [132, 0]
    }
    ]



    [
    {
    "op": "add",
    "path": "/modeTypeTextAndColor/2",
    "value": [ "Forgiving", [75, 206, 58] ]

    }
    ]



    [
    {
    "op": "add",
    "path": "/forgiving",
    "value": { }
    },
    {
    "op": "add",
    "path": "/forgiving/hunger",
    "value": true
    },
    {
    "op": "add",
    "path": "/forgiving/allowBeamUpUnderground",
    "value": false
    },
    {
    "op": "add",
    "path": "/forgiving/deathDropItemTypes",
    "value": "none"
    },
    {
    "op": "add",
    "path": "/forgiving/reviveCostPercentile",
    "value": 0.3
    },
    {
    "op": "add",
    "path": "/forgiving/permadeath",
    "value": false
    }
    ]


    Side note: I've removed all other mods that I'm aware of, including my own first mod, so I don't think a clash is causing an issue as far as I can tell.

    Many thanks in advance to anyone that's able to nudge me in the right direction! :)

    Todd


    UPDATE: I found the sneaky little devil! I had [1] as a value for a single number entry, but the square brackets seem to only be required for number entries with two or more values. So I assume the error, when translates into less coding-y English, basically says "you put a double where a single should be".
     
    Last edited: Apr 12, 2018
  2. projectmayhem

    projectmayhem Spaceman Spiff

    This website rocks for creating patches, instead of testing them
    https://chbrown.github.io/rfc6902/
    Put the files original code on the left, then put what you 'want' the file to look like on the right, click the button and BAM! Patch created.
     
    DrPvtSkittles likes this.
  3. ToddAndChips

    ToddAndChips Tentacle Wrangler

    Oh damn, had no idea that existed! Although to be honest with you, I really enjoyed the learning process and there was something satisfying about typing it all out from nothing, so I might keep at it for now and just use that as a sort of testing and comparing tool. Thanks for the link though, that's going straight in my bookmarks!

    By the way, I managed to get the mod mostly working - just playing with different orders on the character creation menu and working out a few errors and crashes, and hopefully I'll have my second mod up and running :)
     
    projectmayhem likes this.
  4. bk3k

    bk3k Oxygen Tank

    I see you found your problem. For future reference, "double" is a C++ data type (the Starbound engine is written in C++). A decimal number (also referred to as a float number) such as 3.14 or 0.03 as opposed to integers like 3, 5392, etc. It found those numbers where it expected an array (which often itself will contain double values), and a double can't be automatically converted to an array. So that's what the error was telling you.
     
    DrPvtSkittles likes this.
  5. ToddAndChips

    ToddAndChips Tentacle Wrangler

    Ahh I think I'm with you! Thanks for the explanation bk3k :)

    Whilst I'm here, I've hit an error that I'm a little stuck on. I've got through that last few errors while rewriting bits of code, but this one has me stumped so far. It only happens when I try to select my custom difficulty in the character creation menu - as soon as I click on the checkbox, there's a very brief freeze and a crash. I'm wondering if anyone can help me learn what the error is trying to point me at?

    Here's the log from the error downwards:


    [11:37:21.837] [Error] Application: exception thrown, shutting down: (MapException) Key '<type enum Star::playerMode at address: 00000013182FE0F8>' not found in Map::get()
    [0] 7ff7a2517153 Star::captureStack
    [1] 7ff7a2515ede Star::StarException::StarException
    [2] 7ff7a2815e30 Star::MapMixin<std::map<enum Star::playerMode,Star::String const * __ptr64,std::less<enum Star::playerMode>,std::allocator<std::pair<enum Star::playerMode const ,Star::String const * __ptr64> > > >::get
    [3] 7ff7a281f58c Star::player::setModeType
    [4] 7ff7a2cfaf2b Star::CharCreationPane::changed
    [5] 7ff7a2ca2114 Star::ButtonGroup::wasChecked
    [6] 7ff7a2ca3ab4 Star::ButtonWidget::setPressed
    [7] 7ff7a2ca33fe Star::ButtonWidget::sendEvent
    [8] 7ff7a2cd48f7 Star::Widget::sendEvent
    [9] 7ff7a2cc1c48 Star::pane::sendEvent
    [10] 7ff7a2cc6f5d Star::paneManager::sendInputEvent
    [11] 7ff7a2d87f8f Star::TitleScreen::handleInputEvent
    [12] 7ff7a245a41a Star::ClientApplication::processInput
    [13] 7ff7a2c5a8d5 Star::SdlPlatform::run
    [14] 7ff7a2c5ac2d Star::runMainApplication
    [15] 7ff7a245ff76 WinMain
    [16] 7ff7a2e48daf __scrt_common_main_seh
    [17] 7ffaf4d01fe4 BaseThreadInitThunk
    [18] 7ffaf76df061 RtlUserThreadStart
    [11:37:21.837] [Info] Application: shutdown...
    [11:37:22.004] [Info] Root: Shutting down Root
    [11:37:22.177] [Info] Application: Destroying SDL Window
    [11:37:22.216] [Info] Application: stopped gracefully



    I presume it's trying to find my custom difficulty mode (which is named "Forgiving") but some part of it is missing? But I might be completely off the mark there!

    Edit: Sorry, not sure how to stop the forum from putting emojis every time there's a : and a P next to each other!

    Another edit: I might have fixed the silly faces, but no luck on the mod hahah
     
    Last edited: Apr 13, 2018
  6. projectmayhem

    projectmayhem Spaceman Spiff

    For the emoji's, put your code inside [ code ] [ /code ] brackets
     
  7. ToddAndChips

    ToddAndChips Tentacle Wrangler

    Ahh ok I just used the [ plain ] ones for that bulk of text.

    Anyway, any idea what the error could be pointing to? I've made no progress unfortunately :/

    Can't seem to find any relevant info online about what "(MapException) Key not found in Map::get()" means...
     
  8. projectmayhem

    projectmayhem Spaceman Spiff

    wish i could help :( bk3k is good with understanding what causes these more technical errors.

    I always thought map exceptions came from it trying to load part of the world and there being a bad array or somethings. Didn't know you could get one on the character creation screen.
     
  9. ToddAndChips

    ToddAndChips Tentacle Wrangler

    That's what I thought from looking online! I'm not sure if it's something to do with not being able to place a spawn point for a player's character on the new difficulty or something. Doesn't seem to be an unrelated error either, all other mods removed and everything.

    Maybe bk3k will see this eventually and hopefully point me in the right direction! Until then I'll remain patient and keep playing around with other mods :)
     

Share This Page