查看: 3863|回复: 1

[通用发布] 游戏进行时编辑游戏脚本

[复制链接]
梦石
0
星屑
56
在线时间
342 小时
注册时间
2011-10-29
回帖
327
发表于 2013-2-8 09:35:59 | 显示全部楼层 |阅读模式

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

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

×
解释:
这个脚本可以使你在测试游戏的时候也可以直接修改编辑你的编辑器,
而不需要关闭游戏!
适用于:
RPG MAKER XP 和RPG MAKER VX

脚本:
[pre lang="" line="1"]    #===============================================================================
    # * 编辑与游戏
    #-------------------------------------------------------------------------------
    #   - 版本: 2.1
    #   - 日期   : 8 / 02 / 2013
    #   - 作者 : .:yayapipi:.
    #-------------------------------------------------------------------------------
    #   - 解释:
    #     能够让你一边玩游戏的同时编辑游戏!
    #-------------------------------------------------------------------------------
    #   - 适用于:
    #     RPG Maker XP 和 RPG Maker VX
    #===============================================================================
     
    module Edit_and_Play
      # Activate the script? (true / false)
      Activate = true
      # Key which updates the game
      Update_Key = Input::ALT
      # Data files that won't be reloaded
      File_Exclude = []
      # Scripts that won't be reloaded
      Scripts_Exclude = ["Edit & Play", "Main"]
    end
     
    $VX ||= defined?(Graphics.wait)
     
    if ((Edit_and_Play::Activate) && !(File.file?("Game.rgss#{$VX ? '2a' : 'ad'}")))
     
      char     = $VX ? "v" : "x"
      old_file = "Data/BT_Actors.r#{char}data"
      new_file = "Data/BT_Actors2.r#{char}data"
     
      if ($TEST || $DEBUG)
        File.rename(old_file, new_file) if ($BTEST)
        Thread.new {system("Game.exe")}
        exit
      else
        $TEST = $DEBUG = true
        if (File.file?(new_file))
          File.rename(new_file, old_file)
          $BTEST = true
        end
      end
     
      unless ($VX)
        class Scene_Battle
         
          alias :edit_and_play_1 :main unless ($@)
         
          def main
            edit_and_play_1
            $scene = Scene_Battle.new if ($BTEST)
          end
         
        end
      end
     
      class << Input
      
        alias :edit_and_play_2 :update unless ($@)
      
        def update
          if (trigger?(Edit_and_Play::Update_Key))
            for file in (Dir.entries("Data") - [".", "..", *Edit_and_Play::File_Exclude])
              next if (file.include?("Map"))
              basename = File.basename(file, ".*").downcase!
              if (basename == "scripts")
                ($VX ? Cache : RPG::Cache).clear
                for data in load_data("Data/#{file}")
                  next if (Edit_and_Play::Scripts_Exclude.include?(data[1]))
                  eval(Zlib::Inflate.inflate(data[2]))
                end
                $game_map.setup($game_map.map_id) if ($game_map != nil && $game_map.map_id != 0)
                $scene = $scene.class.new
              else
                eval("$data_#{basename} = load_data('Data/#{file}')")
              end
            end        
          end
          edit_and_play_2
        end
      
      end
     
    end[/pre]

插入在MAIN之前,即可使用!
梦石
0
星屑
50
在线时间
37 小时
注册时间
2012-7-30
回帖
124
发表于 2013-2-8 10:06:25 | 显示全部楼层
F12好像就可以重新载入新修改的脚本进程了。
不过比如在战斗中突然删掉某个函数,就不会直接崩溃吗?
而且eval不论怎样都是最好避免的东西,重新打开compiler编译会降速……
想回复我的话请呼(@)我一下。
准备执行人体盗图计划,copyright的诸君赶紧藏好咧~
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部