Coding Help Coding dialogue error, dialogue won't load in game (edit: 19/12/2021, issue solved)

jinnnkies

Greenhorn
edit: as of 29/12/2021 i've figured out how to do this, thank you if you tried to help me! :)



I've been trying to create a custom npc but the dialogue is really stumping me. I wanted their dialogue to show up only under certain conditions (in this case for now, specific heart levels)

I've used the json parser with this code and it comes back with no errors but whenever I try to actually talk to the npc in game it comes back with an error and I don't know how to fix it.

Here's my json validator link and my smapi log, any solutions?

 
Last edited:

IntoxicHeart

Planter
I want to first start out by mentioning I’m still working out coding, but I figured I’d share my own personal experiences thus far while coding, and what has worked for me.

I attempted to replicate your JSON, and it did not work for me either.

For me, I have found the “When” to only work for specific festivals, which in that case, the target must be changed.

Working example:

{
"Action": "EditData",
"Target": "Data/Festivals/spring13",
"When": {
"Language": "en",
"Hearts:Sam": "0, 1, 2, 3, 4, 5, 6, 7, 8"
},
"Entries": {
"Sam": "Hey @. Are you going to partake in the egg hunt? Well, best of luck to you. Abby is a tough component. Haha.$h"
}
},


For specific days of the week, I have the heart level next to the day of the week.

Working example:

{
"Action": "EditData",
"Target": "Characters/Dialogue/Sam",
"Entries": {
"Mon2": "Yo!#$b#I was hoping that I would catch you. Are you heading out to the mines today? If you are, be safe out there.$h",
"Mon4": "@, how are things going? If you are heading to the mines, can I join? I promise to not get in your way, haha.$h",
"Mon6": "Just the person I was hoping to see. Want to grab something to eat at the saloon later?$h",
}
},

For a specific seasonal day of the week, it would be changed to "<season>_<day><heart level>": "<dialogue>",

Example:
"spring_Mon2": "Hey! How is it going?",


Now, again, I am still working out coding, so there might be a way to make it work the way you have attempted, but when searching around the wiki, I haven’t had any luck in finding such methods. I have also not seen your method in other dialogue mods.

I hope this is somehow helpful/useful, and I apologize if not. ^^; I was just wanting to share my own personal experience thus far, and how coding dialogue has worked for me thus far.
 

jinnnkies

Greenhorn
I want to first start out by mentioning I’m still working out coding, but I figured I’d share my own personal experiences thus far while coding, and what has worked for me.

I attempted to replicate your JSON, and it did not work for me either.

For me, I have found the “When” to only work for specific festivals, which in that case, the target must be changed.

Working example:

{
"Action": "EditData",
"Target": "Data/Festivals/spring13",
"When": {
"Language": "en",
"Hearts:Sam": "0, 1, 2, 3, 4, 5, 6, 7, 8"
},
"Entries": {
"Sam": "Hey @. Are you going to partake in the egg hunt? Well, best of luck to you. Abby is a tough component. Haha.$h"
}
},


For specific days of the week, I have the heart level next to the day of the week.

Working example:

{
"Action": "EditData",
"Target": "Characters/Dialogue/Sam",
"Entries": {
"Mon2": "Yo!#$b#I was hoping that I would catch you. Are you heading out to the mines today? If you are, be safe out there.$h",
"Mon4": "@, how are things going? If you are heading to the mines, can I join? I promise to not get in your way, haha.$h",
"Mon6": "Just the person I was hoping to see. Want to grab something to eat at the saloon later?$h",
}
},

For a specific seasonal day of the week, it would be changed to "<season>_<day><heart level>": "<dialogue>",

Example:
"spring_Mon2": "Hey! How is it going?",


Now, again, I am still working out coding, so there might be a way to make it work the way you have attempted, but when searching around the wiki, I haven’t had any luck in finding such methods. I have also not seen your method in other dialogue mods.

