设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 116|回复: 0

[转载发布] Random Name Generator script

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-1 21:42:13 | 显示全部楼层 |阅读模式
    Random Name Generator
    by AMoonlessNight
    12 May 2018

    This script makes it so that actors can have a randomly generated name. You can also set it so that only certain actors have randomly generated names.

    Compatibility:
    Can't see it not working with anything, but let me know.

    Terms of Use:
    Free for commercial and non-commercial games. Please credit me as AMoonlessNight or A-Moonless-Night.

    Script:
    Spoiler: Script
                    Code:       
    1. =begin
    2. #============================================================================
    3. #   AMN Name Generator
    4. #   Version 1.0
    5. #   Author: AMoonlessNight
    6. #   Date: 12 May 2018
    7. #   Latest: 12 May 2018
    8. #===========================================================================#
    9. #   UPDATE LOG
    10. #---------------------------------------------------------------------------#
    11. # 12 May 2018 - created the script
    12. #===========================================================================#
    13. This script makes it so that actors can have a randomly generated name. You
    14. can set it so that only certain actors have randomly generated names, if you
    15. wish, or all of them.
    16. Set up the names in the editable region below.
    17. You can use the notetag   <random name>   in the actor notes
    18.   - If Auto_Names is set to false, this actor WILL be given a random name.
    19.   - If Auto_Names is set to true, this actor WILL NOT be given a random name.
    20. You can use the script call:  random_name(actor_id)
    21. where actor_id is the ID of the actor whose name you want to change.
    22. =end
    23. module AMN_Random_Name_Generator
    24.   Names = [
    25. #==============================================================================
    26. # ** EDITABLE REGION BELOW
    27. #------------------------------------------------------------------------------
    28. #  Change the values in the area below to suit your needs.
    29. #==============================================================================
    30. # Set the random names below. Make sure each one is a string (i.e. enclosed in "")
    31. # followed by a ,
    32. # Names can be anything, so long as they're enclosed in speech marks
    33. # e.g. "N00B 1", "Terry", "100"
    34.   "Hare", "Black", "Ferret", "Kestrel", "Leap", "Stream", "Little", "Prickle",
    35.   "Snail", "Swan", "Spotted", "Ivy", "Crooked", "Pale", "Red", "Clover", "Lion",
    36.   "Tall", "Blizzard", "Running", "Plum", "Ashen", "White", "Ebony", "Nettle",
    37.   "Sand", "Cypress",
    38.   ] # <-- DO NOT REMOVE ]
    39. # If you would like actors to have names generated automatically, set this to
    40. # true
    41.   Auto_Names = true
    42. #==============================================================================
    43. # ** END OF EDITABLE REGION
    44. #------------------------------------------------------------------------------
    45. #  Please do not edit below this point unless you know what you are doing.
    46. #==============================================================================
    47.   AutoNameRegex   = /<random\s+name>/i
    48. end
    49. class RPG::Actor < RPG::BaseItem
    50.   attr_reader :auto_name
    51.   def auto_name?
    52.     return @auto_name unless @auto_name.nil?
    53.     res = self.note.match(AMN_Random_Name_Generator::AutoNameRegex)
    54.     return @auto_name = !res.nil?
    55.   end
    56. end
    57. #==============================================================================
    58. # ** Game_Actor
    59. #------------------------------------------------------------------------------
    60. #  This class handles actors. It is used within the Game_Actors class
    61. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
    62. #==============================================================================
    63. class Game_Actor < Game_Battler
    64.   alias amn_randnamegen_gameactor_init  initialize
    65.   def initialize(actor_id)
    66.     amn_randnamegen_gameactor_init(actor_id)
    67.     if AMN_Random_Name_Generator::Auto_Names
    68.       create_random_name unless $data_actors[@actor_id].auto_name?
    69.     else
    70.       create_random_name if $data_actors[@actor_id].auto_name?
    71.     end
    72.   end
    73.   def create_random_name
    74.     @name = AMN_Random_Name_Generator::Names.sample
    75.   end
    76. end
    77. #==============================================================================
    78. # ** Game_Interpreter
    79. #------------------------------------------------------------------------------
    80. #  An interpreter for executing event commands. This class is used within the
    81. # Game_Map, Game_Troop, and Game_Event classes.
    82. #==============================================================================
    83. class Game_Interpreter
    84.   def random_name(actor_id)
    85.     $game_actors[actor_id].create_random_name
    86.   end
    87. end
    复制代码


    Instructions:
    The script is populated with a number of names (inspired by Warrior Cats, although I haven't read that series yet), but you can change them to whatever you'd like, so long as they're a string/enclosed in speechmarks (e.g. "Dave", "Carla", "Steve",). You can also have as many as you'd like.

    You can put the following in an actor's notetags:
                    Code:       
    1. <random name>
    复制代码

    If you have Auto Names set to true, then this actor WILL NOT be given a random name (and everyone else will).
    If you have Auto Names set to false, then this actor WILL be given a random name (and everyone else won't).

    You can use the following script call:
                    Code:       
    1. random_name(actor_id)
    复制代码

    Change actor_id to the ID of the actor whose name you would like to randomly generate.


    本贴来自国际rpgmaker官方论坛作者:A-Moonless-Night处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/random-name-generator-script.95179/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-18 07:55 , Processed in 0.238531 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表