rpg腳本錯誤
A. rpg maker xp沒有修改腳本可他卻說腳本錯誤,請問是怎麼回事
有可能是修改了游戲根目錄中的素材名稱,使得腳本找不到指定文件就會發生這種情況。
將文件名修改回原來的。或者重裝RMXP。
B. RPGmakerxp腳本錯誤
No Method Error
Undefined method 'event' for nil:NilClass
沒有方法錯誤
未定義的方法'事件'為零:NilClass
打開腳本編輯器,將Game_Player內內容全部刪除,將以下腳本復制進去保存再試試
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 處理主角的類。事件啟動的判定、以及地圖的滾動等功能。
# 本類的實例請參考 $game_player。
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● 恆量
#--------------------------------------------------------------------------
CENTER_X = (320 - 16) * 4 # 畫面中央的 X 坐標 * 4
CENTER_Y = (240 - 16) * 4 # 畫面中央的 Y 坐標 * 4
#--------------------------------------------------------------------------
# ● 可以通行判定
# x : X 坐標
# y : Y 坐標
# d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情況判定 (跳躍用)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# 求得新的坐標
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# 坐標在地圖外的情況下
unless $game_map.valid?(new_x, new_y)
# 不能通行
return false
end
# 調試模式為 ON 並且 按下 CTRL 鍵的情況下
if $DEBUG and Input.press?(Input::CTRL)
# 可以通行
return true
end
super
end
#--------------------------------------------------------------------------
# ● 像通到畫面中央一樣的設置地圖的顯示位置
#--------------------------------------------------------------------------
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
#--------------------------------------------------------------------------
# ● 向指定的位置移動
# x : X 座標
# y : Y 座標
#--------------------------------------------------------------------------
def moveto(x, y)
super
# 自連接
center(x, y)
# 生成遇敵計數
make_encounter_count
end
#--------------------------------------------------------------------------
# ● 增加步數
#--------------------------------------------------------------------------
def increase_steps
super
# 不是強制移動路線的場合
unless @move_route_forcing
# 增加步數
$game_party.increase_steps
# 步數是偶數的情況下
if $game_party.steps % 2 == 0
# 檢查連續傷害
$game_party.check_map_slip_damage
end
end
end
#--------------------------------------------------------------------------
# ● 獲取遇敵計數
#--------------------------------------------------------------------------
def encounter_count
return @encounter_count
end
#--------------------------------------------------------------------------
# ● 生成遇敵計數
#--------------------------------------------------------------------------
def make_encounter_count
# 兩種顏色震動的圖像
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 同伴人數為 0 的情況下
if $game_party.actors.size == 0
# 清除角色的文件名及對像
@character_name = ""
@character_hue = 0
# 分支結束
return
end
# 獲取帶頭的角色
actor = $game_party.actors[0]
# 設置角色的文件名及對像
@character_name = actor.character_name
@character_hue = actor.character_hue
# 初始化不透明度和合成方式子
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 同位置的事件啟動判定
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
result = false
# 事件執行中的情況下
if $game_system.map_interpreter.running?
return result
end
# 全部事件的循環
for event in $game_map.events.values
# 事件坐標與目標一致的情況下
if event.x == @x and event.y == @y and triggers.include?(event.trigger)
# 跳躍中以外的情況下、啟動判定是同位置的事件
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● 正面事件的啟動判定
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# 事件執行中的情況下
if $game_system.map_interpreter.running?
return result
end
# 計算正面坐標
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# 全部事件的循環
for event in $game_map.events.values
# 事件坐標與目標一致的情況下
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# 跳躍中以外的情況下、啟動判定是正面的事件
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# 找不到符合條件的事件的情況下
if result == false
# 正面的元件是計數器的情況下
if $game_map.counter?(new_x, new_y)
# 計算 1 元件里側的坐標
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# 全事件的循環
for event in $game_map.events.values
# 事件坐標與目標一致的情況下
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# 跳躍中以外的情況下、啟動判定是正面的事件
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● 接觸事件啟動判定
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# 事件執行中的情況下
if $game_system.map_interpreter.running?
return result
end
# 全事件的循環
for event in $game_map.events.values
# 事件坐標與目標一致的情況下
if event.x == x and event.y == y and [1,2].include?(event.trigger)
# 跳躍中以外的情況下、啟動判定是正面的事件
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
# 本地變數記錄移動信息
last_moving = moving?
# 移動中、事件執行中、強制移動路線中、
# 信息窗口一個也不顯示的時候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# 如果方向鍵被按下、主角就朝那個方向移動
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地變數記憶坐標
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移動、畫面上的位置在中央下方的情況下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 畫面向下卷動
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移動、畫面上的位置在中央左方的情況下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 畫面向左卷動
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移動、畫面上的位置在中央右方的情況下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 畫面向右卷動
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移動、畫面上的位置在中央上方的情況下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 畫面向上卷動
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移動中的情況下
unless moving?
# 上次主角移動中的情況
if last_moving
# 與同位置的事件接觸就判定為事件啟動
result = check_event_trigger_here([1,2])
# 沒有可以啟動的事件的情況下
if result == false
# 調試模式為 ON 並且按下 CTRL 鍵的情況下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敵計數下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 判定為同位置以及正面的事件啟動
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
C. RPG製作大師 腳本錯誤
腳本不能亂刪啊,每一個腳本都跟其他腳本對應,以Scene開頭的所有腳本基本都有關聯,刪了當然不行了,所謂的第八行出錯也就是沒有關聯項目,無法運行導致的
D. 使用RPG maker XP事出現腳本錯誤
一般來說場景繪制和腳本是沒有任何關系的,樓主把這張地圖復制到新建工程文件里看看會不會報錯。如果不報錯,說明這是單純的腳本沖突,建議重組腳本系統。
E. rpg腳本錯誤
做游戲的吧
找個能正常運行的游戲,把和你游戲里相同位置的腳本全部復制,再粘到你的游戲里,大概能解決。否則就是腳本沖突或者邏輯錯誤了。
F. 製作RPG游戲腳本錯誤
腳本太多了,先重新復制一遍,或者把它移到最靠近Main的上面那個,不行的話就刪除一些腳本
G. rpg製作大師腳本出錯!
Window_Base是游戲中全部窗口的超級類,可以嘗試將腳本編輯器里的Window_Base項刪除,然後從正常的rm里重新粘貼一個過來,看看是不是就沒問題了
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戲中全部窗口的超級類。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 初始化對像
# x : 窗口的 X 坐標
# y : 窗口的 Y 坐標
# width : 窗口的寬
# height : 窗口的寬
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
self.x = x
self.y = y
self.width = width
self.height = height
self.z = 100
end
#--------------------------------------------------------------------------
# ● 釋放
#--------------------------------------------------------------------------
def dispose
# 如果窗口的內容已經被設置就被釋放
if self.contents != nil
self.contents.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 獲取文字色
# n : 文字色編號 (0~7)
#--------------------------------------------------------------------------
def text_color(n)
case n
when 0
return Color.new(255, 255, 255, 255)
when 1
return Color.new(128, 128, 255, 255)
when 2
return Color.new(255, 128, 128, 255)
when 3
return Color.new(128, 255, 128, 255)
when 4
return Color.new(128, 255, 255, 255)
when 5
return Color.new(255, 128, 255, 255)
when 6
return Color.new(255, 255, 128, 255)
when 7
return Color.new(192, 192, 192, 255)
else
normal_color
end
end
#--------------------------------------------------------------------------
# ● 獲取普通文字色
#--------------------------------------------------------------------------
def normal_color
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ● 獲取無效文字色
#--------------------------------------------------------------------------
def disabled_color
return Color.new(255, 255, 255, 128)
end
#--------------------------------------------------------------------------
# ● 獲取系統文字色
#--------------------------------------------------------------------------
def system_color
return Color.new(192, 224, 255, 255)
end
#--------------------------------------------------------------------------
# ● 獲取危機文字色
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 64, 255)
end
#--------------------------------------------------------------------------
# ● 獲取戰斗不能文字色
#--------------------------------------------------------------------------
def knockout_color
return Color.new(255, 64, 0)
end
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
super
# 如果窗口的外關被變更了、再設置
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end
#--------------------------------------------------------------------------
# ● 圖形的描繪
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ● 名稱的描繪
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 120, 32, actor.name)
end
#--------------------------------------------------------------------------
# ● 職業的描繪
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 236, 32, actor.class_name)
end
#--------------------------------------------------------------------------
# ● 水平的描畫
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, "Lv")
self.contents.font.color = normal_color
self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 生辰成描繪用狀態字元串
# actor : 角色
# width : 描畫目標的寬度
# need_normal : [正常] 是否為必須 (true / false)
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
# 獲取括弧的寬
brackets_width = self.contents.text_size("[]").width
# 生成狀態名字元串
text = ""
for i in battler.states
if $data_states[i].rating >= 1
if text == ""
text = $data_states[i].name
else
new_text = text + "/" + $data_states[i].name
text_width = self.contents.text_size(new_text).width
if text_width > width - brackets_width
break
end
text = new_text
end
end
end
# 狀態名空的字元串是 "[正常]" 的情況下
if text == ""
if need_normal
text = "[正常]"
end
else
# 加上括弧
text = "[" + text + "]"
end
# 返回完成後的文字類
return text
end
#--------------------------------------------------------------------------
# ● 描繪狀態
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
# width : 描畫目標的寬
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
self.contents.draw_text(x, y, width, 32, text)
end
#--------------------------------------------------------------------------
# ● 描畫 EXP
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 24, 32, "E")
self.contents.font.color = normal_color
self.contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------
# ● 描繪 HP
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
# width : 描畫目標的寬
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# 描繪字元串 "HP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# 計算描繪 MaxHP 所需的空間
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# 描繪 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# 描繪 MaxHP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
#--------------------------------------------------------------------------
# ● 描繪 SP
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
# width : 描畫目標的寬
#--------------------------------------------------------------------------
def draw_actor_sp(actor, x, y, width = 144)
# 描繪字元串 "SP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
# 計算描繪 MaxSP 所需的空間
if width - 32 >= 108
sp_x = x + width - 108
flag = true
elsif width - 32 >= 48
sp_x = x + width - 48
flag = false
end
# 描繪 SP
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
# 描繪 MaxSP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
end
end
#--------------------------------------------------------------------------
# ● 描繪能力值
# actor : 角色
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
# type : 能力值種類 (0~6)
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = $data_system.words.atk
parameter_value = actor.atk
when 1
parameter_name = $data_system.words.pdef
parameter_value = actor.pdef
when 2
parameter_name = $data_system.words.mdef
parameter_value = actor.mdef
when 3
parameter_name = $data_system.words.str
parameter_value = actor.str
when 4
parameter_name = $data_system.words.dex
parameter_value = actor.dex
when 5
parameter_name = $data_system.words.agi
parameter_value = actor.agi
when 6
parameter_name = $data_system.words.int
parameter_value = actor.int
end
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 描繪物品名
# item : 物品
# x : 描畫目標 X 坐標
# y : 描畫目標 Y 坐標
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
end
H. 一個RPG游戲,到某一個關卡就提示彈出腳本問題,請問該怎麼解決。
樓主對你的問題,我也遇到過。我是這樣解決的:
首先使用本文中的故障排除方法時要按它們出現的順序進行。在您完成一個故障排除部分後,請進行測試以確定是否仍發生此腳本錯誤。如果問題已解決,則不必繼續下一部分。如果問題未解決,則繼續執行下一部分。
從另一個用戶帳戶、另一個瀏覽器和另一台計算機測試網頁
如果問題只在您查看一個或兩個網頁時發生,則從另一個用戶帳戶、另一個瀏覽器或另一台計算機查看這些網頁,以確定問題是否依然存在。如果腳本錯誤依然存在,則可能是網頁的編寫有問題。請與網站管理員或內容開發者聯系,告訴他們網頁存在的問題。如果從另一個用戶帳戶使用網頁時腳本錯誤未發生,則問題可能是您的用戶配置文件的文件或設置造成的。如果在從另一個瀏覽器或另一台計算機使用網頁時腳本錯誤未發生,則繼續進行故障排除操作。
確認活動腳本、ActiveX 和 Java 未被阻止
確認您計算機上的 Internet Explorer 或另外一種程序(如防病毒程序或防火牆)未配置為阻止活動腳本、ActiveX 控制項或 Java 小程序。在 Internet Explorer 的「高」安全級別,活動腳本、ActiveX 控制項和 Java 小程序被關閉。默認情況下,Internet Explorer 6 和某些 Internet Explorer 5.x 版本針對受限站點區域使用「高」安全級別。默認情況下,Microsoft Windows Server 2003 針對受限站點區域和 Internet 區域使用「高」安全級別。如要為當前網頁重置 Internet Explorer 安全設置,請按照下列步驟操作:1. 啟動 Internet Explorer。
2. 在「工具」菜單上,單擊「Internet 選項」。
3. 在「Internet 選項」對話框中,單擊「安全」。
4. 單擊「默認級別」。
5. 單擊「確定」。
請參見您使用的防病毒程序或防火牆的文檔資料,以確定如何打開腳本、ActiveX 和 Java 小程序。
確認您的防病毒程序未設置為掃描「臨時 Internet 文件」或「已下載的程序文件」文件夾
請參見您使用的防病毒程序的文檔資料,以確定如何防止該程序掃描「臨時 Internet 文件」或「已下載的程序文件」文件夾。
刪除所有臨時的 Internet 相關文件
從您的計算機中刪除所有臨時的 Internet 相關文件。為此,請按照下列步驟操作:1. 啟動 Internet Explorer。
2. 在「工具」菜單上,單擊「Internet 選項」。
3. 單擊「常規」選項卡。
4. 在「Internet 臨時文件」下,單擊「設置」。
5. 單擊「刪除文件」。
6. 單擊「確定」。
7. 單擊「刪除 Cookies」。
8. 單擊「確定」。
9. 在「歷史記錄」下,單擊「清除歷史記錄」,然後單擊「是」。
10. 單擊「確定」。 OK完畢
I. 關於RPG製作大師腳本問題
sprite_commands = []
@sprite_commands << sprite
請注意這兩個地方。<<在這里相當於push方法,向數組中添加sprite,但是@sprite_commands此時並不是數組,因此引發了這個錯誤。需要在一開始@sprite_commands = []