赞 | 1 |
VIP | 0 |
好人卡 | 0 |
积分 | 3 |
经验 | 2020 |
最后登录 | 2022-12-4 |
在线时间 | 110 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 251
- 在线时间
- 110 小时
- 注册时间
- 2017-4-16
- 帖子
- 22
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
做了好久,游戏终于有了进度,结果又在做1个人物时卡住了...明明想用喵呜大佬的地图上显示变量,结果发现好像只能用在地图上...所以,不懂脚本的我又来问了,如何在战斗中显示变量
这个是两个地图显示变量的脚本#============================================================================== # ■ 基础脚本 #------------------------------------------------------------------------------ # 请将基础脚本放在我的所有脚本之上。 # # Tips: 什么是基础脚本? # # 这个基础脚本包含我自己的脚本中经常使用的一些【完全相同】的代码 # 虽然不能保证百分百兼容,但是基础脚本中所有的代码都能与大部分脚本和谐共处 # 相应的,如果基础脚本中的某些代码与其他脚本发生了冲突 # 只能证明,我脚本的【思路】和那个脚本【必定会发生冲突】 # 这种情况下,即使我将脚本改写成一个不需要基础脚本的版本,冲突仍然会发生 # #============================================================================== $m5script ||= {}; $m5script[:ScriptData] ||= {} $m5script[:M5Base] = 20170304 #-------------------------------------------------------------------------- # ● 版本检查 # # M5script.version(ver) 检查脚本版本是否高于指定版本 #-------------------------------------------------------------------------- module M5script def self.version(ver,name="基础",key=:M5Base) version = $m5script[key.to_sym] || $m5script[key.to_s] || fail("需要喵呜喵5#{name}脚本的支持") fail("喵呜喵5#{name}脚本版本过低") if (ver > version) end end #-------------------------------------------------------------------------- # ● 读取备注、匹配文本 # # M5script::M5note.match_text(text, note[, option, &block]) # 匹配文本的基本指令 # # text : 文本内容(String) # note : 需要匹配的文字(String) # option : 匹配文本的设置的哈希表 # :default 缺省值(nil) # :value 待匹配文字是否包含内容(true) # :list 是否返回全部匹配结果的数组(nil) # &block : 成功匹配时执行的回调 # # M5script::M5note.map_note(map, note[, option, &block]) # 读取地图备注 # # M5script::M5note.event_note(map, id, note[, option, &block]) # 读取活动事件页的第一条指令,如果为注释则进行匹配 # #-------------------------------------------------------------------------- module M5script; module M5note; class << self def match_text(text, note, *option, &block) config = option[0].is_a?(Hash) ? [option[0][:default], option[0][:value], option[0][:list]] : option default, value, list = *config value = true if value.nil? return list ? [] : default if text.empty? all_result = [] text.each_line do |line| line.chomp! if value result = /^\s*<\s*#{note}\s+(\S+)\s*>\s*$/ =~ line ? $1 : nil next unless result yield(result) if block_given? return result unless list all_result << result else return true if /^\s*<\s*#{note}\s*>\s*$/ =~ line end end return false unless value list ? all_result : default end def map_note(map, *args) text = load_data(sprintf("Data/Map%03d.rvdata2", map)).note match_text(text, *args) end def event_note(map, id, *args) begin if map == $game_map.map_id then page = $game_map.events[id] else ev = load_data(sprintf("Data/Map%03d.rvdata2", map)).events[id] (page = Game_Event.new(map,ev)).refresh end page.empty? ? raise : ev_list = page.list rescue then return match_text('', *args) end text = '' ev_list.each do |c| c.code == 108 || c.code == 408 || break text += c.parameters[0] + "\n" end match_text(text, *args) end end; end; end #-------------------------------------------------------------------------- # ● 读取物品备注 #-------------------------------------------------------------------------- class RPG::BaseItem def m5note *a,&b; M5script::M5note.match_text(@note,*a,&b); end end #-------------------------------------------------------------------------- # ● 与旧版基础脚本的兼容 #-------------------------------------------------------------------------- class << M5script def match_text *a,&b; M5script::M5note.match_text *a,&b; end def read_map_note *a,&b; M5script::M5note.map_note *a,&b; end def read_event_note *a,&b; M5script::M5note.event_note *a,&b; end end #-------------------------------------------------------------------------- # ● 精灵 Sprite_M5_Base / Sprite_M5 #-------------------------------------------------------------------------- class Sprite_M5_Base < Sprite def dispose dispose_bitmap super end def dispose_bitmap; end end class Sprite_M5 < Sprite_M5_Base; end #-------------------------------------------------------------------------- # ● 显示端口 Viewport_M5 #-------------------------------------------------------------------------- class Viewport_M5 < Viewport; end #-------------------------------------------------------------------------- # ● 精灵组 Spriteset_M5 #-------------------------------------------------------------------------- class Spriteset_M5 def update; end def dispose; end end #-------------------------------------------------------------------------- # ● 自动更新释放精灵以及显示端口 #-------------------------------------------------------------------------- class Scene_Base alias m5_20141113_update_basic update_basic def update_basic m5_20141113_update_basic instance_variables.each do |varname| ivar = instance_variable_get(varname) ivar.update if ivar.is_a?(Sprite_M5) && !ivar.disposed? ivar.update if ivar.is_a?(Spriteset_M5) end end alias m5_20141113_terminate terminate def terminate m5_20141113_terminate instance_variables.each do |varname| ivar = instance_variable_get(varname) ivar.dispose if ivar.is_a?(Sprite_M5_Base) ivar.dispose if ivar.is_a?(Spriteset_M5) ivar.dispose if ivar.is_a?(Viewport_M5) end end end #-------------------------------------------------------------------------- # ● 获取控制符的参数(这个方法会破坏原始数据) # # m5_obtain_escape_param(text) #-------------------------------------------------------------------------- class Window_Base def m5_obtain_escape_param(text) text.slice!(/^\[.*?\]/)[1..-2] rescue "" end end #-------------------------------------------------------------------------- # ● 字体大小调整 # # include M5script::M5_Window_FontSize # # m5_font_width 默认文字宽度 # m5_font_height 默认文字高度 # m5_font_size_change 调整文字大小 #-------------------------------------------------------------------------- module M5script; module M5_Window_FontSize def m5_font_size_change(width = m5_font_width, height = m5_font_height) contents.font.size = 40 contents.font.size -= 1 while text_size("口").width > width if width contents.font.size -= 1 while text_size("口").height > height if height end def m5_font_width; return nil; end def m5_font_height; return nil; end end;end class Window_Base alias m5_20140728_reset_font_settings reset_font_settings def reset_font_settings m5_20140728_reset_font_settings m5_font_size_change if respond_to?(:m5_font_size_change) end alias m5_20140728_create_contents create_contents def create_contents m5_20140728_create_contents m5_font_size_change if respond_to?(:m5_font_size_change) end end #-------------------------------------------------------------------------- # ● M5script::Window_Cal # # 计算一段文字大小时使用的临时窗口 # # cal_all_text_height(text) 计算总高度 # cal_all_text_width(text) 计算最大宽度 # calc_line_width(text) 计算单行宽度 # m5_contents 要描绘目标文字的contents # line_height 设置每行文字的高度 #-------------------------------------------------------------------------- module M5script; class Window_Cal < Window_Base attr_writer :line_height, :m5_contents def initialize super(0, 0, Graphics.width, Graphics.height) self.visible = false @text = "" @line_height = nil @m5_contents = nil end def line_height return @line_height if @line_height super end def initialize_contents if @m5_contents self.contents.dispose self.contents = @m5_contents.clone end end def cal_all_text_height(text) initialize_contents reset_font_settings @text = text.clone all_text_height = 1 convert_escape_characters(@text).each_line do |line| all_text_height += calc_line_height(line, false) end @m5_contents = nil return all_text_height end def cal_all_text_width(text) initialize_contents reset_font_settings @text = text.clone all_text_width = 1 convert_escape_characters(@text).each_line do |line| all_text_width = [all_text_width,calc_line_width(line,false)].max end @m5_contents = nil return all_text_width end def calc_line_width(target, need_refresh = true) initialize_contents if need_refresh reset_font_settings text = target.clone pos = {:x => 0, :y => 0, :new_x => 0, :height => Graphics.height} process_character(text.slice!(0, 1), text, pos) until text.empty? @m5_contents = nil if need_refresh return pos[:x] end def process_new_line(text, pos);end def draw_text(*args);end end; end #-------------------------------------------------------------------------- # ● 自动计算大小和位置并包含背景的信息显示窗口 # # M5script::Window_Var # # cal 计算窗口大小使用的临时窗口,M5script::Window_Cal 的实例 # config 窗口设置的哈希表,使用了以下键值: # :X :X2 :Y :Y2 :Z :BACK :SX :SY #-------------------------------------------------------------------------- module M5script; class Window_Var < Window_Base def initialize(config, cal = nil) get_config(config) @dispose_flag = true unless cal @size_window = cal || M5script::Window_Cal.new super(0,0,0,0) self.arrows_visible = false self.z = @config[:Z] self.openness = 0 create_back_sprite end def get_config(config) @config = config.clone @config[:SX] ||= 0 @config[:SY] ||= 0 @config[:Z] ||= 0 end def create_back_sprite return unless @config[:BACK] self.opacity = 0 bitmap = Cache.system(@config[:BACK]) rescue nil return unless bitmap @background_sprite = Sprite.new @background_sprite.x, @background_sprite.y = @config[:SX], @config[:SY] @background_sprite.z = self.z - 1 @background_sprite.bitmap = bitmap end def update_placement if @config[:X] && @config[:X2] self.width = (@config[:X2] - @config[:X]).abs else @size_window.m5_contents = self.contents self.width = @size_window.cal_all_text_width(@word) self.width += standard_padding * 2 end if @config[:Y] && @config[:Y2] self.height = (@config[:Y2] - @config[:Y]).abs else @size_window.m5_contents = self.contents self.height = @size_window.cal_all_text_height(@word) self.height += standard_padding * 2 end create_contents end def update_position if @config[:X] then self.x = @config[:X] elsif @config[:X2] then self.x = @config[:X2] - self.width else self.x = 0 end if @config[:Y] then self.y = @config[:Y] elsif @config[:Y2] then self.y = @config[:Y2] - self.height else self.y = 0 end end def dispose super @size_window.dispose if @dispose_flag @background_sprite.dispose if @background_sprite end end; end #-------------------------------------------------------------------------- # ● 生成TXT # # M5script.creat_text(name,word,type) #-------------------------------------------------------------------------- module M5script def self.creat_text(name,word,type = 'w') content = File.open("#{name}",type) content.puts word content.close end end #-------------------------------------------------------------------------- # ● 打开地址 # # M5script.open_url(addr) #-------------------------------------------------------------------------- module M5script def self.open_url(addr) api = Win32API.new('shell32.dll','ShellExecuteA','pppppi','i') api.call(0,'open',addr,0, 0, 1) end end #-------------------------------------------------------------------------- # ● 读取、写入Game.ini # # M5script::M5ini.get(key, default_value[, section]) # M5script::M5ini.write(key, value[, section]) #-------------------------------------------------------------------------- module M5script; module M5ini; class << self def filename; './Game.ini'; end def default_section; 'M5script'; end def get(key, default_value, section = default_section) buffer = [].pack('x256') api = Win32API.new('kernel32','GetPrivateProfileString','ppppip', 'i') l = api.call(section, key, default_value, buffer, buffer.size, filename) return buffer[0, l] end def write(key, value, section = default_section) api = Win32API.new('kernel32','WritePrivateProfileString','pppp', 'i') api.call(section, key, value.to_s, filename) end end; end; end
#==============================================================================
# ■ 基础脚本
#------------------------------------------------------------------------------
# 请将基础脚本放在我的所有脚本之上。
#
# Tips: 什么是基础脚本?
#
# 这个基础脚本包含我自己的脚本中经常使用的一些【完全相同】的代码
# 虽然不能保证百分百兼容,但是基础脚本中所有的代码都能与大部分脚本和谐共处
# 相应的,如果基础脚本中的某些代码与其他脚本发生了冲突
# 只能证明,我脚本的【思路】和那个脚本【必定会发生冲突】
# 这种情况下,即使我将脚本改写成一个不需要基础脚本的版本,冲突仍然会发生
#
#==============================================================================
$m5script ||= {}; $m5script[:ScriptData] ||= {}
$m5script[:M5Base] = 20170304
#--------------------------------------------------------------------------
# ● 版本检查
#
# M5script.version(ver) 检查脚本版本是否高于指定版本
#--------------------------------------------------------------------------
module M5script
def self.version(ver,name="基础",key=:M5Base)
version = $m5script[key.to_sym] || $m5script[key.to_s] ||
fail("需要喵呜喵5#{name}脚本的支持")
fail("喵呜喵5#{name}脚本版本过低") if (ver > version)
end
end
#--------------------------------------------------------------------------
# ● 读取备注、匹配文本
#
# M5script::M5note.match_text(text, note[, option, &block])
# 匹配文本的基本指令
#
# text : 文本内容(String)
# note : 需要匹配的文字(String)
# option : 匹配文本的设置的哈希表
# :default 缺省值(nil)
# :value 待匹配文字是否包含内容(true)
# :list 是否返回全部匹配结果的数组(nil)
# &block : 成功匹配时执行的回调
#
# M5script::M5note.map_note(map, note[, option, &block])
# 读取地图备注
#
# M5script::M5note.event_note(map, id, note[, option, &block])
# 读取活动事件页的第一条指令,如果为注释则进行匹配
#
#--------------------------------------------------------------------------
module M5script; module M5note; class << self
def match_text(text, note, *option, &block)
config = option[0].is_a?(Hash) ?
[option[0][:default], option[0][:value], option[0][:list]] : option
default, value, list = *config
value = true if value.nil?
return list ? [] : default if text.empty?
all_result = []
text.each_line do |line|
line.chomp!
if value
result = /^\s*<\s*#{note}\s+(\S+)\s*>\s*$/ =~ line ? $1 : nil
next unless result
yield(result) if block_given?
return result unless list
all_result << result
else
return true if /^\s*<\s*#{note}\s*>\s*$/ =~ line
end
end
return false unless value
list ? all_result : default
end
def map_note(map, *args)
text = load_data(sprintf("Data/Map%03d.rvdata2", map)).note
match_text(text, *args)
end
def event_note(map, id, *args)
begin
if map == $game_map.map_id then page = $game_map.events[id]
else
ev = load_data(sprintf("Data/Map%03d.rvdata2", map)).events[id]
(page = Game_Event.new(map,ev)).refresh
end
page.empty? ? raise : ev_list = page.list
rescue then return match_text('', *args)
end
text = ''
ev_list.each do |c|
c.code == 108 || c.code == 408 || break
text += c.parameters[0] + "\n"
end
match_text(text, *args)
end
end; end; end
#--------------------------------------------------------------------------
# ● 读取物品备注
#--------------------------------------------------------------------------
class RPG::BaseItem
def m5note *a,&b; M5script::M5note.match_text(@note,*a,&b); end
end
#--------------------------------------------------------------------------
# ● 与旧版基础脚本的兼容
#--------------------------------------------------------------------------
class << M5script
def match_text *a,&b; M5script::M5note.match_text *a,&b; end
def read_map_note *a,&b; M5script::M5note.map_note *a,&b; end
def read_event_note *a,&b; M5script::M5note.event_note *a,&b; end
end
#--------------------------------------------------------------------------
# ● 精灵 Sprite_M5_Base / Sprite_M5
#--------------------------------------------------------------------------
class Sprite_M5_Base < Sprite
def dispose
dispose_bitmap
super
end
def dispose_bitmap; end
end
class Sprite_M5 < Sprite_M5_Base; end
#--------------------------------------------------------------------------
# ● 显示端口 Viewport_M5
#--------------------------------------------------------------------------
class Viewport_M5 < Viewport; end
#--------------------------------------------------------------------------
# ● 精灵组 Spriteset_M5
#--------------------------------------------------------------------------
class Spriteset_M5
def update; end
def dispose; end
end
#--------------------------------------------------------------------------
# ● 自动更新释放精灵以及显示端口
#--------------------------------------------------------------------------
class Scene_Base
alias m5_20141113_update_basic update_basic
def update_basic
m5_20141113_update_basic
instance_variables.each do |varname|
ivar = instance_variable_get(varname)
ivar.update if ivar.is_a?(Sprite_M5) && !ivar.disposed?
ivar.update if ivar.is_a?(Spriteset_M5)
end
end
alias m5_20141113_terminate terminate
def terminate
m5_20141113_terminate
instance_variables.each do |varname|
ivar = instance_variable_get(varname)
ivar.dispose if ivar.is_a?(Sprite_M5_Base)
ivar.dispose if ivar.is_a?(Spriteset_M5)
ivar.dispose if ivar.is_a?(Viewport_M5)
end
end
end
#--------------------------------------------------------------------------
# ● 获取控制符的参数(这个方法会破坏原始数据)
#
# m5_obtain_escape_param(text)
#--------------------------------------------------------------------------
class Window_Base
def m5_obtain_escape_param(text)
text.slice!(/^\[.*?\]/)[1..-2] rescue ""
end
end
#--------------------------------------------------------------------------
# ● 字体大小调整
#
# include M5script::M5_Window_FontSize
#
# m5_font_width 默认文字宽度
# m5_font_height 默认文字高度
# m5_font_size_change 调整文字大小
#--------------------------------------------------------------------------
module M5script; module M5_Window_FontSize
def m5_font_size_change(width = m5_font_width, height = m5_font_height)
contents.font.size = 40
contents.font.size -= 1 while text_size("口").width > width if width
contents.font.size -= 1 while text_size("口").height > height if height
end
def m5_font_width; return nil; end
def m5_font_height; return nil; end
end;end
class Window_Base
alias m5_20140728_reset_font_settings reset_font_settings
def reset_font_settings
m5_20140728_reset_font_settings
m5_font_size_change if respond_to?(:m5_font_size_change)
end
alias m5_20140728_create_contents create_contents
def create_contents
m5_20140728_create_contents
m5_font_size_change if respond_to?(:m5_font_size_change)
end
end
#--------------------------------------------------------------------------
# ● M5script::Window_Cal
#
# 计算一段文字大小时使用的临时窗口
#
# cal_all_text_height(text) 计算总高度
# cal_all_text_width(text) 计算最大宽度
# calc_line_width(text) 计算单行宽度
# m5_contents 要描绘目标文字的contents
# line_height 设置每行文字的高度
#--------------------------------------------------------------------------
module M5script; class Window_Cal < Window_Base
attr_writer :line_height, :m5_contents
def initialize
super(0, 0, Graphics.width, Graphics.height)
self.visible = false
@text = ""
@line_height = nil
@m5_contents = nil
end
def line_height
return @line_height if @line_height
super
end
def initialize_contents
if @m5_contents
self.contents.dispose
self.contents = @m5_contents.clone
end
end
def cal_all_text_height(text)
initialize_contents
reset_font_settings
@text = text.clone
all_text_height = 1
convert_escape_characters(@text).each_line do |line|
all_text_height += calc_line_height(line, false)
end
@m5_contents = nil
return all_text_height
end
def cal_all_text_width(text)
initialize_contents
reset_font_settings
@text = text.clone
all_text_width = 1
convert_escape_characters(@text).each_line do |line|
all_text_width = [all_text_width,calc_line_width(line,false)].max
end
@m5_contents = nil
return all_text_width
end
def calc_line_width(target, need_refresh = true)
initialize_contents if need_refresh
reset_font_settings
text = target.clone
pos = {:x => 0, :y => 0, :new_x => 0, :height => Graphics.height}
process_character(text.slice!(0, 1), text, pos) until text.empty?
@m5_contents = nil if need_refresh
return pos[:x]
end
def process_new_line(text, pos);end
def draw_text(*args);end
end; end
#--------------------------------------------------------------------------
# ● 自动计算大小和位置并包含背景的信息显示窗口
#
# M5script::Window_Var
#
# cal 计算窗口大小使用的临时窗口,M5script::Window_Cal 的实例
# config 窗口设置的哈希表,使用了以下键值:
# :X :X2 :Y :Y2 :Z :BACK :SX :SY
#--------------------------------------------------------------------------
module M5script; class Window_Var < Window_Base
def initialize(config, cal = nil)
get_config(config)
@dispose_flag = true unless cal
@size_window = cal || M5script::Window_Cal.new
super(0,0,0,0)
self.arrows_visible = false
self.z = @config[:Z]
self.openness = 0
create_back_sprite
end
def get_config(config)
@config = config.clone
@config[:SX] ||= 0
@config[:SY] ||= 0
@config[:Z] ||= 0
end
def create_back_sprite
return unless @config[:BACK]
self.opacity = 0
bitmap = Cache.system(@config[:BACK]) rescue nil
return unless bitmap
@background_sprite = Sprite.new
@background_sprite.x, @background_sprite.y = @config[:SX], @config[:SY]
@background_sprite.z = self.z - 1
@background_sprite.bitmap = bitmap
end
def update_placement
if @config[:X] && @config[:X2]
self.width = (@config[:X2] - @config[:X]).abs
else
@size_window.m5_contents = self.contents
self.width = @size_window.cal_all_text_width(@word)
self.width += standard_padding * 2
end
if @config[:Y] && @config[:Y2]
self.height = (@config[:Y2] - @config[:Y]).abs
else
@size_window.m5_contents = self.contents
self.height = @size_window.cal_all_text_height(@word)
self.height += standard_padding * 2
end
create_contents
end
def update_position
if @config[:X] then self.x = @config[:X]
elsif @config[:X2] then self.x = @config[:X2] - self.width
else self.x = 0
end
if @config[:Y] then self.y = @config[:Y]
elsif @config[:Y2] then self.y = @config[:Y2] - self.height
else self.y = 0
end
end
def dispose
super
@size_window.dispose if @dispose_flag
@background_sprite.dispose if @background_sprite
end
end; end
#--------------------------------------------------------------------------
# ● 生成TXT
#
# M5script.creat_text(name,word,type)
#--------------------------------------------------------------------------
module M5script
def self.creat_text(name,word,type = 'w')
content = File.open("#{name}",type)
content.puts word
content.close
end
end
#--------------------------------------------------------------------------
# ● 打开地址
#
# M5script.open_url(addr)
#--------------------------------------------------------------------------
module M5script
def self.open_url(addr)
api = Win32API.new('shell32.dll','ShellExecuteA','pppppi','i')
api.call(0,'open',addr,0, 0, 1)
end
end
#--------------------------------------------------------------------------
# ● 读取、写入Game.ini
#
# M5script::M5ini.get(key, default_value[, section])
# M5script::M5ini.write(key, value[, section])
#--------------------------------------------------------------------------
module M5script; module M5ini; class << self
def filename; './Game.ini'; end
def default_section; 'M5script'; end
def get(key, default_value, section = default_section)
buffer = [].pack('x256')
api = Win32API.new('kernel32','GetPrivateProfileString','ppppip', 'i')
l = api.call(section, key, default_value, buffer, buffer.size, filename)
return buffer[0, l]
end
def write(key, value, section = default_section)
api = Win32API.new('kernel32','WritePrivateProfileString','pppp', 'i')
api.call(section, key, value.to_s, filename)
end
end; end; end
=begin =============================================================================== 地图显示变量 By 喵呜喵5 =============================================================================== 【说明】 在地图上显示变量,支持许多的自定义操作 =end $m5script ||= {};raise("需要喵呜喵5基础脚本的支持") unless $m5script[:M5Base] $m5script[:M5Var20140815] = 20160307;M5script.version(20150706) module M5Var20140815;VAR_CONFIG =[ =begin #============================================================================== # 设定部分 #============================================================================== 下面的每一对大括号对应地图上的一个窗口,中间的内容就是窗口的属性 具体的格式请参考下面给出的范例(※注意每大括号最后的逗号) 添加内容的格式为: 需要设置的属性: 属性的值 , (※ 冒号和属性的值之间请加上空格,不要忘记每条设置最后的逗号) 可以设置的属性如下: VAR 要显示的变量的ID X 窗口左上角的X坐标 Y 窗口左上角的Y坐标 X2 窗口右下角的X坐标 Y2 窗口右下角的Y坐标 Z 窗口的Z高度,可以为负数 高度比较大的窗口将遮住高度比较低的窗口 HINT1 在变量的数值前面显示的提示文字(前后要加英文引号) HINT2 在变量的数值后面显示的提示文字(前后要加英文引号) POSX 窗口文字的起始X坐标 POSY 窗口文字的起始Y坐标 BACK 窗口的背景图片,文件放在Graphics/System/下(前后要加英文引号) 文件不存在时,窗口背景透明 SX 背景图片的X坐标 SY 背景图片的Y坐标 SWI 窗口的开关ID,当对应ID的开关打开时不显示这个窗口 INV_SWI 窗口的开关ID,当对应ID的开关【关闭】时不显示这个窗口 EVAL 窗口显示的内容变为代码的返回值,VAR属性将被忽略(需要双引号) 如果不懂意思的话请不要设置这个属性 SCENE 窗口只在特定的 Scene 才显示,如果不懂意思的话请不要设置这个属性 =end { VAR: 1, X: 0, X2: 544, Y2: 416, HINT1: "\\i[10]1号变量的值是", HINT2: "的说(打开2号开关试试?)", SWI: 2, POSX: 50, }, { VAR: 2, X2: 544, HINT1: "2号变量的\n值是:", BACK: "", }, { X: 0, HINT1: "这个是不显示变量数值的窗口\n", HINT2: "仅当2号开关打开时才显示", INV_SWI: 2, }, { EVAL: "$game_player.x", HINT1: "玩家的地图X坐标为:", SCENE: Scene_Menu, }, ] # 请不要删除这行 Z = 200 # 如果窗口遮住其他不希望遮住的内容了,请调小这个数值 SWI = 1 # 对应ID的开关打开时,关闭本脚本的功能,不在地图上显示变量, # 这个全局开关优先于各个窗口单独设置的开关 # 我的其他需要本脚本支持的脚本也会受到这个开关的影响而失效 # 如果不需要这个开关的话,这里请填 nil # 对应ID的开关【关闭】时,关闭本脚本的功能,不在地图上显示变量, # 这个全局开关优先于各个窗口单独设置的开关以及上面设置的开关 # 我的其他需要本脚本支持的脚本也会受到这个开关的影响而失效 # 如果不需要这个开关的话,这里请填 nil #============================================================================== # 设定结束 #============================================================================== class Window_Var < M5script::Window_Var #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def initialize(config,cal) super(config,cal) update refresh if @config[:ONLY] end #-------------------------------------------------------------------------- # ● 获取窗口的设置 #-------------------------------------------------------------------------- def get_config(config) super(config) @config[:Z] += Z @config[:HINT1] ||= "" @config[:HINT2] ||= "" @config[:POSX] ||= 0 @config[:POSY] ||= 0 return if @config[:EVAL] @config[:EVAL] = "$game_variables[#{@config[:VAR]}]" end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update super return if update_close_judge @background_sprite.opacity = 255 if @background_sprite and \ @background_sprite.opacity != 255 open if close? update_content unless @config[:ONLY] end #-------------------------------------------------------------------------- # ● 更新窗口的关闭判断 #-------------------------------------------------------------------------- def update_close_judge if close_judge @background_sprite.opacity = 0 if @background_sprite and \ @background_sprite.opacity != 0 close if open? return true end false end #-------------------------------------------------------------------------- # ● 窗口是否应该关闭? (true:关闭) #-------------------------------------------------------------------------- def close_judge return true if INV_SWI && !$game_switches[INV_SWI] return true if SWI && $game_switches[SWI] return true if @config[:INV_SWI] && !$game_switches[@config[:INV_SWI]] return true if @config[:SWI] && $game_switches[@config[:SWI]] false end #-------------------------------------------------------------------------- # ● 更新窗口内容 #-------------------------------------------------------------------------- def update_content cont = @cont begin @cont = eval(@config[:EVAL]).to_s rescue p "窗口:#{@config}","错误:#{$!.to_s}","追踪:#{$!.backtrace}" msgbox('地图显示变量脚本的某个窗口发生错误,错误信息已输出到控制台') exit end refresh unless cont == @cont end #-------------------------------------------------------------------------- # ● 描绘文字 #-------------------------------------------------------------------------- def refresh if @config[:ONLY] then @word = "#{@config[:HINT1]}#{@config[:HINT2]}" else @word = "#{@config[:HINT1]}#{@cont}#{@config[:HINT2]}" end update_placement update_position draw_text_ex(@config[:POSX], @config[:POSY], @word) end end end # M5Var20140815 #-------------------------------------------------------------------------- # ● Scene_Base #-------------------------------------------------------------------------- class Scene_Base #-------------------------------------------------------------------------- # ● 生成窗口 #-------------------------------------------------------------------------- alias m5_20131103_start start def start m5_20131103_start @m5_20140815_cal_size_window = M5script::Window_Cal.new @m5_20140815_var_windows = [] (M5Var20140815::VAR_CONFIG + self.class.m5_20150517_window).each do |config| next unless config next unless self.class == (config[:SCENE] ? config[:SCENE] : Scene_Map) if !(config[:VAR] || config[:EVAL]) next unless (config[:HINT1] || config[:HINT2]) config[:ONLY] = true end @m5_20140815_var_windows.push( M5Var20140815::Window_Var.new(config,@m5_20140815_cal_size_window) ) end @m5_20140815_var_windows.compact! end #-------------------------------------------------------------------------- # ● 更新窗口 #-------------------------------------------------------------------------- alias m5_20131103_update update def update m5_20131103_update return if scene_changing? return unless @m5_20140815_var_windows @m5_20140815_var_windows.each {|window| window.update if window} end #-------------------------------------------------------------------------- # ● 释放窗口 #-------------------------------------------------------------------------- alias m5_20131103_terminate terminate def terminate m5_20131103_terminate return unless @m5_20140815_var_windows @m5_20140815_var_windows.each {|window| window.dispose if window} end #-------------------------------------------------------------------------- # ● 为其他脚本提供的接口 #-------------------------------------------------------------------------- def self.m5_20150517_window(config = nil) @m5_20150517_add_window ||= [] return @m5_20150517_add_window unless config hash = { EVAL: "#{config}.text", SCENE: self } [:X, :Y, :X2, :Y2, :Z, :BACK, :SX, :SY, :POSX, :POSY, :SWI, :INV_SWI].each do |key| hash[key] = config.const_get(key) rescue nil end @m5_20150517_add_window.push hash end end
=begin
===============================================================================
地图显示变量 By 喵呜喵5
===============================================================================
【说明】
在地图上显示变量,支持许多的自定义操作
=end
$m5script ||= {};raise("需要喵呜喵5基础脚本的支持") unless $m5script[:M5Base]
$m5script[:M5Var20140815] = 20160307;M5script.version(20150706)
module M5Var20140815;VAR_CONFIG =[
=begin
#==============================================================================
# 设定部分
#==============================================================================
下面的每一对大括号对应地图上的一个窗口,中间的内容就是窗口的属性
具体的格式请参考下面给出的范例(※注意每大括号最后的逗号)
添加内容的格式为:
需要设置的属性: 属性的值 ,
(※ 冒号和属性的值之间请加上空格,不要忘记每条设置最后的逗号)
可以设置的属性如下:
VAR 要显示的变量的ID
X 窗口左上角的X坐标
Y 窗口左上角的Y坐标
X2 窗口右下角的X坐标
Y2 窗口右下角的Y坐标
Z 窗口的Z高度,可以为负数
高度比较大的窗口将遮住高度比较低的窗口
HINT1 在变量的数值前面显示的提示文字(前后要加英文引号)
HINT2 在变量的数值后面显示的提示文字(前后要加英文引号)
POSX 窗口文字的起始X坐标
POSY 窗口文字的起始Y坐标
BACK 窗口的背景图片,文件放在Graphics/System/下(前后要加英文引号)
文件不存在时,窗口背景透明
SX 背景图片的X坐标
SY 背景图片的Y坐标
SWI 窗口的开关ID,当对应ID的开关打开时不显示这个窗口
INV_SWI 窗口的开关ID,当对应ID的开关【关闭】时不显示这个窗口
EVAL 窗口显示的内容变为代码的返回值,VAR属性将被忽略(需要双引号)
如果不懂意思的话请不要设置这个属性
SCENE 窗口只在特定的 Scene 才显示,如果不懂意思的话请不要设置这个属性
=end
{
VAR: 1,
X: 0,
X2: 544,
Y2: 416,
HINT1: "\\i[10]1号变量的值是",
HINT2: "的说(打开2号开关试试?)",
SWI: 2,
POSX: 50,
},
{
VAR: 2,
X2: 544,
HINT1: "2号变量的\n值是:",
BACK: "",
},
{
X: 0,
HINT1: "这个是不显示变量数值的窗口\n",
HINT2: "仅当2号开关打开时才显示",
INV_SWI: 2,
},
{
EVAL: "$game_player.x",
HINT1: "玩家的地图X坐标为:",
SCENE: Scene_Menu,
},
] # 请不要删除这行
Z = 200 # 如果窗口遮住其他不希望遮住的内容了,请调小这个数值
SWI = 1 # 对应ID的开关打开时,关闭本脚本的功能,不在地图上显示变量,
# 这个全局开关优先于各个窗口单独设置的开关
# 我的其他需要本脚本支持的脚本也会受到这个开关的影响而失效
# 如果不需要这个开关的话,这里请填 nil
# 对应ID的开关【关闭】时,关闭本脚本的功能,不在地图上显示变量,
# 这个全局开关优先于各个窗口单独设置的开关以及上面设置的开关
# 我的其他需要本脚本支持的脚本也会受到这个开关的影响而失效
# 如果不需要这个开关的话,这里请填 nil
#==============================================================================
# 设定结束
#==============================================================================
class Window_Var < M5script::Window_Var
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def initialize(config,cal)
super(config,cal)
update
refresh if @config[:ONLY]
end
#--------------------------------------------------------------------------
# ● 获取窗口的设置
#--------------------------------------------------------------------------
def get_config(config)
super(config)
@config[:Z] += Z
@config[:HINT1] ||= ""
@config[:HINT2] ||= ""
@config[:POSX] ||= 0
@config[:POSY] ||= 0
return if @config[:EVAL]
@config[:EVAL] = "$game_variables[#{@config[:VAR]}]"
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
return if update_close_judge
@background_sprite.opacity = 255 if @background_sprite and \
@background_sprite.opacity != 255
open if close?
update_content unless @config[:ONLY]
end
#--------------------------------------------------------------------------
# ● 更新窗口的关闭判断
#--------------------------------------------------------------------------
def update_close_judge
if close_judge
@background_sprite.opacity = 0 if @background_sprite and \
@background_sprite.opacity != 0
close if open?
return true
end
false
end
#--------------------------------------------------------------------------
# ● 窗口是否应该关闭? (true:关闭)
#--------------------------------------------------------------------------
def close_judge
return true if INV_SWI && !$game_switches[INV_SWI]
return true if SWI && $game_switches[SWI]
return true if @config[:INV_SWI] && !$game_switches[@config[:INV_SWI]]
return true if @config[:SWI] && $game_switches[@config[:SWI]]
false
end
#--------------------------------------------------------------------------
# ● 更新窗口内容
#--------------------------------------------------------------------------
def update_content
cont = @cont
begin
@cont = eval(@config[:EVAL]).to_s
rescue
p "窗口:#{@config}","错误:#{$!.to_s}","追踪:#{$!.backtrace}"
msgbox('地图显示变量脚本的某个窗口发生错误,错误信息已输出到控制台')
exit
end
refresh unless cont == @cont
end
#--------------------------------------------------------------------------
# ● 描绘文字
#--------------------------------------------------------------------------
def refresh
if @config[:ONLY] then @word = "#{@config[:HINT1]}#{@config[:HINT2]}"
else @word = "#{@config[:HINT1]}#{@cont}#{@config[:HINT2]}"
end
update_placement
update_position
draw_text_ex(@config[:POSX], @config[:POSY], @word)
end
end
end # M5Var20140815
#--------------------------------------------------------------------------
# ● Scene_Base
#--------------------------------------------------------------------------
class Scene_Base
#--------------------------------------------------------------------------
# ● 生成窗口
#--------------------------------------------------------------------------
alias m5_20131103_start start
def start
m5_20131103_start
@m5_20140815_cal_size_window = M5script::Window_Cal.new
@m5_20140815_var_windows = []
(M5Var20140815::VAR_CONFIG + self.class.m5_20150517_window).each do |config|
next unless config
next unless self.class == (config[:SCENE] ? config[:SCENE] : Scene_Map)
if !(config[:VAR] || config[:EVAL])
next unless (config[:HINT1] || config[:HINT2])
config[:ONLY] = true
end
@m5_20140815_var_windows.push(
M5Var20140815::Window_Var.new(config,@m5_20140815_cal_size_window) )
end
@m5_20140815_var_windows.compact!
end
#--------------------------------------------------------------------------
# ● 更新窗口
#--------------------------------------------------------------------------
alias m5_20131103_update update
def update
m5_20131103_update
return if scene_changing?
return unless @m5_20140815_var_windows
@m5_20140815_var_windows.each {|window| window.update if window}
end
#--------------------------------------------------------------------------
# ● 释放窗口
#--------------------------------------------------------------------------
alias m5_20131103_terminate terminate
def terminate
m5_20131103_terminate
return unless @m5_20140815_var_windows
@m5_20140815_var_windows.each {|window| window.dispose if window}
end
#--------------------------------------------------------------------------
# ● 为其他脚本提供的接口
#--------------------------------------------------------------------------
def self.m5_20150517_window(config = nil)
@m5_20150517_add_window ||= []
return @m5_20150517_add_window unless config
hash = { EVAL: "#{config}.text", SCENE: self }
[:X, :Y, :X2, :Y2, :Z, :BACK, :SX, :SY, :POSX, :POSY, :SWI,
:INV_SWI].each do |key|
hash[key] = config.const_get(key) rescue nil
end
@m5_20150517_add_window.push hash
end
end
|
|