How to make a string with spaces in a plugin command?

Aura_Gamer

Villager
Member
Joined
Jun 24, 2018
Messages
18
Reaction score
2
First Language
English
Primarily Uses
RMMV
I'm making a plugin which shows text at different locations of the screen. :rhappy:

Unfortunately my approach was by plugin commands and my messages of course include spaces which makes the plugin think it as another argument.

Like I say: drawText My message with spaces 0 0
(STRING MESSAGE, X, Y)

I can't find any solutions..:kaoback:
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,068
Reaction score
6,698
First Language
German
Primarily Uses
RMMV
1) have your plugins re-combine the arguments into a string. requires that the string is the last argument in the command, but a simple loop if it is.

2) you can try (no guarantee) to see if the default plugin command accepts "" as a declaration for a string argument
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,893
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
I'm making a plugin
my messages of course include spaces
if you're the author,..... maybe set it up so that strings are quoted and parameters are separated by commas? use parentheses? use colons?
IDK! you're the author! you can set it up however you want! 0o

drawText(string, param, param)
drawText: string, param, param.
drawText, "string", param, param.
drawText(param, param): "string"

so many variations.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,401
Reaction score
880
First Language
EN
Primarily Uses
RMMV
More possibilities~
  • Ask users to type the message with a different character (e.g. underscore) instead of spaces, then do a global replace:
    Code:
    var msg = args[0].replace(/_/g, ' ');
    Global replace (MDN): link.

  • Rearrange the arguments to "x y text" and do something like this (basically Andar's first suggestion):
    Code:
    var x = parseInt(args[0], 10) || 0;
    var y = parseInt(args[1], 10) || 0;
    var msg = args.slice(2).join(' ');
    Array.slice (MDN): link.
    Edit: and Array.join (MDN): link. :kaoslp:
 
Last edited:

Aura_Gamer

Villager
Member
Joined
Jun 24, 2018
Messages
18
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thanks for all the replies!

I did it like this:

Code:
var text = args[0] + " ";
var i = 1;
var word;

while(!args[i - 1].includes(",")) {
if(args[i].includes(",")) {
word = args[i].slice(0, -1);
} else {
word = args[i] + " ";
}

text += word;
i++;
}

var x = Number(args[i + 1]);
var y = Number(args[i + 2]);

CreateMessage(text, x, y);
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Having lots of fun using different PS brushes to add a lil' texture to the floors and walls in my maps.
Setup a system to cull enemies that are too far from the player to matter, and to spawn new ones just outside of view. Take that lag! :LZSexcite:
That trope is alive more than ever, not so much elemental Crystal's but gathering magical objects or doing "task" to unlock this oddly specific thing is everywhere, I saw it saw it in the IT 2 remake, avengers and every season of supernatural
It's raining...in winter :")

Forum statistics

Threads
93,717
Messages
914,891
Members
123,319
Latest member
chrisred801
Top