Project1
标题: 为什么无法换行 [打印本页]
作者: huct08 时间: 2014-2-27 17:14
标题: 为什么无法换行
我在文本里加了 “\n” 但是没有显示换行
难道不是 “\n” ?
作者: Sion 时间: 2014-2-27 17:29
本帖最后由 Sion 于 2014-2-27 17:33 编辑
因为n被当做控制符 \n[x] 被置换为 x号角色的名字- class Window_Base
- def convert_escape_characters(text)
- result = text.to_s.clone
- result.gsub!(/\\/) { "\e" }
- result.gsub!(/\e\e/) { "\\" }
- result.gsub!(/\en/) { "\n" } # 加这个
- result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
- result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
- result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
- result.gsub!(/\eG/i) { Vocab::currency_unit }
- result
- end
- end
复制代码 这样改的话 \n 还是 \n; \N[x] 是置换名字。
作者: huct08 时间: 2014-2-27 18:39
Sion 发表于 2014-2-27 17:29 
因为n被当做控制符 \n[x] 被置换为 x号角色的名字这样改的话 \n 还是 \n; \N[x] 是置换名字。 ...
class Window_Base
alias :iisnow_convert_escape_characters :convert_escape_characters
def convert_escape_characters(text)
result = iisnow_convert_escape_characters(text)
result.gsub!(/\ek/) { "\k" }
result
end
def process_character(c, text, pos)
case c
when "\r"
return
when "\n"
process_new_line(text, pos) if !@auto_n
when "\k"
@auto_n = false
when "\f"
process_new_page(text, pos)
when "\e"
process_escape_character(obtain_escape_code(text), text, pos)
else
process_normal_character(c,text,pos)
end
end
def process_normal_character(c,text,pos)
@auto_n = true
text_width = text_size(c).width
if real_width - pos[:x] > text_width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
else
process_new_line(text,pos)
process_normal_character(c,text,pos)
end
end
def real_width
return self.width - 2 * standard_padding
end
end
class Window_Message
def process_normal_character(c,text,pos)
super
wait_for_one_character
end
end
class Window_Base
alias :iisnow_convert_escape_characters :convert_escape_characters
def convert_escape_characters(text)
result = iisnow_convert_escape_characters(text)
result.gsub!(/\ek/) { "\k" }
result
end
def process_character(c, text, pos)
case c
when "\r"
return
when "\n"
process_new_line(text, pos) if !@auto_n
when "\k"
@auto_n = false
when "\f"
process_new_page(text, pos)
when "\e"
process_escape_character(obtain_escape_code(text), text, pos)
else
process_normal_character(c,text,pos)
end
end
def process_normal_character(c,text,pos)
@auto_n = true
text_width = text_size(c).width
if real_width - pos[:x] > text_width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
else
process_new_line(text,pos)
process_normal_character(c,text,pos)
end
end
def real_width
return self.width - 2 * standard_padding
end
end
class Window_Message
def process_normal_character(c,text,pos)
super
wait_for_one_character
end
end
与这个脚本冲突了,大神帮忙看看{:2_249:}
作者: huct08 时间: 2014-2-27 21:24
Sion 发表于 2014-2-27 17:29 
因为n被当做控制符 \n[x] 被置换为 x号角色的名字这样改的话 \n 还是 \n; \N[x] 是置换名字。 ...
我就是这么放的{:2_271:}
作者: Sion 时间: 2014-2-27 22:15
本帖最后由 Sion 于 2014-2-27 22:19 编辑
huct08 发表于 2014-2-27 21:24 
我就是这么放的
我靠,你这个是自动换行的嘛,你都自动换行了,还要手动换行干毛 - -b
这个脚本读到 \k 会关闭自动换行,你不会不知道巴?
嗯.....它这个写得不对{:2_254:} 我都无语了。
作者: Sion 时间: 2014-2-27 22:22
你用这个吧,直接输入 \k 换行
class Window_Base
def process_character(c, text, pos)
case c
when "\r"
return
when "\n"
process_new_line(text, pos) if !@auto_n
when "\f"
process_new_page(text, pos)
when "\e"
process_escape_character(obtain_escape_code(text), text, pos)
else
process_normal_character(c,text,pos)
end
end
def process_escape_character(code, text, pos)
case code.upcase
when 'C'
change_color(text_color(obtain_escape_param(text)))
when 'I'
process_draw_icon(obtain_escape_param(text), pos)
when '{'
make_font_bigger
when '}'
make_font_smaller
when 'K'
process_new_line(text, pos)
end
end
def process_normal_character(c,text,pos)
@auto_n = true
text_width = text_size(c).width
if real_width - pos[:x] > text_width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
else
process_new_line(text,pos)
process_normal_character(c,text,pos)
end
end
def real_width
return self.width - 2 * standard_padding
end
end
class Window_Message
def process_normal_character(c,text,pos)
super
wait_for_one_character
end
end
class Window_Base
def process_character(c, text, pos)
case c
when "\r"
return
when "\n"
process_new_line(text, pos) if !@auto_n
when "\f"
process_new_page(text, pos)
when "\e"
process_escape_character(obtain_escape_code(text), text, pos)
else
process_normal_character(c,text,pos)
end
end
def process_escape_character(code, text, pos)
case code.upcase
when 'C'
change_color(text_color(obtain_escape_param(text)))
when 'I'
process_draw_icon(obtain_escape_param(text), pos)
when '{'
make_font_bigger
when '}'
make_font_smaller
when 'K'
process_new_line(text, pos)
end
end
def process_normal_character(c,text,pos)
@auto_n = true
text_width = text_size(c).width
if real_width - pos[:x] > text_width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
else
process_new_line(text,pos)
process_normal_character(c,text,pos)
end
end
def real_width
return self.width - 2 * standard_padding
end
end
class Window_Message
def process_normal_character(c,text,pos)
super
wait_for_one_character
end
end
作者: 喵呜喵5 时间: 2014-2-27 22:28
少年不试着换一个自动换行脚本...?
http://rpg.blue/home.php?mod=spa ... o=blog&id=11571
作者: huct08 时间: 2014-2-28 09:42
Sion 发表于 2014-2-27 22:22 
你用这个吧,直接输入 \k 换行
class Window_Base
问题解决 谢谢{:2_249:}
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |