How do i make a player be able to make their own name

how to make a player be able to make own name ?


msg ("What's your name?")
get input {
  player.alias = result
  msg ("<br/>Pleased to meet you, {player.alias}! ")
}

Hope that helps! :D

Anonynn.


here's how to do it in the GUI/Editor (Pixie's 'character creation' guide):

http://docs.textadventures.co.uk/quest/guides/character_creation.html

(if you don't know how to code or how to code with quest yet)


J_J

Jumping off this question, is there a way to do this, but set parameters so that a slur or other specific words can't be used?


(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


see the 'String (Manipulation)' Functions:

http://docs.textadventures.co.uk/quest/functions/#string

http://docs.textadventures.co.uk/quest/functions/string/instr.html
http://docs.textadventures.co.uk/quest/functions/string/instrrev.html

http://docs.textadventures.co.uk/quest/functions/string/mid.html

some examples:

get input {
  if (Instr (result, "fuck") or Instr (result, "cunt") or Instr (result, "shag") or Instr (result, "tits")) {
    msg ("Sorry, those words are not allowed")
  } else {
    player.alias = result
  }
}

.

game.profane_and_obscene_stringlist_attribute = NewStringList ()

list add (game.profane_and_obscene_stringlist_attribute, "fuck")

list add (game.profane_and_obscene_stringlist_attribute, "shit")

list add (game.profane_and_obscene_stringlist_attribute, "arse")

list add (game.profane_and_obscene_stringlist_attribute, "shag")

list add (game.profane_and_obscene_stringlist_attribute, "fag") // but not 'faggot' (see my big pet peeve comment below)

list add (game.profane_and_obscene_stringlist_attribute, "asshole")

list add (game.profane_and_obscene_stringlist_attribute, "ass hole") // I don't think one can legitly have 'hole' following 'ass' in a sentence (ass:donkey hole), lol (but if so, then it'd be wrong to censor/filter it out, as 'ass' again, is a real word, meaning a donkey, and 'hole' doesn't mean one's body's orifix... depends on its context/use, lol) --- I'm digressing on parsing sentences... lol

// whereas 'ass' is an alternative name of/for a donkey animal, so it's NOT a bad word (one of HK's many pet peeves with fkn retarded people not knowing fkn vocabulary, lol), and slang is not actual language, whereas 'ass' is official language, meaning (as another name for) a donkey animal, regardless of it being used to mean one's bottom/butt as slang. Same with 'faggot', which is a LUMP OF COAL/CHARCOAL/POOP/ETC (for burning to make a fire to stay warm or to cook or whatever usage), regardless of it being used as a (usually/presumably derogatory) slang for male homosexuals. Pussy is short for pussycat, aka: a cat, regardless of it being slang for a female's genitilia. Cock is a rooster (and a verb: "you cock your gun or its trigger back", "you cock your neck to the side"), regardless of it being used as slang for male genitilia. And many more such examples... lol. Sorry, going off on a major pet peeve here with fkn retards not knowing fkn english, GROWLES...

list add (game.profane_and_obscene_stringlist_attribute, "tits")

list add (game.profane_and_obscene_stringlist_attribute, "cunt")

// etc... especially with the sexual body parts... so many (nearly infinite) slang words for them... lol


// game.profane_and_obscene_integer_attribute = 0
get input {
  foreach (string_variable, game.profane_and_obscene_stringlist_attribute) {
    if (not Instr (result, string_variable) = 0) {
      game.profane_and_obscene_integer_attribute = game.profane_and_obscene_integer_attribute + 1
    }
  }
  on ready {
    if (game.profane_and_obscene_boolean_attribute = 0) {
      player.alias = result
    } else {
      msg ("Sorry, those words are not allowed")
      game.profane_and_obscene_integer_attribute = 0
    }
  }
}

and etc (and probably more efficient ways of doing it)


and, mrangel/pixie, can probably provide how to do it using the regex stuff, which is probably the best way of doing it...


ETA: Edited to catch whole words only.

This code can be put in a function, with a single parameter, "str" and to return a Boolean, true if a naughty word is detected, false otherwise.

As HK alludes to, there are a lot of words that are offensive in one context and fine in another. Another example is "fag", which is slang for cigarette in the UK. Exactly what words you allow is your decision. You can add any words you like to the list in line two, separated with semi-colons. As HK says, it will be a long list.

It will catch sh1t, @$$ anbd stuff like that too (and is case insensitive).

if (game.censorlist = null) {
  list = Split("ass;asshole;shit;crap", ";")
  game.censorlist = NewStringList()
  foreach (s, list) {
    s = Replace(LCase(s), "i", "(i|1|!)")
    s = Replace(s, "l", "(l|1|!)")
    s = Replace(s, "o", "(o|0)")
    s = Replace(s, "a", "(a|@)")
    s = Replace(s, "s", "(s|\\$)")
    s = "( |^|\\-)" + s + "( |$|\\-)"
    list add (game.censorlist, s)
  }
}
str = LCase(str)
foreach (s, game.censorlist) {
  msg (str + "/" + s)
  if (IsRegexMatch(s, str)) {
    return (true)
  }
}
return (false)

I tested it on these strings, the first and last return false, the rest true:

msg (Censor("Here is a sentence"))
msg (Censor("Here is a shit sentence"))
msg (Censor("Here is a shIt sentence"))
msg (Censor("Here is a sh1t sentence"))
msg (Censor("Here is a $h1t sentence"))
msg (Censor("Here is a $hit sentence"))
msg (Censor("$hit"))
msg (Censor("Here is a cr@p sentence"))
msg (Censor("Here is an ass sentence"))
msg (Censor("Here is an ass"))
msg (Censor("Here is an ass-wipe"))
msg (Censor("Here is an associate"))

J_J

Awesome! Thanks!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums