Project1

标题: 【已解决】如何让多等级名称在文章中显示成中文 [打印本页]

作者: l734273398    时间: 2020-11-13 15:10
标题: 【已解决】如何让多等级名称在文章中显示成中文
本帖最后由 l734273398 于 2020-11-13 17:14 编辑

如题:劳烦大佬们帮帮忙

怎么在对话框中,显示文章,怎么把等级的名称显示出来,而不是代入等级的数字

RUBY 代码复制
  1. LEVEL_LIST = {
  2.   1=>"菜鸡",
  3.   2=>"小菜鸡",
  4.  
  5. }
  6. LEVEL_LIST2 = {
  7.   1=>"勇士",
  8.   2=>"小勇士",
  9.  
  10. }
  11. class Window_Base < Window
  12.   def draw_actor_level(actor, x, y)
  13.     if LEVEL_LIST.has_key?(actor.level) or LEVEL_LIST2.has_key?(actor.level)
  14.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level]) if $game_switches[1]
  15.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST2[actor.level]) if $game_switches[2]
  16.     else
  17.       self.contents.font.color = system_color
  18.       self.contents.draw_text(x, y, 32, 32, "Lv")
  19.       self.contents.font.color = normal_color
  20.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  21.     end
  22.   end
  23. end

作者: soulsaga    时间: 2020-11-13 15:53
大佬怎么又来?
你有什么问题...
作者: enghao_lim    时间: 2020-11-13 16:04
同楼上疑惑……
文章显示说的是对话框?
没记错对话框没有显示等级功能吧。
作者: enghao_lim    时间: 2020-11-13 16:22
  1. class Interpreter
  2.   def levelName(varId, actorId)
  3.     list = {
  4.       1=>"菜鸡",
  5.       2=>"小菜鸡",
  6.     }
  7.     actor = $game_actors[actorId]
  8.     gv = $game_variables[varId]
  9.     if (actor and gv and list[actor.level])
  10.       $game_variables[varId] = list[actor.level]
  11.     else
  12.       $game_variables[varId] = 0
  13.     end
  14.   end
  15. end
复制代码

在显示文章前使用脚本:
  1. levelName(变量号,角色编号)
复制代码

例子:
  1. levelName(5, 1)
复制代码

这样要是1号角色的等级为1的时候5号变量会变成菜鸡,接着在文章显示使用\v[5]就可以把变量显示出。
作者: l734273398    时间: 2020-11-13 16:32
enghao_lim 发表于 2020-11-13 16:22
在显示文章前使用脚本:

例子:

我是用搭配这个的,在不影响开关的前提下,在文章中又能显示出境界的名字

  1. LEVEL_LIST = {
  2.   1=>"菜鸡",
  3.   2=>"小菜鸡",

  4. }
  5. LEVEL_LIST2 = {
  6.   1=>"勇士",
  7.   2=>"小勇士",

  8. }
  9. class Window_Base < Window
  10.   def draw_actor_level(actor, x, y)
  11.     if LEVEL_LIST.has_key?(actor.level) or LEVEL_LIST2.has_key?(actor.level)
  12.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level]) if $game_switches[1]
  13.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST2[actor.level]) if $game_switches[2]
  14.     else
  15.       self.contents.font.color = system_color
  16.       self.contents.draw_text(x, y, 32, 32, "Lv")
  17.       self.contents.font.color = normal_color
  18.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  19.     end
  20.   end
  21. end
复制代码

作者: l734273398    时间: 2020-11-13 17:14
enghao_lim 发表于 2020-11-13 16:22
在显示文章前使用脚本:

例子:

在脚本中加入这行脚本$game_variables[1] = LEVEL_LIST[actor.level]直接在文章中用变量就可以实现了,感谢回复




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1