Jump to content

Name Randomizer


Dean

Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hi there everyone,

I'd like to share a small function which will give you a random name whilst creating a new character.
This will only include the function and a list of names, so you will have to set the event on your own.

Preview:
cc2a7b04b715ef6aff0896a0ed21f18d.gif

The function which will most likely be put in introCreate.py
 

import os
import app
#import the above lines if you don't have them already

def __randomizeName(self):
	dir = os.path.dirname(os.path.abspath("introCreate.py"))
	list = open("%s\\names.list" % dir, "r").read().split("\n")
	rng = app.GetRandom(0, len(list)-1)
	randomName = list[rng]
	self.heroName.SetText("%s" % randomName) ## change variable 'heroName' with your editline's name

Also place the attached file to this thread in the main directory of the client. (i.e: where the launcher is)
names.list contains 150 names, if you ever need more names let me know so I can up the number or you can add more yourself, but do note you need to put each name as a new line so you won't mess up the function.


That's all for now, hope you all have a great day!
Cheers. :D

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Think 1
  • Confused 1
  • Scream 1
  • Good 2
  • Love 22
for brain_cells in xrange(brain):
  if brain_cells == 0:
    print("0x3703c7 Fatal error occurred. Please replace the brain.")
    break
  if brain_cells == "damaged":
    print("0x3703c7 Error occurred. Please repair damaged brain_cells")
    break
  
  print("brain_cells are at 100% capacity.")

 

Link to comment
Share on other sites

10 hours ago, Chyu ^^ said:

I think the biggest question is why would you implement this.

The code is simple, it takes names at random from a list and it's being placed in your character name edit line. Also the whole purpose of it is as pure inspiration whenever a player is in lack for a better name. To decrease the chance of getting a duplicate you can do either of 2 things: expand the list to a larger amount of names or simply place a condition within the code to generate a new name if the first name generated is already taken. (PS. you already have such functions in your game)

I hope that answers most of your questions and if you have any further questions please do let me know.
Have a great day everyone! :D 

  • Love 1
for brain_cells in xrange(brain):
  if brain_cells == 0:
    print("0x3703c7 Fatal error occurred. Please replace the brain.")
    break
  if brain_cells == "damaged":
    print("0x3703c7 Error occurred. Please repair damaged brain_cells")
    break
  
  print("brain_cells are at 100% capacity.")

 

Link to comment
Share on other sites

  • Forum Moderator

http://listofrandomnames.com/index.cfm?textarea

3xE3cab.png

 

I would like to do something like that and can be used very easy for multiple languages too. 'locale/xx/names.list'

  • localeInfo.py

This is the hidden content, please

  • any_file.py
  • self.textLine.SetText(localeInfo.GetRandomName())
Spoiler

import localeInfo
class TextLine(ui.TextLine):
	def __init__(self):
		ui.TextLine.__init__(self)

		self.SetParent(self)
		self.SetPosition(0, 15)
		self.SetFeather()
		self.SetFontName("Tahoma:20")
		self.SetPackedFontColor(0xffcfcc57)

	def __del__(self):
		ui.TextLine.__del__(self)
		
	def __OnToggleButton(self):
		self.SetText(localeInfo.GetRandomName())
  • Output:
Spoiler

0907 04:17:05267 :: Antonina
0907 04:17:05532 :: Magaret
0907 04:17:05731 :: Hayden
0907 04:17:05910 :: Jospeh
0907 04:18:06075 :: Portia
0907 04:18:06239 :: Chanell
0907 04:18:06406 :: Miguelina
0907 04:18:06554 :: Darwin
0907 04:18:06834 :: Armanda
0907 04:18:06982 :: Tamekia
0907 04:18:07115 :: Shera
0907 04:18:07281 :: Santiago
0907 04:18:07445 :: Caryl
0907 04:18:07593 :: Guillermo
0907 04:18:07758 :: Taisha
0907 04:18:07924 :: Jenifer
0907 04:18:08073 :: Diedre
0907 04:18:08237 :: Asha
0907 04:18:08418 :: Leone
0907 04:18:08567 :: Floyd

 

Download 1000 random names:

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 5
  • Good 1
  • Love 5
Link to comment
Share on other sites

  • 3 months later...

@VegaS™ As good as your script might look, I find it more demanding on the game having to load the list of names everytime the game loads localeInfo.py
My piece of code it loads up a rather short list of names which can be maintained on a weekly basis (reason why most servers perform a weekly maintenance) and grab a random name when user requests it by clicking the button.

I could see a point in combining the two methods by making a list which is loaded up when the user is trying to create a character followed by dumping it when the user exits the create interface.

I thank you nevertheless for bringing alternatives to the table which makes us expand our knowledge :D 

for brain_cells in xrange(brain):
  if brain_cells == 0:
    print("0x3703c7 Fatal error occurred. Please replace the brain.")
    break
  if brain_cells == "damaged":
    print("0x3703c7 Error occurred. Please repair damaged brain_cells")
    break
  
  print("brain_cells are at 100% capacity.")

 

Link to comment
Share on other sites

  • 1 year later...

Announcements



×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.