设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2019|回复: 1
打印 上一主题 下一主题

[已经解决] 求教,Theo的地图显示变量脚本怎么变成横向?(已解决)

[复制链接]

Lv5.捕梦者

梦石
18
星屑
13525
在线时间
1708 小时
注册时间
2017-1-12
帖子
1771

开拓者

跳转到指定楼层
1
发表于 2019-6-3 12:33:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 火锅深处 于 2019-6-4 11:07 编辑

现有脚本的三种模式是左上、右上、右下。变量是纵向排列。
我想变成在左上角距离顶边100像素左右,变量横向一字排开,具体应该改哪部分呢?
  1. # =============================================================================
  2. # TheoAllen - 简单变量HUD
  3. # Version : 1.2b
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_VariableHUD] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2014.03.13 - Fixed hidden glitch when access menu then back to map
  12. # 2014.02.07 - Make sure that variable HUD is always visible
  13. # 2013.08.09 - Add mutiple variable HUD support
  14. # 2013.07.23 - Finished script
  15. # =============================================================================
  16. =begin

  17.   介绍 :
  18.   本脚本可以简单地在地图上显示变量的数值。
  19.   
  20.   使用方法 :
  21.   将本脚本放在插件脚本之下,Main之上
  22.   
  23.   使用脚本:
  24.   show_variable(变量id) >> 显示变量数值
  25.   show_variable(变量id,图标索引) >> 显示变量数值+一个图标
  26.   show_variable(变量id,图标索引,位置) >> 显示变量数值+一个图标+设定显示位置
  27.   
  28.   多重 HUD 的脚本:
  29.   show_variable([变量id,变量id,变量id],[图标索引,图标索引,图标索引],位置)
  30.   
  31.   hide_variable >> 隐藏所有 HUD
  32.   
  33.     使用条款 :
  34.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  35.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.  
  36.   
  37.   Note :
  38.   Karena ini simple, jadi jangan harap ada banyak kustomisasi bebas

  39. =end
  40. # =============================================================================
  41. # 设定
  42. # =============================================================================
  43.   VarHUD_DefaultPos = 1 # Posisi default HUD
  44. # -----------------------------------------------------------------------------
  45. # 1 >> Kiri Atas
  46. # 2 >> Kanan Atas
  47. # 3 >> Kiri Bawah
  48. # 4 >> Kanan Bawah
  49. # -----------------------------------------------------------------------------
  50.   VarHUD_FontSize = 24 # Ukuran Font
  51. # -----------------------------------------------------------------------------
  52.   VarHUD_MaxVar = 4 # Maksimal variable yg dapat ditampilin
  53. # =============================================================================
  54. # 设定结束
  55. # =============================================================================
  56. class Game_Temp
  57.   attr_accessor :refresh_hud
  58.   
  59.   alias theo_varhud_init initialize
  60.   def initialize
  61.     theo_varhud_init
  62.     @refresh_hud = false
  63.   end
  64.   
  65. end

  66. class Game_Variables
  67.   alias theo_varhud_on_change on_change
  68.   def on_change
  69.     theo_varhud_on_change
  70.     $game_temp.refresh_hud = true
  71.   end
  72. end

  73. class Game_System
  74.   class VarHUD
  75.     attr_accessor :position
  76.     attr_accessor :icon
  77.     attr_accessor :id
  78.    
  79.     def initialize
  80.       @position = 0
  81.       @icon = 0
  82.       @id = 0
  83.     end
  84.   end
  85.   attr_accessor :varhud_visible
  86.   attr_accessor :varhud_position
  87.   attr_reader :varhud
  88.   
  89.   alias theo_varhud_init initialize
  90.   def initialize
  91.     theo_varhud_init
  92.     @varhud = Array.new(VarHUD_MaxVar) { VarHUD.new }
  93.   end
  94.   
  95.   def clear_varhud
  96.     @varhud.each do |hud|
  97.       hud.id = 0
  98.     end
  99.   end
  100.   
  101. end

  102. class Game_Interpreter
  103.   
  104.   def show_variable(id = nil,icon = 0,position = VarHUD_DefaultPos)
  105.     $game_system.clear_varhud
  106.     if id.is_a?(Array)
  107.       icon = [icon] unless icon.is_a?(Array)
  108.       id.each_with_index do |i,index|
  109.         return if index-1 > VarHUD_MaxVar
  110.         hud = $game_system.varhud[index]
  111.         hud.id = i
  112.         hud.icon = icon[index]
  113.       end
  114.     elsif id.is_a?(Numeric)
  115.       hud = $game_system.varhud[0]
  116.       hud.icon = icon
  117.       hud.id = id
  118.     end
  119.     $game_system.varhud_position = position
  120.     $game_system.varhud_visible = true
  121.     $game_temp.refresh_hud = true
  122.   end
  123.   
  124.   def hide_variable
  125.     $game_system.varhud_visible = false
  126.   end
  127.   
  128. end

  129. class Window_VarHUD < Window_Base
  130.   
  131.   def initialize
  132.     super(0,0,window_width,window_height)
  133.     contents.font.size = VarHUD_FontSize
  134.     update_hud_position
  135.     update_visibility
  136.     self.opacity = 0
  137.     refresh
  138.   end
  139.   
  140.   def window_width;Graphics.width;end;
  141.   def window_height;fitting_height(VarHUD_MaxVar);end;
  142.   def line_height;VarHUD_FontSize;end;
  143.    
  144.   def update
  145.     super
  146.     update_visibility
  147.     refresh if $game_temp.refresh_hud
  148.   end
  149.   
  150.   def update_visibility
  151.     self.visible = $game_system.varhud_visible
  152.   end
  153.   
  154.   def refresh
  155.     contents.clear
  156.     active_hud.each_with_index do |hud,i|
  157.       update_hud_contents(hud,i)
  158.     end
  159.     update_hud_position
  160.     $game_temp.refresh_hud = false
  161.   end
  162.   
  163.   def update_hud_position
  164.     pos = $game_system.varhud_position
  165.     if pos == 1 || pos == 2
  166.       self.y = 0
  167.     elsif
  168.       self.y = Graphics.height - self.height
  169.       size = active_hud.size - 1
  170.       return if size < 0
  171.       self.y += size * line_height
  172.     end
  173.   end
  174.   
  175.   def update_hud_contents(hud,i)
  176.     var_id = hud.id
  177.     icon = hud.icon.nil? ? 0 : hud.icon
  178.     return if var_id == 0
  179.     rect = Rect.new(0,0,contents.width,line_height)
  180.     rect.y = i * line_height
  181.     case $game_system.varhud_position
  182.     when 1,3
  183.       if icon != 0
  184.         rect.x += 27
  185.         draw_icon(icon,0,icon_y_pos + (i * line_height))
  186.       end
  187.       draw_text(rect,$game_variables[var_id])
  188.     else
  189.       if icon != 0
  190.         rect.x -= 27
  191.         draw_icon(icon,contents.width-24,icon_y_pos + (i * line_height))
  192.       end
  193.       draw_text(rect,$game_variables[var_id],2)
  194.     end
  195.   end
  196.   
  197.   def icon_y_pos
  198.     return 0 if line_height <= 24
  199.     return line_height/2 - 12
  200.   end
  201.   
  202.   def active_hud
  203.     $game_system.varhud.select {|hud| hud.id > 0}
  204.   end
  205.   
  206. end

  207. class Scene_Map < Scene_Base
  208.   
  209.   alias theo_varhud_start start
  210.   def start
  211.     theo_varhud_start
  212.     create_var_hud
  213.   end
  214.   
  215.   def create_var_hud
  216.     @varhud_viewport = Viewport.new
  217.     @varhud_viewport.z = 9999
  218.     @var_hud = Window_VarHUD.new
  219. #~     @var_hud.z -= 100
  220.     @var_hud.viewport = @vahud_viewport
  221.   end
  222.   
  223.   alias theo_varhud_terminate terminate
  224.   def terminate
  225.     theo_varhud_terminate
  226.     @varhud_viewport.dispose
  227.   end
  228.   
  229. end
