Jump to content
  • 0

obtain randomly instead of chronologically ordered


Question

Posted
if ( abcde < 4 )
			abcde++;
		for ( .@i = 0; .@i < abcde; .@i++ )
			.@form$ = .@form$ + .word$[.@i] +" ";
		for ( .@i = abcde; .@i < 4; .@i++ )
			.@form$ = .@form$ +"_ ";
		message strcharinfo(0), "Letter's Collected : "+ .@form$;

instead of collecting chronologically at random % how to change it to obtain the letters randomly

 

PS: i dont know what to put into the tittle . to the moderators kindly edit it thanks!

4 answers to this question

Recommended Posts

  • 0
Posted

you could try something like this.

initialize all the character as specific character, then search and replace them randomly.

if (abcde$ == "")
	abcde$ = "____"; // initialize with a dummy character

if (compare(abcde$, "_")) {
	.@length = getstrlen(abcde$);
	do {
		.@index = rand(.@length);
	} while (charat(abcde$, .@index) != "_")); // search for it
	setchar(abcde$, .word$[.@index], .@index); // replace it
}
message strcharinfo(0), "Letter's Collected : "+ abcde$;

 

  • 0
Posted (edited)
if (abcde$ == "")
	abcde$ = "____"; // initialize with a dummy character

if (compare(abcde$, "_")) {
	.@length = getstrlen(abcde$);
	do {
		.@index = rand(.@length);
	} while (charat(abcde$, .@index) != "_"); // search for it
	abcde$ = setchar(abcde$, .word$[.@index], .@index); // replace it
}
message strcharinfo(0), "Letter's Collected : "+ abcde$;
end;

jbtafYu.png

Edited by Emistry

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...