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
31,365
Reaction score
7,675
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
2,248
Reaction score
1,250
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
2,088
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
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 Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top