Help Understanding Mod Error Appreciated

You guys are awesome, now not only do I have that particular event functioning in my mod’s code, I also know how to format other events/notifications similar to it. Thanks to this I now have…at least a little bit more understanding about formatting mods for this game. Hopefully there are any other problems with this mod’s code I can figure them out myself.

1 Like

Glad to hear that it works :slight_smile: Don’t hesitate to ask any further questions :wink:

2 Likes

So you don’t mind if I ask another question? I don’t mean to bombard anyone with too many questions. There have been plenty of different errors I’ve had to fix in my efforts to recode the mod I’ve been working on, and I’ve been able to fix most of it myself, I just can’t help but admit there are instances where I just can’t see / don’t understand why certain errors are being recorded.

Even though I’ve been making substantial progress with my mod so far, I’m getting another weird error this time by the case of Uncaught SyntaxError: Unexpected identifier on line 1121. I’ll post the section of the code like I did last time, but this time I’ll be courteous enough to abridge the text field and bolden the line of the script that’s causing problems like list time.

(function () {
var icon = GDT.getRelativePath() + ‘/images/platforms/DoxTesseract Final.png’;
GDT.addPlatform(
{
id: ‘DoxTesseract’,
name: ‘DoxTesseract’,
company: ‘Cryptic Entertainment’,
startAmount: 0.5,
unitsSold: 1.0,
licencePrize: 100000,
published: ‘28/1/1’,
platformRetireDate: ‘34/1/1’,
developmentCosts: 100000,
genreWeightings: [0.9, 1, 1, 0.8, 0.9, 0.7],
audienceWeightings: [0.8, 0.9, 1],
techLevel: 6,
iconUri: icon,
events: [
{
id: ‘2a33185f-49dc-486c-a829-33a13dad374c’,
date: ‘25/11/3’,
getNotification: function (company) {
return new Notification({
header: “The Final Product of the Dox Line”.localize(),
text: “…”.localize().format(General.getETADescription(‘25/11/3’, 34/1/1’)),
image: icon
});
}
}
]
});
}

Here’s the oddest thing though, the code for all the consoles before it in my mod is written in the same way and work (or at least, it should be. I’ve been cross-checking them extensively and haven’t found any problems that I can see at least). What I have noticed posting this into the UME code viewer is that unlike all the other platforms, none of the opening brackets are highlighted with the closing brackets when I highlight them.

You’re missing a single quotation mark before the date 34/1/1 on the line above :slight_smile:

1 Like

Just to clarify, he’s talking about this line:

1 Like

-Tests the line fix, discovers it really was a missing quote…facepalms- Seriously, the only reason it was broken was because I forgot one character? Been so long since I’ve seen an error like that, I’m going to need to check similar instances to that and make sure that mistake isn’t repeated. Wow that was kind of dumb, but at least that section isn’t broken anymore. How did I not see that?

To be fair, it took me a while to figure that out too. It’s always the small things that you never see. :smile:

1 Like

Alright at this point I am literally at the very last error of recoding this mod (at least, this version. Sure it’ll break plenty of times once I finish playtesting it and deem it worthy of additional content). The only thing stopping me from being able to playtest with this mod is this error: Uncaught SyntaxError: Unexpected end of input.

Basically, it doesn’t seem to understand when the code actually ends, and I’ve been trying to put marks at the very end, yet every time I do it complains about unexpected tokens. So I guess my final question is how do I actually format the end of the script?

Assuming you have (function () { at the top of your mod, to end this, all you need to put on your last line is })()

1 Like

One would think. This is the final part of my mod followed by nothing else:

(function () {
GDT.addTopics([
{
id: “Cyborg”,
name: “Cyborg”.localize(“game topic”),
genreWeightings: [1, 0.8, 0.7, 0.9, 0.7, 0.6],
audienceWeightings: [0.6, 0.9, 1],
}
]);
})()

Yet here’s the error I’m getting: Uncaught SyntaxError: Unexpected end of input. I think I might be forgetting one last thing, just not sure where. I appreciate the help I’ve received so far, and I’d be even more grateful if I could get this one last error resolved.

I’m going to need more information than this. Does it tell you what line the error occurs on?

From what I can tell from all the things you’ve posted, is that you put every command (GDT.addTopics, etc. Not sure what the right word to use for this is to be fair) within its separate function. If you actually do do this, it’s probably best if you put all commands in one function.

EDIT: This is a complete wild card, but what if you remove the comma at the end of audienceWeightings?

1 Like

Terribly sorry about not specifying the line, thought I did earlier. I did remove the audienceWeightings comma, and it didn’t seem to change anything. The full error on the same script I posted last time is:

Error Uncaught error. Please report this to support@greenheartgames.com: Uncaught SyntaxError: Unexpected end of input (file:///C:/Program%20Files%20(x86)/Steam/steamapps/common/Game%20Dev%20Tycoon/mods_ws/72428655_TEST_Bit_Of_Everything_RECODED/main/code.js:2002) Please restart the game.

There’s just one problem: There is no line 2002, there’s nothing there. It ends on line 2001.

Here’s the code segment again just for reference:

(function () {
GDT.addTopics([
{
id: “Cyborg”,
name: “Cyborg”.localize(“game topic”),
genreWeightings: [1, 0.8, 0.7, 0.9, 0.7, 0.6],
audienceWeightings: [0.6, 0.9, 1]
}
]);
})()

For the past couple days I’ve been experimenting with a variety of ways to try and end the input of my mod, and what I can conclusively state right now is that for whatever reason I keep getting one of two results:

  1. The mod reports an unexpected end of input if })(); or })() are absent.

  2. The mod reports an unexpected token } or ; if })() or })(); are used respectively.

