Project1
标题:
脚本错误
[打印本页]
作者:
q6625765
时间:
2014-2-18 15:21
标题:
脚本错误
本帖最后由 fux2 于 2014-2-20 16:46 编辑
3.png
(5.58 KB, 下载次数: 11)
下载附件
保存到相册
2014-2-18 15:19 上传
帮看一下这里怎么会这样的,是不是还缺少一个脚本呀{:2_271:}
# ● 初始画对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
# css : 窗口样式
#--------------------------------------------------------------------------
def initialize(x, y, width, height, css = "")
super(x, y, width, height,css)
@item_max = 1
@column_max = 1
[url=home.php?mod=space&uid=370741]@Index[/url] = -1
end
#--------------------------------------------------------------------------
# ● 设置光标的位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)
@index = index
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 获取行数
#--------------------------------------------------------------------------
def row_max
# 由项目数和列数计算出行数
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
return self.oy / 80
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
self.oy = row * 80
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return (self.height - 32) / 80
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的项目数
#--------------------------------------------------------------------------
def page_item_max
# 将行数 page_row_max 乘上列数 @column_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# ● 帮助窗口的设置
# help_window : 新的帮助窗口
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = 80
# 计算光标坐标
x = 1 + @index % @column_max * (cursor_width)
y = 1 + @index / @column_max * 80
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 80)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 可以移动光标的情况下
if self.active and @index >= 0
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 列数不是 1 并且方向键的下的按下状态不是重复的情况、
# 或光标位置在(项目数-列数)之前的情况下
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# 光标向下移动
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 列数不是 1 并且方向键的下的按下状态不是重复的情况、
# 或光标位置在列之后的情况下
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
# 光标向上移动
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
if @column_max >= 2 and @index < @item_max - 1
# 光标向右移动
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 列数为 2 以上并且、光标位置在 0 之后的情况下
if @column_max >= 2 and @index > 0
# 光标向左移动
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
# R 键被按下的情况下
if Input.repeat?(Input::R)
# 显示的最后行在数据中最后行上方的情况下
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# 光标向后移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
# L 键被按下的情况下
if Input.repeat?(Input::L)
# 显示的开头行在位置 0 之后的情况下
if self.top_row > 0
# 光标向前移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
if self.active and @item_max > 0
index_var = @index
tp_index = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in 0...@item_max
@index = i
update_cursor_rect
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false
if tp_index != @index
$game_system.se_stop
tp_index = @index
$game_system.se_play($data_system.cursor_se)
end
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect
Mouse.click_lock
else
Mouse.click_unlock
end
end
end
end
class Window_Renwu < Window_Renwu_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(242, 35, 336, 256)
self.opacity = 0
[url=home.php?mod=space&uid=95897]@actor[/url] = actor
@column_max = 4
@item_max = 0
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = [0,1,2,3,4,5,6,7,8,9,10,11]
for @actor in
[email protected]
@item_max = @data.size
self.index = @actor
return @data[self.index]
end
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 80 + 32)
end
end
end
class Window_Renjian < Window_Baby_Selectable
def initialize(x, y, width, height, commands, x_jiange = 0, y_jiange=14)
super(x,y, width, height)
self.opacity = 0
@item_max = commands.size
@commands = commands
@x_jiange = x_jiange
@y_jiange = y_jiange
self.contents = Bitmap.new(width,height)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_name(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
# color : 文字色
#--------------------------------------------------------------------------
def draw_name(index)
self.contents.font.name = "宋体"
self.contents.font.size = 13
w = (self.contents.width - 32) / @column_max - @column_max * @x_jiange
h = (self.contents.height- 32) / @item_max - @column_max * @y_jiange
x = index % @column_max *w + @x_jiange
y = index / @column_max *h + @y_jiange
self.contents.draw_text(x, y, w, h, @commands[index],0)
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Window_Jianren < Window_Base
attr_accessor :actor
def initialize
super(0,0,640,480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
[url=home.php?mod=space&uid=114926]@sprite[/url] = Sprite.new
@sprite.x = 232
@sprite.y = 354
@sprite2 = Sprite.new
@sprite2.x = 21
@sprite2.y = 20
@actor = actor
refresh
end
def dispose
if @sprite.bitmap != nil
@sprite.bitmap.dispose
end
if @sprite2.bitmap != nil
@sprite2.bitmap.dispose
end
end
def refresh
self.contents.clear
case @actor
when 0
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 1
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 2
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 3
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 4
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 5
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 6
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 7
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 8
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 9
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 10
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
when 11
@sprite.bitmap = Bitmap.new
@sprite2.bitmap = Bitmap.new
end
end
end
class Mingshuo < Window_Base
def initialize
super(225,289,374,72)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.contents.font.name = "黑体"
self.contents.font.color = text_color(6)
self.contents.font.size = 25
end
def refresh(shuoming = "")
self.contents.clear
self.contents.draw_text(0,0,300,40,shuoming,1)
end
end
class Scene_Cjrw
def initialize(index=0)
@index = index
end
def main
# 获取角色
@window_moren = Window_Base.new(0,231,450,50)
@window_moren.contents = Bitmap.new(400,118)
@window_moren.opacity = 0
@window_moren.active = false
[url=home.php?mod=space&uid=81523]@skin[/url] = Sprite.new
@skin.bitmap = RPG::Cache.windowskin
@window2_skin = Sprite.new
@window2_skin.bitmap = RPG::Cache.windowskin
@window2_skin.x = 54
@window2_skin.y = 369
@window2_command = Window_Base.new(57,362,100,60)
@window2_command.contents = Bitmap.new(68,28)
@window2_command.opacity = 0
@window2_command.active = false
@v = Viewport.new(0,313,220,29)
@v.color.set(0,0,0,0)
$game_temp.name_max_char = 6
@tf = Type_Field.new($game_temp.name_max_char*3-4)--这里出现错误
@window_ren = Window_Renwu.new(@index)
@window_ren.index = @index
@window_ren.active = true
[url=home.php?mod=space&uid=37298]@Window[/url] = Window_Jianren.new
s1 = ""
s2 = ""
@command = Window_Renjian.new(507,338,142,128,[s1,s2])
@command.index = -1
@command.active = false
@shuoming = Mingshuo.new
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新信息
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@window_moren.dispose
@skin.dispose
@window2_command.dispose
@window_ren.dispose
@command.dispose
@shuoming.dispose
@tf.dispose
@window.dispose
@window2_skin.dispose
@v.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@window_moren.update
@window2_command.update
@window_ren.update
@command.update
@window.update
if @window_ren.active == true
@shuoming.refresh("现在请选择人物")
case @window_ren.index
when 0
@window.actor = 0
@window.refresh
when 1
@window.actor = 1
@window.refresh
when 2
@window.actor = 2
@window.refresh
when 3
@window.actor = 3
@window.refresh
when 4
@window.actor = 4
@window.refresh
when 5
@window.actor = 5
@window.refresh
when 6
@window.actor = 6
@window.refresh
when 7
@window.actor = 7
@window.refresh
when 8
@window.actor = 8
@window.refresh
when 9
@window.actor = 9
@window.refresh
when 10
@window.actor = 10
@window.refresh
when 11
@window.actor = 11
@window.refresh
end
if Input.trigger?(Input::C)
case @window_ren.index
when 0
k = $game_party.actors[0]
if k.id == 9
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(9)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 1
k = $game_party.actors[0]
if k.id == 10
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(10)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 2
k = $game_party.actors[0]
if k.id == 11
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(11)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 3
k = $game_party.actors[0]
if k.id == 12
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(12)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 4
k = $game_party.actors[0]
if k.id == 13
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(13)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 5
k = $game_party.actors[0]
if k.id == 14
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(14)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 6
k = $game_party.actors[0]
if k.id == 15
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(15)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 7
k = $game_party.actors[0]
if k.id == 16
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(16)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 8
k = $game_party.actors[0]
if k.id == 17
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(17)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 9
k = $game_party.actors[0]
if k.id == 18
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(18)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 10
k = $game_party.actors[0]
if k.id == 19
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(19)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
when 11
k = $game_party.actors[0]
if k.id == 20
$game_system.se_play($data_system.decision_se)
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
else
$game_system.se_play($data_system.decision_se)
$game_party.add_actor(20)
$game_party.remove_actor(k.id)
$game_player.refresh
@window_ren.active = false
@window_ren.index = -1
@window_moren.active = true
end
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
return
end
end
if @window2_command.active == true
@shuoming.refresh("现在请输入名字")
@window2_skin.bitmap = RPG::Cache.windowskin("创建2")
@window2_skin.x = 54
@window2_skin.y = 369
@window2_command.cursor_rect.set(0, 0, 68, 28)
if Input.trigger?(Input::C)
if @tf.get_text != ""
$game_actors[$game_party.actors[0].id].name = @tf.get_text
$game_system.se_play($data_system.decision_se)
@command.active = true
@window2_command.active = false
@window2_command.cursor_rect.set(0, 0, 0, 0)
@window2_skin.bitmap = RPG::Cache.windowskin("创建1")
@window2_skin.x = 54
@window2_skin.y = 369
else
$game_system.se_play($data_system.buzzer_se)
end
end
if Input.trigger?(Input::UP)
@window2_command.active = false
@window2_skin.bitmap = RPG::Cache.windowskin("创建1")
@window2_skin.x = 54
@window2_skin.y = 369
@window_moren.active = true
@tf.active = true
@window2_command.cursor_rect.set(0, 0, 0, 0)
end
mouse_x, mouse_y = Mouse.get_mouse_pos
if mouse_x > 70 and mouse_x < 178 and mouse_y > 313 and mouse_y < 339
@window2_command.active = false
@window2_skin.bitmap = RPG::Cache.windowskin("创建1")
@window2_skin.x = 54
@window2_skin.y = 369
@window_moren.active = true
@tf.active = true
@window2_command.cursor_rect.set(0, 0, 0, 0)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_ren.active = true
@window_moren.active = false
@window2_command.active = false
@window2_command.cursor_rect.set(0, 0, 0, 0)
end
end
if @window_moren.active == true
@shuoming.refresh("现在请输入名字")
@window_moren.cursor_rect.set(180, 65, 200, 30)
@tf.update
if Input.trigger?(Input::DOWN)
@window2_command.active = true
@window_moren.active = false
@tf.active = false
@tf.update
@window_moren.cursor_rect.set(0, 0, 0, 0)
end
mouse_x, mouse_y = Mouse.get_mouse_pos
if mouse_x > 70 and mouse_x < 160 and mouse_y > 378 and mouse_y < 431
@window2_command.active = true
@window_moren.active = false
@tf.active = false
@tf.update
@window_moren.cursor_rect.set(0, 0, 0, 0)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_ren.active = true
@window_moren.active = false
@window2_command.active = false
@window_moren.cursor_rect.set(0, 0, 0, 0)
end
end
end
复制代码
作者:
你欠抽吧
时间:
2014-2-18 17:07
本帖最后由 你欠抽吧 于 2014-2-18 19:59 编辑
Type_Field没初始化
这个像是输入文本用的- -
看起来像是LZ没有把整个和这段有关的脚本都复制下来
到找到这段脚本的地方再找找看有没有和Type_Field有关的东西
作者:
夜狠简单
时间:
2014-2-19 13:11
复制你的脚本以后错误的地方提示挺多,希望能切换到高级回复模式,使用代码功能,重新复制脚本。或者把相关脚本弄到一个新工程里发上来。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1