复制代码

Lv5.捕梦者

梦石
0
星屑
31947
在线时间
5081 小时
注册时间
2012-11-19
帖子
4877

开拓者

2
发表于 2019-6-4 10:08:20 | 只看该作者
呃~, 以前有一个 地图显示变量 的存货,可能比较适合LZ的要求。

RUBY 代码复制
  1. #==============================================================================
  2. # 〓 地图显示变量 〓                              Author:芯☆淡茹水
  3. #==============================================================================
  4. =begin
  5. #==============================================================================
  6.   ◆ 说明 ◆
  7. #==============================================================================
  8. #------------------------------------------------------------------------------
  9. 1,变量的命名
  10.    变量命名格式为 => 变量名^图标序号
  11.    未写 图标序号 的变量,不会显示图标。
  12. #------------------------------------------------------------------------------
  13. 2,游戏中添加变量显示 => 事件-脚本:show_map_val(id, x, y, w, s, c1, c2)
  14.    id :变量ID
  15.    x  :变量窗口显示的X坐标
  16.    y  :变量窗口显示的Y坐标
  17.    w  :变量窗口宽(可省略,省略后为设置的默认值)
  18.    s  :字体大小(可省略,省略后为设置的默认值)
  19.    c1 :变量名文字色号(可省略,省略后为设置的默认值)
  20.    c2 :变量值文字色号(可省略,省略后为设置的默认值)
  21.    
  22.    ※ 如果对应的变量已经在显示中,此条命令无效 ※
  23.    ※ 地图上显示的变量个数无限制,理论上可显示无数个变量 ※
  24. #------------------------------------------------------------------------------
  25. 3,游戏中删除变量显示 => 事件-脚本:delete_map_val(id)
  26.    id :变量ID
  27.    
  28.    ※ 如果对应的变量未在显示中,此条命令无效 ※
  29. #------------------------------------------------------------------------------
  30. 4,移动变量窗口 => 事件-脚本:move_val_window(id, direction, duration, speed)
  31.    id        :变量ID
  32.    direction :移动的方向(2:下;4:左;6:右;8:上)
  33.    duration  :移动时持续的帧数
  34.    speed     :移动时每一帧移动的像素值
  35.    
  36.    ※ 如果对应的变量未在显示中或变量窗口正在移动中,此条命令无效 ※
  37. #------------------------------------------------------------------------------
  38. =end
  39. #==============================================================================
  40. module XdRs_Show_Val_Set
  41. #==============================================================================
  42. # ◆ 设置 ◆
  43. #==============================================================================
  44.   #--------------------------------------------------------------------------
  45.   # 窗口边宽
  46.   Standard_padding = 8
  47.  
  48.   #--------------------------------------------------------------------------
  49.   # 窗口不透明度
  50.   Opacity = 255
  51.  
  52.   #--------------------------------------------------------------------------
  53.   # 默认窗口宽度
  54.   Default_window_width = 180
  55.  
  56.   #--------------------------------------------------------------------------
  57.   # 默认窗口字体大小
  58.   Default_font_size = 20
  59.  
  60.   #--------------------------------------------------------------------------
  61.   # 默认变量名字体颜色号
  62.   Default_val_name_color = 0
  63.  
  64.   #--------------------------------------------------------------------------
  65.   # 默认变量值字体颜色号
  66.   Default_val_num_color = 0
  67.  
  68.   #--------------------------------------------------------------------------
  69.   # 初始显示的变量。
  70.   # 格式:变量ID => [X坐标, Y坐标, 窗口宽, 字体大小, 变量名色号, 变量值色号]
  71.   # 其中 窗口宽, 字体大小, 变量名色号, 变量值色号 可省略, 省略后为默认值。
  72.   Initial_vals = {
  73.     11 => [0, 0],
  74.     12 => [10, 40],
  75.     13 => [20, 80, 240, 18, 3, 2]
  76.   }
  77. end
  78. #==============================================================================
  79. class XdRs_Val_Data
  80.   #--------------------------------------------------------------------------
  81.   attr_reader :id, :x, :y
  82.   attr_reader :font_size
  83.   attr_reader :window_width
  84.   attr_reader :window_height
  85.   attr_reader :name_color
  86.   attr_reader :num_color
  87.   #--------------------------------------------------------------------------
  88.   def initialize(id, x, y, w=nil, s=nil, c1=nil, c2=nil)
  89.     @id = id
  90.     @x = x || 0
  91.     @y = y || 0
  92.     @font_size = s || XdRs_Show_Val_Set::Default_font_size
  93.     @window_width =  w || XdRs_Show_Val_Set::Default_window_width
  94.     @window_height = XdRs_Show_Val_Set::Standard_padding * 2 + [@font_size, 24].max
  95.     @name_color = c1 || XdRs_Show_Val_Set::Default_val_name_color
  96.     @num_color  = c2 || XdRs_Show_Val_Set::Default_val_num_color
  97.     clear_move_data
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   def clear_move_data
  101.     @speed = 0
  102.     @move_direction = 0
  103.     @move_duration = 0
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   def name
  107.     text = $data_system.variables[@id]
  108.     return text.split(/\^/)[0] || ""
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   def icon_index
  112.     text = $data_system.variables[@id]
  113.     return (text.split(/\^/)[1] || "0").to_i
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   def start_move(direction, duration, speed)
  117.     return if is_moving?
  118.     @move_direction = direction
  119.     @move_duration = duration
  120.     @speed = speed
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   def is_moving?
  124.     return false if ![2,4,6,8].include?(@move_direction)
  125.     return @speed > 0 && @move_duration > 0
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   def update_move
  129.     return if @move_duration == 0
  130.     @move_duration -= 1
  131.     is_moving? && apply_move
  132.     @move_duration == 0 && clear_move_data
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   def apply_move
  136.     @x += @move_direction == 6 ? @speed : (@move_direction == 4 ? -@speed : 0)
  137.     @y += @move_direction == 2 ? @speed : (@move_direction == 8 ? -@speed : 0)
  138.   end
  139. end
  140. #==============================================================================
  141. class Game_System
  142.   #--------------------------------------------------------------------------
  143.   attr_accessor :additive_val, :deleted_val
  144.   #--------------------------------------------------------------------------
  145.   alias xr_show_val_initialize initialize
  146.   def initialize
  147.     xr_show_val_initialize
  148.     setup_initial_vals
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   def setup_initial_vals
  152.     @xr_map_vals = []
  153.     vals = XdRs_Show_Val_Set::Initial_vals
  154.     vals.keys.each do |id|
  155.       data = vals[id]
  156.       show_map_val(id,data[0],data[1],data[2],data[3],data[4],data[5])
  157.     end
  158.     @additive_val = nil
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   def map_vals
  162.     return @xr_map_vals.map{|d| d.id }
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   def get_map_val_data(id)
  166.     return @xr_map_vals.find{|d| d.id == id }
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   def has_map_val(id)
  170.     return @xr_map_vals.any?{|d| d.id == id}
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   def show_map_val(id, x, y, w=nil, s=nil, c1=nil, c2=nil)
  174.     return if has_map_val(id) || id == 0
  175.     @xr_map_vals.push(XdRs_Val_Data.new(id,x,y,w,s,c1,c2))
  176.     @additive_val = id
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   def delete_map_val(id)
  180.     return if !has_map_val(id)
  181.     @xr_map_vals.delete(get_map_val_data(id))
  182.     @deleted_val = id
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   def move_map_val_window(id, drc, drt, speed)
  186.     has_map_val(id) && get_map_val_data(id).start_move(drc, drt, speed)
  187.   end
  188. end
  189. #==============================================================================
  190. class Game_Interpreter
  191.   #--------------------------------------------------------------------------
  192.   def show_map_val(id, x, y, w=nil, s=nil, c1=nil, c2=nil)
  193.     $game_system.show_map_val(id, x, y, w, s, c1, c2)
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   def delete_map_val(id)
  197.     $game_system.delete_map_val(id)
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   def move_val_window(id, direction, duration, speed)
  201.     $game_system.move_map_val_window(id, direction, duration, speed)
  202.   end
  203. end
  204. #==============================================================================
  205. class Window_Map_Val < Window_Base
  206.   #--------------------------------------------------------------------------
  207.   def initialize(data)
  208.     @data = data
  209.     super(@data.x, @data.y, @data.window_width, @data.window_height)
  210.     self.opacity = XdRs_Show_Val_Set::Opacity
  211.     self.z = 9999
  212.     refresh
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   def line_height
  216.     return [@data.font_size, 24].max
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   def standard_padding
  220.     return XdRs_Show_Val_Set::Standard_padding
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   def refresh
  224.     contents.clear
  225.     contents.font.size = @data.font_size
  226.     @last_num = $game_variables[@data.id]
  227.     draw_val_name(draw_val_icon(0))
  228.     draw_val_num
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   def draw_val_icon(x)
  232.     return x if @data.icon_index == 0
  233.     y = (line_height - 24) / 2
  234.     draw_icon(@data.icon_index, x, y)
  235.     return x + 28
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   def draw_val_name(x)
  239.     change_color(text_color(@data.name_color))
  240.     tw = text_size(@data.name).width + 4
  241.     y = (line_height - @data.font_size) / 2
  242.     draw_text(x, y, tw, @data.font_size, @data.name)
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   def draw_val_num
  246.     change_color(text_color(@data.num_color))
  247.     y = (line_height - @data.font_size) / 2
  248.     draw_text(0, y, contents_width, @data.font_size, @last_num.to_s, 2)
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   def is_val_changed?
  252.     return @last_num != $game_variables[@data.id]
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   def update
  256.     super
  257.     @data.update_move
  258.     update_state
  259.     update_location
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   def update_state
  263.     is_val_changed? && refresh
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   def update_location
  267.     self.x = @data.x
  268.     self.y = @data.y
  269.   end
  270. end
  271. #==============================================================================
  272. class Scene_Map
  273.   #--------------------------------------------------------------------------
  274.   def create_xr_val_window(id)
  275.     $game_system.additive_val = nil
  276.     window_name = "@xr_val_window#{id}"
  277.     data = $game_system.get_map_val_data(id)
  278.     window = instance_variable_get(window_name)
  279.     return if !!window && !window.disposed? || !data
  280.     instance_variable_set(window_name, Window_Map_Val.new(data))
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   def dispose_xr_val_window(id)
  284.     $game_system.deleted_val = nil
  285.     window_name = "@xr_val_window#{id}"
  286.     return if !instance_variable_get(window_name)
  287.     instance_variable_get(window_name).dispose
  288.     instance_variable_set(window_name, nil)
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   alias xr_map_val_create_all_windows create_all_windows
  292.   def create_all_windows  
  293.     xr_map_val_create_all_windows
  294.     $game_system.map_vals.each{|id| create_xr_val_window(id) }
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   alias xr_map_val_update update
  298.   def update
  299.     xr_map_val_update
  300.     update_xr_map_val
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   def update_xr_map_val
  304.     $game_system.additive_val && create_xr_val_window($game_system.additive_val)
  305.     $game_system.deleted_val  && dispose_xr_val_window($game_system.deleted_val)
  306.   end
  307. end
  308. #==============================================================================


这儿也有个示范用法的范例工程

地图显示变量.rar (1.42 MB, 下载次数: 101)

评分

参与人数 2星屑 +30 +1 收起 理由
VIPArcher + 30 认可答案
火锅深处 + 1 感谢大佬

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-27 19:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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