Even though I’m still a damn newb when it comes to scriptwriting, I’m beginning to suspect that there’s an issue with formatting. It’s just confusing me as to what that issue might be.

Sometimes, when i code a little bit. I’m like:

My code doesn’t work, why?
My code DOES work! But why?

In the timespan between today and yesterday, I only found two things, one of which I could fix. Turns out some false statements a while back were missing semicolons. Necessary fix, but the mod’s still unplayable. Nah, I tried to throw the code into a script fixer, and the closest explanation I could find about my mod being unable to have its input ended without “unexpected tokens” was some kind of “Unrecoverable Syntax Error”. Still experimenting, but I’ve been making sure to give myself a break every now and again hoping I find some profound, unexpected solution.

Apologies for the delayed response. Would it be possible for you to send me your code (through PM would be possible if you’d prefer that)? That way I can understand the way you formatted your code better, and I’ll be able to find a solution for you.

Perfectly understandable, I’ve been busy with life myself. Honestly, I’m just grateful to get any kind of assistance. I’ll be sending the .txt file of the code here in a bit.

I’ve had a look at your source code and I believe I’ve found the problem.

From the point you implement the platforms (around line 1000), you aren’t closing the functions sufficiently (though sometimes you do). You need to close your functions as such:

(function () {
//code
})();

However, from line 1000 downwards, you’re closing them as so

(function () {
};
1 Like

So after making the necessary fixes, discovering new errors that were somehow overlooked and undetected, and fixing said new errors…I was finally able to start up the game without an error message popping up with my mod activated. Now I can finally playtest it! Seriously, thanks to everyone, I wouldn’t have made it this far without your help! Just goes to show how relevant formatting really is.

1 Like

Well I have some good news and bad news: The good news is that the mod is still capable of being loaded without a crippling error on startup. The bad news is, while it was partially playtestable for a time, it now instantly crashes upon starting a new game. I’ve deleted my saves and carefully ensured that the old saves weren’t being restored, yet it doesn’t work. The specific error reads: Error Uncaught error. Please report this to support@greenheartgames.com: Uncaught TypeError: Cannot read property ‘experience’ of null (file:///C:/Program%20Files%20(x86)/Steam/steamapps/common/Game%20Dev%20Tycoon/compressed/codeNw.js:1714) Please restart the game.

Now I actually did try to read that line of script in the Compressed CodeNw file, despite the fact that it’s a fecking nightmare to sort through. The only thing I vaguely understood was that it had something to do with the research sections of my mod (Which I found previously weren’t even being read because I accidentally formatted them as notes). What absolutely confuses me though is that I followed the API very closely, so there shouldn’t be anything wrong with the research section of my mod…but there is so there must be something I’m not seeing.