Page 1 of 1

Alias Type Error

Posted: 29 Jun 2016 21:12
by Lelouch
Hello, I'm new to the forums and game, so if this falls under "sensitive game information," sorry, I didn't mean to.
Well, recently I've tried out the paths alias that is written in the guide on the website. The code I have is directly copied and pasted from the guide, but when I added a new path, there was a problem. The orcs to shop path in the guide worked both ways, but when I made a path from sparkle to faerie, the "sparkle_to_faerie" command worked fine, but faerie_to_sparkle didn't work. When I typed in "faerie_to_sparkle", the system said the following:
Error in alias TypeError: Cannot read property 'reverse' of undefined

Now, the path is correct, since I could travel from sparkle to faerie without a hitch, but the reverse didn't work for some reason. This is my code for update_paths:

Code: Select all

gwc.userdata.paths = {
shop_to_orcs:[
'n','w','w','w','n','n','w','w','w',
'w','w','w','w','w','w','w','w','w',
'n','w','w','n','n','n','n','n'
],

sparkle_to_faerie:[
'w','n','n','w','w','w','w','w','w',
'w','w','w','w','w','w','w','w','w',
'sw','s','s','sw','w','sw','sw','sw',
's','se','s','se','e','se','se','se',
'se','e','e','se','se','e','se','se'
],

reverse : {
'n':'s', 's':'n', 'e':'w', 'w':'e',
'nw':'se', 'ne':'sw', 'sw':'ne', 'se':'nw',
'u':'d', 'd':'u', 'in':'out', 'out':'in'
},

go:function(path) {
path.forEach(function(step) {
gwc.connection.send(step);
});
},

go_back:function(path) {
path.reverse();
path.forEach(function(step) {
step = gwc.userdata.paths.reverse[step];
gwc.connection.send(step);
});
}
};
gwc.output.append("Your paths have been updated!");
This is my sparkle_to_faerie alias:

Code: Select all

var p = gwc.userdata.paths;
p.go(p.sparkle_to_faerie);
This is my faerie_to_sparkle alias:

Code: Select all

var p = gwc.userdata.paths;
p.go_back(p.faerie_to_sparkle);
Can someone help with this? Thank you very much.

Re: Alias Type Error

Posted: 30 Jun 2016 00:31
by Gronkas
Took me a while to spot, you probably found the error yourself by now.

The definition for the faerie_to_sparkle alias needs to be:
Code:
var p = gwc.userdata.paths;
p.go_back(p.sparkle_to_faerie);


the p.go_back will reverse the path, but of course you only defined the sparkle_to_faerie path in the upgrade_paths alias - which
is the one you plan to reverse.

So only the alias is called "faerie_to_sparkle", the path inside is "p.go_back(sparkle_to_faerie)"

Re: Alias Type Error

Posted: 30 Jun 2016 01:31
by Melarec
I just use my numpad.
;-;

Re: Alias Type Error

Posted: 30 Jun 2016 08:47
by Orien
Tips: Change "update_path" to "z", "sparkle_faerie" to "sun_tree", well Orien obsesses with typeless and no-spam. You need to update your path after using too, if not your path will gone mess

Example: Normal path: e e n n w w s s Normal reverse: n n e e s s w w
Mess reverse: w w s s e e n n

Re: Alias Type Error

Posted: 01 Jul 2016 19:28
by Lelouch
Thanks, I'm not that good with coding (if not a complete newbie), I just understand the basic theory behind what a code means. So errors like this I can't really spot. I see the mistake now, though. Thanks for the help once again!