GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2017-08-10 02:43:33

lostdarkwolf
Member
Registered: 2015-11-19
Posts: 31

name generation script (modified from "speakable_password")

this script is basically an improved version of "speakable_password". it is very flexible.
EDIT: added dual consonant features and fixed some small issues.

Expand/// make_word(length, reroll_chance, end_in_y, dual_vowel, th_sh_chance, ll_chance)
//
//  This is a modified version of the speakable_password script by xot and Keith.
//  It has been remade to generate words that look more like names.
//  Returns a random, speakable word of the given length.
//  All arguments are optional.
//
//      length          length of the generated word, real
//      reroll_chance   chance for re-rolling a second subsequential vowel if this vowel is detected to be the same as the vowel before it. real (out of 100)
//      end_in_y        chance that the word will end with a "y" when a vowel is called for, real (out of 100)
//      dual_vowel      chance that two vowels will occor when calling for vowels, real (out of 100)
//      th_sh_chance    chance that "h" will occor after "t" or "s"
//      ll_chance       chance that another "l" will occor after one "l"
//
/// GMLscripts.com/license

{
    var result,i;
    result = "";
    i=0;
    var word_length=3+(1+random(99)>80)+(1+random(99)>40)+(1+random(99)>20)+(1+random(99)>10)+(1+random(99)>5)+(1+random(99)>2.5);
    if argument_count>0 word_length=argument[0];
    
    var reroll_chance=95;
    if argument_count>1 reroll_chance=argument[1];
    
    var end_in_y=20;
    if argument_count>2 end_in_y=argument[2];
    
    var dual_vowel=20;
    if argument_count>3 dual_vowel=argument[3];
    
    var th_sh_chance=50;
    if argument_count>4 th_sh_chance=argument[4];
    
    var ll_chance=25;
    if argument_count>5 ll_chance=argument[5];
    
    var append='';
    
    while string_length(result)<word_length {
     append='';
     append+=string_char_at("bcdfghjklmnpqrstvwxyz",1+irandom(20))
     i+=1;
     if (append="t" or append="s") and 1+random(99)<=th_sh_chance and i<word_length {
      append+="h"
      i+=1;
     }
     if (append="l") and 1+random(99)<=ll_chance and i<word_length {
      append+="l"
      i+=1;
     }
     if i<word_length {
      vowel_1=choose("a","e","i","o","u")
      if i=word_length-1 and (1+random(99)<=end_in_y) { // chance that the word will end with a "y" (when a vowel is called for)
       vowel_1="y";
      }
      append+=vowel_1
      i+=1
     }
     if 1+random(99)<=dual_vowel/*chance for a double vowel.*/ and i<word_length {
      vowel_2=choose("a","e","i","o","u")
      if i=word_length-1 and (1+random(99)<=end_in_y) { // chance that the word will end with a "y" (when a vowel is called for)
       vowel_2="y";
      }
      // while dual vowels are subsequentially reoccoring, reroll the second vowel. with a certain possablity of having this correction not occor.
      while (vowel_1=vowel_2 and 1+random(99)<=reroll_chance/*chance for re-rolling the second vowel (which must be subsequentially reoccoring)*/) {
       vowel_2=choose("a","e","i","o","u")
       if i=word_length-1 and (1+random(99)<=end_in_y) { // chance that the word will end with a "y" (when a vowel is called for)
        vowel_2="y";
       }
      }
      append+=vowel_2;
      i+=1;
     }
     result+=append;
    }
    return result;
}

Last edited by lostdarkwolf (2017-08-11 05:35:04)

Offline

Board footer

Powered by FluxBB