Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Working on a NPC relationship system

darkkitten

Towns Guard
Xy$
0.00
I'm working on a NPC relationship system, but I keep getting a weird Error about U being unsupported or something. Anyway the base for my script is on my github here, If anyone's got any suggestions feel free to help :)
 

eivl

Local Hero
Xy$
0.00
JavaScript:
[
    [Unknown, Known],
    {
        "id": 1,
        "face": People1, 2,
        "name": "Beverly",
        "cat": 0,
        "current_status": "none",
        "desc": "Beverly is outgoing and fun to be around",
        "levelvar": 100,
        "eventid": 17,
        "likes":[
        ["item", 1, false]
        ],
        "dislikes": [
        ["item",3, false]
        ]
    }
]
Your JSON is wrong, unknown is not anything, you should use " to say it is a string.
Same with People1
and the single 2, right after does not mean anything.

Also in your code you must not use the equality operator when assigning a function, and when checking for equality do not use double equal, use triple === instead.

You also need to learn when to use semi colon, you need it after an assignment

JavaScript:
Game_Relationships.prototype.initialize = function() {
        this.data = [];
    };
but not after a function call

JavaScript:
    function Game_Relationships() {
        this.initialize.apply(this, arguments);
    }
you are also running a lot of for loops, and you are declaring variables multiple times when there is no need to,

JavaScript:
for (var i = 0; i < q.likes.length; i++)
then later inside the same method you declare i again in the same way.
Skip the second declaration or just declare it outside the for loop and use just for (i = 0 ...... )

Hope this helps, It was written hastily and without any explanation of why it is so. i can do that at a later time if you want, but since this is the Javascript forum i feel like i might not have to over explain things ;)
[doublepost=1449490019,1449489643][/doublepost]http://www.rpgmakermv.co/threads/json-syntax.1179/
 

eivl

Local Hero
Xy$
0.00
ok, that is just fine, make sure you have code checking on or if not just check it on http://jshint.com/

only error in your code was in the JSON file and where you used == instead of =

Luckily JS is not a strict language, so missing semi colons are not that big a deal, myself i do not fix this before i am done, takes to much time to do that while coding.
 

darkkitten

Towns Guard
Xy$
0.00
Slow moving, as I'm redoing the display window.. I origionally used a Quest system to base this off of, but I don't think that's going to work right.
 
Top