I hope this is somehow helpful/useful, and I apologize if not. ^^; I was just wanting to share my own personal experience thus far, and how coding dialogue has worked for me thus far.
thank you for your reply! i'm extremely new to coding and maybe some of this is out of my league lmao so i appreciate any help. i'll try to do what you said and see if it works :)

also i notice you put your 'when' statement above the entries in your first working example, does this make a difference somehow?
 

IntoxicHeart

Planter
Your welcome. ^^ Also, I know the feeling of how coding can ‘feel out of my league’, for I have felt that way too, but I want to provide encouragement not to give up!

Also, I believe it does. Every dialogue json files I have seen have the ‘when’ in that area. I believe it has something to do with how the code is read. I can be horrible at explaining, but I’m going to attempt to explain.

When a program reads a coding that changes something, it first looks for the action (which would be for it edit a specific data), then the target (what specifically is editing, in this case, it’s a character), and then the criteria (in this case, the character and the hearts level of that character), then after it reads the target and criteria, it reads what is going to be changed/to be done (in this case, it’s going to either change dialogue or add dialogue in).

Now, I could be wrong, but I believe that’s how it’s done and why I’ve only ever seen it typed out that way.


I guess another way to look at it is that the programming is following specific instructions before it then does what those instructions are telling it to do. If the instructions aren’t there to read at the top, and part are at the bottom beneath the changes, it might ‘confuse’ the program. That’s how I view it anyhow. Again, this is what I’m believing based off what I have seen and read.

Side note;; what program are using for the json? I highly recommend NotePad++. It’s free and such an awesome helper for coders. It’ll even pinpoint/highlight certain ‘errors’ that doesn’t make sense to it, which those are ‘errors’ that would cause the file to no work properly in a program. Also, if you double click on a word, it’ll highlight that word throughout the entire file (if that word is used more than once), which can be useful if you’re looking for something specific.
 

jinnnkies

Greenhorn
Your welcome. ^^ Also, I know the feeling of how coding can ‘feel out of my league’, for I have felt that way too, but I want to provide encouragement not to give up!

Also, I believe it does. Every dialogue json files I have seen have the ‘when’ in that area. I believe it has something to do with how the code is read. I can be horrible at explaining, but I’m going to attempt to explain.

When a program reads a coding that changes something, it first looks for the action (which would be for it edit a specific data), then the target (what specifically is editing, in this case, it’s a character), and then the criteria (in this case, the character and the hearts level of that character), then after it reads the target and criteria, it reads what is going to be changed/to be done (in this case, it’s going to either change dialogue or add dialogue in).

Now, I could be wrong, but I believe that’s how it’s done and why I’ve only ever seen it typed out that way.


I guess another way to look at it is that the programming is following specific instructions before it then does what those instructions are telling it to do. If the instructions aren’t there to read at the top, and part are at the bottom beneath the changes, it might ‘confuse’ the program. That’s how I view it anyhow. Again, this is what I’m believing based off what I have seen and read.

Side note;; what program are using for the json? I highly recommend NotePad++. It’s free and such an awesome helper for coders. It’ll even pinpoint/highlight certain ‘errors’ that doesn’t make sense to it, which those are ‘errors’ that would cause the file to no work properly in a program. Also, if you double click on a word, it’ll highlight that word throughout the entire file (if that word is used more than once), which can be useful if you’re looking for something specific.
oh i've never heard of notepad++, i'm using visual studio currently. is it a better software to use?

also thank you for the encouragement and explanation, i'm going to keep trucking along until i find a solution :)
 

IntoxicHeart

Planter
oh i've never heard of notepad++, i'm using visual studio currently. is it a better software to use?

also thank you for the encouragement and explanation, i'm going to keep trucking along until i find a solution :)
They're about the same, and it essentially boils down to preference. ^^ So, you can download NotePad++ and check it out, or not. It's fine either way~. I just personally use NotePad++ since it's what was recommended to me to use. I haven't personally used Vision Studios, but I know someone who has used it and NotePad++ (he's also the one who recommended NotePad++ to me), and he's the one who informed me it comes down to preference.

Your welcome! I'm sending you the best vibes and luck that you get this working.
 
Top