Advertisement
mjshi

Display Player Username

Jan 3rd, 2017
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.61 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Display Player Username v1.0
  3. #-- Creep out the player by displaying their computer username ingame!
  4. #-- By mjshi
  5. #-------------------------------------------------------------------------------
  6. # **Usage**
  7. #-------------------------------------------------------------------------------
  8. # In an event, create a new Script command (tab 3) and type in
  9. # getUsername
  10. # and type \V[variable id] in a dialogue box to display it.
  11. #
  12. # In conditional branch script evals, you can type
  13. # name
  14. # as a shortcut for comparing stuff instead of typing in $game_variables[id].
  15. #-------------------------------------------------------------------------------
  16. # **More Built-In Functions For Conditional Branches**
  17. # You can give it as many things as you want, but they have to be in quotes!
  18. #-------------------------------------------------------------------------------
  19. # nameStartsWith(*things)
  20. #-- ex nameStartsWith("Admin", "C")
  21. #-- ex nameStartsWith("A", "B", "C", "D")
  22. #-- checks if the player's username starts with "Admin" or "C", such as
  23. #   something like "Administrator" or "Computer" or "Cassie" etc
  24. #-- the second one checks if the name starts with any of the four letters.
  25. #
  26. # nameEndsWith(*things)
  27. #-- same as above but it checks if the name ends with the stuff now.
  28. #
  29. # nameIs(*things)
  30. #-- ignores spaces, checks if the name is exactly equal to a thing.
  31. #-------------------------------------------------------------------------------
  32. # Installation: Put anywhere above Main.
  33. #-------------------------------------------------------------------------------
  34.  
  35. module DisplayPlayerUsername
  36.   #-----------------------------------------------------------------------------
  37.   # **CONFIGURATION**
  38.   #-----------------------------------------------------------------------------
  39.   # Store the username in which variable?
  40.   StoreIn = 1
  41.   #-----------------------------------------------------------------------------
  42. end
  43.  
  44. def getUsername
  45.   $game_variables[DisplayPlayerUsername::StoreIn] = ENV['username']
  46. end
  47.  
  48. def name
  49.   return ENV['username']
  50. end
  51.  
  52. def nameStartsWith(*things)
  53.   n = name.downcase.strip
  54.   things.each do |thing|
  55.     t = thing.downcase
  56.     return true if n.start_with? t
  57.   end
  58.   return false
  59. end
  60.  
  61. def nameEndsWith(*things)
  62.   n = name.downcase.strip
  63.   things.each do |thing|
  64.     t = thing.downcase
  65.     return true if n.end_with? t
  66.   end
  67.   return false
  68. end
  69.  
  70. def nameIs(*things)
  71.   n = name.downcase.strip
  72.   things.each do |thing|
  73.     t = thing.downcase
  74.     return true if n == t
  75.   end
  76.   return false
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement