设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1149|回复: 2
打印 上一主题 下一主题

[已经解决] 脚本出现NoMethodError。

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
140
在线时间
0 小时
注册时间
2009-8-24
帖子
2
跳转到指定楼层
1
发表于 2009-8-28 15:39:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
出错的是人物跟随脚本。希望大家能够帮忙解决!

class Game_Character
attr_accessor :move_speed
end

class Game_Map
attr_accessor :oldroute
attr_accessor :oldeventsnums
attr_reader   :map
alias initialize_old initialize
def initialize
   initialize_old
   @oldroute = []
   @oldeventsnums = 0
end
end

class Game_Player < Game_Character
alias update_old update
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
       if passable?(@x, @y, 2)
         $game_map.oldroute.push([@x,@y,2])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_down
     when 4
       if passable?(@x, @y, 4)
         $game_map.oldroute.push([@x,@y,4])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_left
     when 6
       if passable?(@x, @y, 6)
         $game_map.oldroute.push([@x,@y,6])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_right
     when 8
       if passable?(@x, @y, 8)
         $game_map.oldroute.push([@x,@y,8])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_up
     end
   end
   update_old
end
end

class Interpreter
def command_129
   actor = $game_actors[@parameters[0]]
   if actor != nil
     if @parameters[1] == 0
       if @parameters[2] == 1
         $game_actors[@parameters[0]].setup(@parameters[0])
       end
       $game_party.add_actor(@parameters[0])
       $scene.del_follow
       $scene.follow_system
     else
       $game_party.remove_actor(@parameters[0])
       $scene.del_follow
       $scene.follow_system
     end
   end
   return true
end
end

class Scene_Map
alias main_old main
def main
   @spriteset = Spriteset_Map.new
   if $game_variables[1000] == 0
     follow_system
     $game_variables[1000] = 1
   end
   main_old
end

alias update_old update
def update
   follow_system_update
   update_old
end

alias transfer_player_old transfer_player
def transfer_player
   $game_temp.player_transferring = false
   if $game_map.map_id != $game_temp.player_new_map_id
     del_follow
     $game_map.setup($game_temp.player_new_map_id)
   end
   $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
   follow_system
   transfer_player_old
end

def follow_system
   $game_map.oldeventsnums = $game_map.events.size
   if $game_party.actors.size>=2
     for i in 2..$game_party.actors.size
       # 为事件加上名字考虑做srpg用
       name = "队伍,"+i.to_s
       character_name = $game_party.actors[i-1].character_name
       party_event($game_player.x,$game_player.y,name,character_name)
       $game_map.oldroute.push([$game_player.x,$game_player.y,$game_player.direction])
     end
   end
end

def del_follow
   $game_map.oldroute.clear
   for i in 1..($game_map.events.size-$game_map.oldeventsnums)
     $game_map.events.delete($game_map.oldeventsnums+i)
   end
end

def party_event(x,y,name,character_name)
   $game_map.events[$game_map.events.size+1] = Game_Event.new($game_map.map_id,produce_party_event(x,y,name,character_name))
   $game_map.map.events[$game_map.events.size] = produce_party_event(x,y,name,character_name)
   @spriteset.dispose
   @spriteset = Spriteset_Map.new
end

def produce_party_event(x,y,name,character_name)
   e = RPG::Event.new(x,y)
   e.id = $game_map.events.size
   e.name = name
   e.pages = [RPG::Event::Page.new]   
   e.pages[0].graphic = RPG::Event::Page::Graphic.new
   e.pages[0].graphic.character_name = character_name   
   e.pages[0].through = true
   return e
end

def follow_system_update
   num = $game_map.oldeventsnums
   n = $game_player.move_speed
   s=$game_map.oldroute.size-1
   if s>=0
     $game_map.events[num+1].move_speed = n
     if $game_map.events[num+1].x>$game_map.oldroute[0]
       $game_map.events[num+1].move_left
     elsif $game_map.events[num+1].x<$game_map.oldroute[0]
       $game_map.events[num+1].move_right
     elsif $game_map.events[num+1].y>$game_map.oldroute[1]
       $game_map.events[num+1].move_up
     elsif $game_map.events[num+1].y<$game_map.oldroute[1]
       $game_map.events[num+1].move_down
     end
   end
   if s>=1
     $game_map.events[num+2].move_speed = n
     if $game_map.events[num+2].x>$game_map.oldroute[s-1][0]
       $game_map.events[num+2].move_left
     elsif $game_map.events[num+2].x<$game_map.oldroute[s-1][0]
       $game_map.events[num+2].move_right
     elsif $game_map.events[num+2].y>$game_map.oldroute[s-1][1]
       $game_map.events[num+2].move_up
     elsif $game_map.events[num+2].y<$game_map.oldroute[s-1][1]
       $game_map.events[num+2].move_down
     end
   end
   if s>=2
     $game_map.events[num+3].move_speed = n(出错的179行)
     if $game_map.events[num+3].x>$game_map.oldroute[s-2][0]
       $game_map.events[num+3].move_left
     elsif $game_map.events[num+3].x<$game_map.oldroute[s-2][0]
       $game_map.events[num+3].move_right
     elsif $game_map.events[num+3].y>$game_map.oldroute[s-2][1]
       $game_map.events[num+3].move_up
     elsif $game_map.events[num+3].y<$game_map.oldroute[s-2][1]
       $game_map.events[num+3].move_down
     end
   end
   if s>=3
     $game_map.events[num+4].move_speed = n
     if $game_map.events[num+4].x>$game_map.oldroute[s-3][0]
       $game_map.events[num+4].move_left
     elsif $game_map.events[num+4].x<$game_map.oldroute[s-3][0]
       $game_map.events[num+4].move_right
     elsif $game_map.events[num+4].y>$game_map.oldroute[s-3][1]
       $game_map.events[num+4].move_up
     elsif $game_map.events[num+4].y<$game_map.oldroute[s-3][1]
       $game_map.events[num+4].move_down
     end
   end
   if s>=4
     $game_map.events[num+5].move_speed = n
     if $game_map.events[num+5].x>$game_map.oldroute[s-4][0]
       $game_map.events[num+5].move_left
     elsif $game_map.events[num+5].x<$game_map.oldroute[s-4][0]
       $game_map.events[num+5].move_right
     elsif $game_map.events[num+5].y>$game_map.oldroute[s-4][1]
       $game_map.events[num+5].move_up
     elsif $game_map.events[num+5].y<$game_map.oldroute[s-4][1]
       $game_map.events[num+5].move_down
     end
   end
end
end

Lv1.梦旅人

梦石
0
星屑
140
在线时间
0 小时
注册时间
2009-8-24
帖子
2
2
 楼主| 发表于 2009-8-28 15:36:00 | 只看该作者

脚本发生了NoMethodError

出错的是人物跟随的脚本。
之前测试没有出错,但是再次测试的时候系统提示脚本出错。(这个是朋友的游戏)

因为朋友使用的脚本和我的不同...所以请教一下大家~
————————————————
class Game_Character
attr_accessor :move_speed
end

class Game_Map
attr_accessor :oldroute
attr_accessor :oldeventsnums
attr_reader   :map
alias initialize_old initialize
def initialize
   initialize_old
   @oldroute = []
   @oldeventsnums = 0
end
end

class Game_Player < Game_Character
alias update_old update
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
       if passable?(@x, @y, 2)
         $game_map.oldroute.push([@x,@y,2])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_down
     when 4
       if passable?(@x, @y, 4)
         $game_map.oldroute.push([@x,@y,4])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_left
     when 6
       if passable?(@x, @y, 6)
         $game_map.oldroute.push([@x,@y,6])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_right
     when 8
       if passable?(@x, @y, 8)
         $game_map.oldroute.push([@x,@y,8])
         if $game_map.oldroute.size == $game_party.actors.size
           $game_map.oldroute.shift
         end
       end
       move_up
     end
   end
   update_old
end
end

class Interpreter
def command_129
   actor = $game_actors[@parameters[0]]
   if actor != nil
     if @parameters[1] == 0
       if @parameters[2] == 1
         $game_actors[@parameters[0]].setup(@parameters[0])
       end
       $game_party.add_actor(@parameters[0])
       $scene.del_follow
       $scene.follow_system
     else
       $game_party.remove_actor(@parameters[0])
       $scene.del_follow
       $scene.follow_system
     end
   end
   return true
end
end

class Scene_Map
alias main_old main
def main
   @spriteset = Spriteset_Map.new
   if $game_variables[1000] == 0
     follow_system
     $game_variables[1000] = 1
   end
   main_old
end

alias update_old update
def update
   follow_system_update
   update_old
end

alias transfer_player_old transfer_player
def transfer_player
   $game_temp.player_transferring = false
   if $game_map.map_id != $game_temp.player_new_map_id
     del_follow
     $game_map.setup($game_temp.player_new_map_id)
   end
   $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
   follow_system
   transfer_player_old
end

def follow_system
   $game_map.oldeventsnums = $game_map.events.size
   if $game_party.actors.size>=2
     for i in 2..$game_party.actors.size
       # 为事件加上名字考虑做srpg用
       name = "队伍,"+i.to_s
       character_name = $game_party.actors[i-1].character_name
       party_event($game_player.x,$game_player.y,name,character_name)
       $game_map.oldroute.push([$game_player.x,$game_player.y,$game_player.direction])
     end
   end
end

def del_follow
   $game_map.oldroute.clear
   for i in 1..($game_map.events.size-$game_map.oldeventsnums)
     $game_map.events.delete($game_map.oldeventsnums+i)
   end
end

def party_event(x,y,name,character_name)
   $game_map.events[$game_map.events.size+1] = Game_Event.new($game_map.map_id,produce_party_event(x,y,name,character_name))
   $game_map.map.events[$game_map.events.size] = produce_party_event(x,y,name,character_name)
   @spriteset.dispose
   @spriteset = Spriteset_Map.new
end

def produce_party_event(x,y,name,character_name)
   e = RPG::Event.new(x,y)
   e.id = $game_map.events.size
   e.name = name
   e.pages = [RPG::Event::Page.new]   
   e.pages[0].graphic = RPG::Event::Page::Graphic.new
   e.pages[0].graphic.character_name = character_name   
   e.pages[0].through = true
   return e
end

def follow_system_update
   num = $game_map.oldeventsnums
   n = $game_player.move_speed
   s=$game_map.oldroute.size-1
   if s>=0
     $game_map.events[num+1].move_speed = n
     if $game_map.events[num+1].x>$game_map.oldroute[0]
       $game_map.events[num+1].move_left
     elsif $game_map.events[num+1].x<$game_map.oldroute[0]
       $game_map.events[num+1].move_right
     elsif $game_map.events[num+1].y>$game_map.oldroute[1]
       $game_map.events[num+1].move_up
     elsif $game_map.events[num+1].y<$game_map.oldroute[1]
       $game_map.events[num+1].move_down
     end
   end
   if s>=1
     $game_map.events[num+2].move_speed = n
     if $game_map.events[num+2].x>$game_map.oldroute[s-1][0]
       $game_map.events[num+2].move_left
     elsif $game_map.events[num+2].x<$game_map.oldroute[s-1][0]
       $game_map.events[num+2].move_right
     elsif $game_map.events[num+2].y>$game_map.oldroute[s-1][1]
       $game_map.events[num+2].move_up
     elsif $game_map.events[num+2].y<$game_map.oldroute[s-1][1]
       $game_map.events[num+2].move_down
     end
   end
   if s>=2
     $game_map.events[num+3].move_speed = n(显示出错的179行)
     if $game_map.events[num+3].x>$game_map.oldroute[s-2][0]
       $game_map.events[num+3].move_left
     elsif $game_map.events[num+3].x<$game_map.oldroute[s-2][0]
       $game_map.events[num+3].move_right
     elsif $game_map.events[num+3].y>$game_map.oldroute[s-2][1]
       $game_map.events[num+3].move_up
     elsif $game_map.events[num+3].y<$game_map.oldroute[s-2][1]
       $game_map.events[num+3].move_down
     end
   end
   if s>=3
     $game_map.events[num+4].move_speed = n
     if $game_map.events[num+4].x>$game_map.oldroute[s-3][0]
       $game_map.events[num+4].move_left
     elsif $game_map.events[num+4].x<$game_map.oldroute[s-3][0]
       $game_map.events[num+4].move_right
     elsif $game_map.events[num+4].y>$game_map.oldroute[s-3][1]
       $game_map.events[num+4].move_up
     elsif $game_map.events[num+4].y<$game_map.oldroute[s-3][1]
       $game_map.events[num+4].move_down
     end
   end
   if s>=4
     $game_map.events[num+5].move_speed = n
     if $game_map.events[num+5].x>$game_map.oldroute[s-4][0]
       $game_map.events[num+5].move_left
     elsif $game_map.events[num+5].x<$game_map.oldroute[s-4][0]
       $game_map.events[num+5].move_right
     elsif $game_map.events[num+5].y>$game_map.oldroute[s-4][1]
       $game_map.events[num+5].move_up
     elsif $game_map.events[num+5].y<$game_map.oldroute[s-4][1]
       $game_map.events[num+5].move_down
     end
   end
end
end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

清纯红

梦石
0
星屑
61
在线时间
65 小时
注册时间
2009-7-23
帖子
995

贵宾

3
发表于 2009-8-28 17:50:36 | 只看该作者
你有自定义脚本,我记的有个版本可以用
就算痛也要做,宅必备宅人的必备网站
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-1-10 04:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表