MZ "Concat Is Not Defined" for Altimit Movement

So I've been using the Altimit Pixel Movement plugin for my project, and when I recently made the switch from MV to MZ, I started using agoaj's MZ port of Altimit (found here). It works great for the most part, but now I've encountered an issue that wasn't present in the MV version.

Every time I try to use the plugin commands to move my followers (for cutscenes and whatnot), I simply get a "ReferenceError: concat is not defined." I'm not very well-versed in JS, so unfortunately I'm not sure how I would go about fixing this. It's the smoothest pixel movement plugin I've tried, and I'm still hoping to continue my project in MZ, so any and all insight I could get on this would be much appreciated!

For reference, I'm testing it in a new, blank project with no other plugins, so I know it's not conflicting with any other plugins.
1.PNG
2.PNG
I know the plugin for MV but not the ported version to MZ, but
the error shows you miss something, but to pinpoint what
is the missing "console.log" what we need to see.

that explain the error more than that, as it would be hard to
know what you miss.
I know the plugin for MV but not the ported version to MZ, but
the error shows you miss something, but to pinpoint what
is the missing "console.log" what we need to see.

that explain the error more than that, as it would be hard to
know what you miss.

Hi, thanks so much for your reply!

Here's what the console says whenever the error occurs. Very sorry for not providing pics of this in the first place, haha.

3.PNG

4.PNG
adding pictures is good, just add the correct ones.

as I dont know js that good, but I do know concat(code) is something
I know just by function:

but I think "follower1" in your parameters is wrong now that I look at the line
of the code and the image. as followers use lower numbers than 1.

so -1 is follower 1, so mover = -1 instead of follower1 (which is my guess).
-2 for follower2.

if those number does not fix the issue, maybe someone using MZ or js coder
might know what it could cause or the author that ported it.
The error message seems to be absolutely correct - it's saying that "concat" is being called like a function, but there isn't any such function defined.

JavaScript has a concat method of arrays and strings, but this isn't calling it from another object.

RPG Maker doesn't have any concat function defined.

So unless it's defined inside this plugin (which, apparently, it's not), that code doesn't mean anything.

You might compare the similar function from the original plugin to see what's supposed to be getting combined in that command.

Not having looked at this at all before, the way the author is treating arrays as strings is frankly a bit confusing to me. Like, I understand the mechanics of doing so, but I have no idea why you would choose to do it.

I also don't get why he's vice versa treating strings like numbers. What's the point of repeatedly referencing 'follower'.length when that's always the same number? Just type 8.

You can try replacing that line with this, but since I'm not certain what some of the original code is trying to do, it might not work correctly:
Code:
step.other=step.other.substring(0, 'follower'.length).concat(followerNumber-1);

@caethyril - might you be able to explain any of the above?
Looking at the code from the screenshot, it's most likely a mistake from the plugin developer. You can ask him/her for a fix.

In the meantime, you can quickly create a concat function by yourself to resolve this problem. Just make a new plugin and insert this:

Code:
global.concat = function(a, b) {
  return a + b
}

To be honest, it's hard for me to see what the concat function was originally designed for. So it's likely that this code snippet does not work instantly and needs some refinements.
To be honest, it's hard for me to see what the concat function was originally designed for. So it's likely that this code snippet does not work instantly and needs some refinements.
I'm glad it's not just me having a hard time reading this 😛
Thanks for your suggestions, everyone! I just finished trying each of them out, but unfortunately, I still receive error messages.

Here's when I tested what ShadowDragon suggested:

5.PNG
6.PNG
7.PNG



Here's when I tested what ATT_Turan suggested:

8.PNG

9.PNG

10.PNG



And here's when I tested what Aerosys suggested:

11.PNG

12.PNG

13.PNG



I still really appreciate everyone's insight on this, and I'm at least glad to see that I was correct in thinking this was an oversight on the port author's end. Though I'm not sure if contacting them directly would be very successful, since it seems that they haven't been online here in over a year. :/


EDIT:

I've been messing around with the code to see if I can come up with anything on my own (despite my complete lack of JS knowledge, haha), and I made an interesting discovery. I don't really know if it means anything, but whenever I capitalize "Follower" in lines 4826 and 4841, and then test it out, I get some sort of follower movement without any error messages. It's just not quite right.

My test event is designating that Follower 1 should move 5 tiles to the left, but when I test it with this altered version of the plugin, it only makes Follower 2 move 5 tiles to the left and Follower 3 follow her that way for about a tile or so, before they both automatically turn around and try to come back to the leader. Very confusing and possibly useless, but I figured I would report my findings anyway.

14.PNG
keep in mind, if you change "follower" to "Follower", you should do
that with the others too to make them correct.

as Follower and follower are 2 different variables.

I cannot help you further because I'm out of idea's.
I think the string stuff is because the port just tries to convert the MZ parameters into MV format (string separated by spaces), so they can just feed those inputs to the original plugin commands. The code looks very rushed, though, and I don't know what compelled them to try to use concat like that. 😴

Re @Aerosys's suggestion, try this in a plugin instead:
JavaScript:
/*:
 * @target MZ
 */
