Project1
标题:
我可耻地忘了怎么呼出这个脚本了
[打印本页]
作者:
№独孤剑→
时间:
2012-8-13 21:51
标题:
我可耻地忘了怎么呼出这个脚本了
本帖最后由 hcm 于 2012-8-22 09:05 编辑
一共是三个脚本,是图书馆系统,能选音乐,选书阅读的那个。
第一个
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
class Window_Reader < Window_Base
attr_accessor :text
def initialize(text, line)
@text = text
@line = line
super(50, 15, 540, 450)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 20
refresh
end
def refresh
self.contents.clear
self.contents.font.size = 20
self.contents.font.color = normal_color
j = 0
for i in @line..[@text.size - 1, @line + 14].min
self.contents.draw_text(0, 28 * j, 540 - 32, 28, @text[i])
j += 1
end
self.contents.font.size = 12
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(0, 408, 540 - 32, 12, @line.to_s + "/" + (@text.size-1).to_s , 2)
end
def add_1
@line += 1
@line = [@text.size - 1, @line].min
refresh
end
def minus_1
@line -= 1
@line = [0, @line].max
refresh
end
def page_add
@line += 15
@line = [@text.size - 1, @line].min
refresh
end
def page_back
@line -= 15
@line = [0, @line].max
refresh
end
def renew(text, line)
@text = text
@line = line
refresh
end
end
class Window_Command < Window_Selectable
attr_reader :commands
end
——————————————————
第二个
-----------------------------------------------
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ Scene_Read
#==============================================================================
class Scene_Read_NM
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
sp = Spriteset_Map.new
@read_window = Window_Reader.new([""], 0)
@read_window.opacity = 230
@read_window.z = 900
text = Dir["Graphics/txt/*"]
@text = []
for tx in text
@text.push (tx.split(/txt\//)[1].split(/.txt/)[0])
end
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 1
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@command_window.dispose if !@command_window.disposed?
@read_window.dispose
sp.dispose
end
def update
case @doing
when 1 #选书
update_1
when 2 #读书
update_2
end
end
def update_1
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Graphics/txt/" + @command_window.commands[@command_window.index]+".txt"
file = File.open(filename, "r")
r = file.readlines
@real_text = []
for i in 0...r.size
temp_story = r[i].split(/\n/)[0]
temp_story.gsub!(/,/) {","} if temp_story != nil
temp_story.gsub!(/\./) {"。"} if temp_story != nil
temp_story.gsub!(/ /) {" "} if temp_story != nil
while(temp_story != nil)
text = ""
if temp_story.length > 75
text = temp_story.slice!(0,75)
else
text = temp_story
temp_story = nil
end
@real_text.push(text)
end
end
file.close
@read_window.renew(@real_text, 0)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
def update_2
@read_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.visible = true
@command_window.active = true
@doing = 1
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@read_window.minus_1
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@read_window.add_1
end
if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_back
end
if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_add
end
end
end
——————————————————————
第三个
——————————————————————
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ Scene_Read
#==============================================================================
class Scene_Read_SUPER
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
sp = Spriteset_Map.new
@read_window = Window_Reader.new([""], 0)
@read_window.opacity = 230
@read_window.z = 900
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@command_window.dispose if !@command_window.disposed?
@read_window.dispose
sp.dispose
end
def update
case @doing
when 0 #选项
update_0
when 1 #选书
update_1
when 2 #读书
update_2
when 3 #选音乐
update_3
end
end
def update_0
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
text = Dir["Audio/music/*"]
@text = []
for tx in text
@text.push(tx.split(/music\//)[1])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 3
when 1
$game_system.se_play($data_system.decision_se)
text = Dir["Graphics/txt/*"]
@text = []
for tx in text
@text.push (tx.split(/txt\//)[1].split(/.txt/)[0])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 1
when 2
$game_system.se_play($data_system.decision_se)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
end
def update_1
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Graphics/txt/" + @command_window.commands[@command_window.index]+".txt"
file = File.open(filename, "r")
r = file.readlines
@real_text = []
for i in 0...r.size
temp_story = r[i].split(/\n/)[0]
temp_story.gsub!(/,/) {","} if temp_story != nil
temp_story.gsub!(/\./) {"。"} if temp_story != nil
temp_story.gsub!(/ /) {" "} if temp_story != nil
while(temp_story != nil)
text = ""
if temp_story.length > 75
text = temp_story.slice!(0,75)
else
text = temp_story
temp_story = nil
end
@real_text.push(text)
end
end
file.close
@read_window.renew(@real_text, 0)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
def update_2
@read_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@read_window.minus_1
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@read_window.add_1
end
if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_back
end
if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_add
end
end
def update_3
@command_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Audio/music/" + @command_window.commands[@command_window.index]
Audio.bgm_play(filename, 100, 100)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
end
end
复制代码
作者:
リデル
时间:
2012-8-14 04:10
測試不能
有錯誤
不過應該是
$scene=Scene_Read_SUPER.new
复制代码
呼出腳本一般的命令都是$scene = +主處理的項目
作者:
hys111111
时间:
2012-8-14 09:02
$scene = Scene_Read_NM.new
$scene = Scene_Read_SUPER.new
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1