Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Strifen on July 23, 2012, 07:10:15 PM

Title: Fiddle with Mod creation, get Errors 2 <Solved!>
Post by: Strifen on July 23, 2012, 07:10:15 PM
  While trying to mod in a new Laser weapon to get a hang of using the fx folder, I got this error when loading up the mod:
Spoiler
Fatal: A JSONObject text must begin with '{' at 1 [character 2 line 1]
Check starfarer.log for more info.
[close]

It seemed simple enough to solve, the only .json in the mod is the mod_info.json; The mod had worked before adding in this 'Laser weapon' update, but I checked anyway - '{' is right where it's supposed to be - the first character; just to make sure I checked all the text files, but they're all alright as well.

It occurred to me that this may have been a problem caused by the editor I use, but it appeared alright in all the other text editors I used.

I am stumped as to what the problem could be, as I can't find anything wrong with the update files, but since the mod worked beforehand it must be something to do with them; If anyone has an Idea as to what the problem might be, I'd appreciate the help.

Here are the relevant file texts affected/concerning the update causing the error:

The .log -
Spoiler
18587 [Thread-6] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading weapon [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\data\weapons\particlewavebeam.wpn]
18587 [Thread-6] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\data\weapons\particlewavebeam.wpn]
18606 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.plugins.BattleObjectivesFleetPointsPluginImpl]
18637 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.plugins.BattleObjectivesFogOfWarPluginImpl]
18656 [Thread-6] INFO  com.fs.profiler.Profiler  - ID     Calls   Duration    Percent
18658 [Thread-6] INFO  com.fs.profiler.Profiler  - --------------------------------
18666 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
   at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
   at org.json.JSONObject.<init>(JSONObject.java:184)
   at org.json.JSONObject.<init>(JSONObject.java:311)
   at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.G.o00000(Unknown Source)
   at com.fs.oOOO.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
18671 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.BaseSpawnPoint]
18719 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.SectorGen]
18876 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.missions.turningthetables.MissionDefinition]
18950 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.missions.forthegreaterlud.MissionDefinition]
[close]
The .wpn - [really just a gravbeam edit]
Spoiler
{
   "specClass":"beam",
   "id":"particlewavebeam",
   "type":"ENERGY",
   "size":"MEDIUM",
   "displayArcRadius":550,
   "turretSprite":"graphics/weapons/graviton_beam_turret_base.png",
   "turretGlowSprite":"graphics/weapons/graviton_beam_turret_glow.png",
   "hardpointSprite":"graphics/weapons/graviton_beam_hardpoint_base.png",
   "hardpointGlowSprite":"graphics/weapons/graviton_beam_hardpoint_glow.png",
   "turretOffsets":[15, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[23, 0],
   "hardpointAngleOffsets":[0],
   "fringeColor":[5,135,175,255],
   "coreColor":[200,225,255,255],
   "glowColor":[25,215,255,255],
   "width":20.0,
   "textureType":["graphics/fx/particlewavefringe.png","graphics/fx/particlewavecore.png"],
   "textureScrollSpeed":260.0,
   "pixelsPerTexel":5.0,
   "pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER],
   "fireSoundOne":"beam_medium_intro",
   "fireSoundTwo":"beam_medium_loop",
}
[close]
The weapon_data.csv - [Copy-pasted straight from the excel sheet.]
Spoiler
Particle Wave Beam   particlewavebeam   2   3000   725   250         75   25   10         KINETIC      50   0.85   0.2
[close]
The mod_info.json -
Spoiler
{
  "id":"strifen_wip_mod",
   "name":"Strifens' WIP",
   "version":"0.1.4",
   "description":"Adds Strifens' WIP Mod-stuff to your game",
   "gameVersion":"0.52a",
   "totalConversion":"false",
   "replace":[
      
   ],
}
[close]

Edit: The Problem seems to have been some rather strange behavior on the part of Libre Office, trouble with BOMs and the Corruption of .wpn files

Case Solved
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Alex on July 23, 2012, 07:27:18 PM
Can you check to make sure that you JSON files are saved using the UTF-8 character encoding?
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 07:44:52 PM
  It seems I switched to using Western Europe (ISO-8859-15/EURO); I remember setting it to Western Europe (Windows-1252/Winlatin 1) due to the example given in the second post of the 'Modding Tools and Resources'
Spoiler
http://fractalsoftworks.com/forum/index.php?action=dlattach;topic=633.0;attach=272;image
[close]

I'll try runningediting it into Unicode (UTF-8) and seeing if it works

Edit: Now I'm getting a
Spoiler
Fatal: Error loading mod descriptor [C:Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]
[close]
error before the launcher even pops up.

How does that even happen...
[C:Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]
I don't even understand why that is, unless it's just what 'happens' when trying to load a mod.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Alex on July 23, 2012, 09:03:09 PM
[C:Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]
I don't even understand why that is, unless it's just what 'happens' when trying to load a mod.

That's a valid path - the .. just means "go up a level" - so that's not the problem. Looks like it dies when it tries to take a look at the available mods - the descriptors get parsed when the launcher runs. There ought to be a bit more in the logs about the exact error.


Are you certain it's UTF-8? I'm asking because you keep calling it unicode, and it's not - it's just UTF-8 - so just want to make sure there's no confusion.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 09:10:20 PM
-snip-
Are you certain it's UTF-8? I'm asking because you keep calling it unicode, and it's not - it's just UTF-8 - so just want to make sure there's no confusion.

(http://i47.tinypic.com/2ue1kl2.jpg) ?
mostly certain*

*Note: The way I 'edited'** it into UTF-8 was
  - Open in the Unicode (UTF-8) format
  - Delete the 'i' in "id"
  - Refill the 'i' in "id"
  - Save

It is possible that may be where the misfortune lies.

**NoteII: When I got the error when using UTF-8 format, I hadn't mad a proper back-up, so I 'restored' the folder[mod_info.json] version' by coping what I'd posted here. When it copied the...well, color of the forum as well, I pasted it back in as plain text, resulting in that continuous, flatline text look instead of properly segregated and well-spaced sections; while I plan on fixing this, the mod version available for download hasn't been properly re-adjusted, so there's also that.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Alex on July 23, 2012, 09:12:16 PM
Odd. If you can upload the mod somewhere, I'll take a quick look.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 09:22:40 PM
Here's the .log of that "Fatal: Error loading mod descriptor [C:Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]" error:

.log -
Spoiler
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starfarer 0.52.1a launcher
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Windows 7 6.1
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.6.0_18
16   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod: ironclads [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\ACM]
16   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod: inorbita [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\ascendency-A.5-full]
16   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod: CAELUS [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\CAELUS]
16   [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.RuntimeException: Error loading mod descriptor [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]
java.lang.RuntimeException: Error loading mod descriptor [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\mod_info.json]
   at com.fs.starfarer.launcher.ModManager$1.accept(Unknown Source)
   at java.io.File.listFiles(File.java:1134)
   at com.fs.starfarer.launcher.ModManager.?00000(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.<init>(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.return(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
   at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
   at org.json.JSONObject.<init>(JSONObject.java:184)
   at org.json.JSONObject.<init>(JSONObject.java:311)
   at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.o00000(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.o00000(Unknown Source)
   ... 7 more
[close]
.
Odd. If you can upload the mod somewhere, I'll take a quick look.
Many thanks.

First_Mod.zip: -REMOVED-
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Alex on July 23, 2012, 09:34:41 PM
Aha. Looks like Starfarer doesn't handle a BOM (http://en.wikipedia.org/wiki/Byte_order_mark) at the beginning of a UTF-8 file properly (it's optional - and meaningless - in the format). If you just convert it to ASCII, it'll work. Meanwhile, I'll see about making it work when a file starts off with a BOM.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 09:59:26 PM
Aha. Looks like Starfarer doesn't handle a BOM (http://en.wikipedia.org/wiki/Byte_order_mark) at the beginning of a UTF-8 file properly (it's optional - and meaningless - in the format). If you just convert it to ASCII, it'll work. Meanwhile, I'll see about making it work when a file starts off with a BOM.
That solves the second problem, but the original problem still comes up after starting up...

How'd you 'convert it to ASCII', exactly? I tried to with Libre Office and Notepad++, but still get the original error.
IE:
Spoiler
Fatal: A JSONObject text must begin with '{' at 1 [character 2 line 1]
Check starfarer.log for more info.
[close]
and
Spoiler
18587 [Thread-6] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading weapon [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\data\weapons\particlewavebeam.wpn]
18587 [Thread-6] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starfarer\starfarer-core\..\mods\First_Mod\data\weapons\particlewavebeam.wpn]
18606 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.plugins.BattleObjectivesFleetPointsPluginImpl]
18637 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.plugins.BattleObjectivesFogOfWarPluginImpl]
18656 [Thread-6] INFO  com.fs.profiler.Profiler  - ID     Calls   Duration    Percent
18658 [Thread-6] INFO  com.fs.profiler.Profiler  - --------------------------------
18666 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
   at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
   at org.json.JSONObject.<init>(JSONObject.java:184)
   at org.json.JSONObject.<init>(JSONObject.java:311)
   at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.G.o00000(Unknown Source)
   at com.fs.oOOO.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
18671 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.BaseSpawnPoint]
18719 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.SectorGen]
18876 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.missions.turningthetables.MissionDefinition]
18950 [Thread-10] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.missions.forthegreaterlud.MissionDefinition]
[close]
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: LazyWizard on July 23, 2012, 10:09:17 PM
In Notepad++, you can fix this with "Encoding -> Encode in UTF-8 without BOM". But changing the encoding to ANSI works just as well.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 10:15:24 PM
In Notepad++, you can fix this with "Encoding -> Encode in UTF-8 without BOM". But changing the encoding to ANSI works just as well.
This also still results in the original error.
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: LazyWizard on July 23, 2012, 10:21:05 PM
In Notepad++, you can fix this with "Encoding -> Encode in UTF-8 without BOM". But changing the encoding to ANSI works just as well.
This also still results in the original error.
Ah, it seems LibreOffice destroyed your weapon file; it looks like you saved it as a document at some point. Open it in Notepad++ and paste in the text from your first post here, that should fix it. You might want to stick to Notepad++ for editing these kinds of files in the future. :)
Title: Re: Fiddle with Mod creation, get Errors 2
Post by: Strifen on July 23, 2012, 10:29:55 PM
In Notepad++, you can fix this with "Encoding -> Encode in UTF-8 without BOM". But changing the encoding to ANSI works just as well.
This also still results in the original error.
Ah, it looks like LibreOffice destroyed your weapon file. Open it in Notepad++ and paste in the text from your first post here, that should fix it.

Huzzah, That fixed it! I Thank You both, Alex and LazyWizard.
How strange Libre Office can be...

Case Solved