globalThis.concat = function(...args) { return args.join(' '); }
global is a different scope, though I don't know the exact details of what it represents in NW.js. E.g. global.$dataActors is not defined.

Also, I quickly skimmed the code and spotted an inconsistency with how the plugin commands are structured. They've written the MZ commands as arrow functions, which means they forfeit the this value (current interpreter). That means any interpreter-based functionality in those commands, e.g. wait for movement, will not work if called from a parallel event. You can fix it by rewriting the commands as "proper" functions, e.g.
Spoiler: command example
From the MZ port:
JavaScript:
PluginManager.registerCommand(pluginName, "setThisCollider", args => {
  const presetCollider = Collider.getPreset(args.colliderPreset);
  if(presetCollider){
    const eventId = $gameMap._interpreter._eventId;
    const event = $gameMap.event(eventId);
    if(event){
// etc
Replace:
  • The arrow function:

    args => {
    ...with a normal function:

    function(args) {
  • And the main interpreter reference:

    $gameMap._interpreter._eventId
    ...with this:

    this._eventId
I think the string stuff is because the port just tries to convert the MZ parameters into MV format (string separated by spaces), so they can just feed those inputs to the original plugin commands. The code looks very rushed, though, and I don't know what compelled them to try to use concat like that. 😴

Re @Aerosys's suggestion, try this in a plugin instead:
JavaScript:
/*:
 * @target MZ
 */
globalThis.concat = function(...args) { return args.join(' '); }
global is a different scope, though I don't know the exact details of what it represents in NW.js. E.g. global.$dataActors is not defined.

Also, I quickly skimmed the code and spotted an inconsistency with how the plugin commands are structured. They've written the MZ commands as arrow functions, which means they forfeit the this value (current interpreter). That means any interpreter-based functionality in those commands, e.g. wait for movement, will not work if called from a parallel event. You can fix it by rewriting the commands as "proper" functions, e.g.
Spoiler: command example
From the MZ port:
JavaScript:
PluginManager.registerCommand(pluginName, "setThisCollider", args => {
  const presetCollider = Collider.getPreset(args.colliderPreset);
  if(presetCollider){
    const eventId = $gameMap._interpreter._eventId;
    const event = $gameMap.event(eventId);
    if(event){
// etc
Replace:
  • The arrow function:

    args => {

    ...with a normal function:

    function(args) {

  • And the main interpreter reference:

    $gameMap._interpreter._eventId

    ...with this:

    this._eventId

Hi, thanks for your time and insight!

I went and created a new "concat" plugin with the code you specified, and I also went into (a fresh copy of) the Altimit code and replaced all instances of args => { with function(args) { and replaced both instances of $gameMap._interpreter._eventId with this._eventId.

And this is what the console tells me:

16.PNG


Is there something I should do to this area of code as well?

17.PNG
The error means that target is undefined. That method expects target to be a string. So I expect it's a problem with the input from line 4853: calling altMovementMoveCharacter with a string that does not correctly represent the MV plugin command arguments. That might be due to the port's messy code and/or because I didn't correctly guess what the concat function was supposed to do.

The MZ move command function should "simply" convert its arguments (e.g. args.mvr) into a string representing the corresponding MV plugin command args. Then it can pass that string to altMovementMoveCharacter. The MV plugin command arg order seems pretty convoluted, though:

AltMovement move "foo bar" up 0.1 # Moves event named "foo bar" up 0.1 units AltMovement move 2 east 1 wait skip # Moves event ID 2 east 1 unit, wait and skip AltMovement move this 9 0.5 # Moves current event upper-right 0.5 units AltMovement move player top_left edge # Moves player upper-left to tile edge AltMovement move follower0 away boat 2 # Moves follower 0 2 units away from boat AltMovement move follower2 toward follower0 0.5 # Moves follower 2 0.5 units towards follower 0 AltMovement move airship random 6.5 # Moves airship in random direction 6.5 units AltMovement move this forward 1 skip # Moves current event forward 1 unit
I can't get my head around that at the moment. 😴

(I'll leave these direct links to the plugin github pages here for convenience: MV, MZ.)
@PhantomPixel Is there any other plugin that may accomplish what you want? This is getting toward a lot of effort from various people to fix a hastily-done port of a convoluted plugin 🤣

@caethyril that's a whopper! There are so many freaking options for that second argument. It seems like it would've been much easier to break it into, like, two commands (one with strict directions and one with relative) and not give the user so many options for how to type it.

Just say "the syntax is..." numbers or words and let that be that.
I dont get "concat" behind = part and most concat is used with Name.concat(stuff)
and not without something before it which there is nothing to concat for.

so I dont know even if it is even functional or that you are missing parameters
inside the game or config of the plugin to make it work correctly.

but I think you can do what ATT_Turan said if it's possible for another plugin.
Ah, yeah, I had a feeling this wasn't going to be a simple fix, haha! So I'll probably just end up using the Cyclone Movement plugin or something if I can't figure anything else out.

Either way, thanks so much for your assistance, everyone! I really appreciate it. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/concat-is-not-defined-for-altimit-movement.153358/