查看: 3905|回复: 1

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

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

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

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

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

脚本:
  1.     #===============================================================================
  2.     # * 编辑与游戏
  3.     #-------------------------------------------------------------------------------
  4.     #   - 版本: 2.1
  5.     #   - 日期   : 8 / 02 / 2013
  6.     #   - 作者 : .:yayapipi:.
  7.     #-------------------------------------------------------------------------------
  8.     #   - 解释:
  9.     #     能够让你一边玩游戏的同时编辑游戏!
  10.     #-------------------------------------------------------------------------------
  11.     #   - 适用于:
  12.     #     RPG Maker XP 和 RPG Maker VX
  13.     #===============================================================================
  14.      
  15.     module Edit_and_Play
  16.       # Activate the script? (true / false)
  17.       Activate = true
  18.       # Key which updates the game
  19.       Update_Key = Input::ALT
  20.       # Data files that won't be reloaded
  21.       File_Exclude = []
  22.       # Scripts that won't be reloaded
  23.       Scripts_Exclude = ["Edit & Play", "Main"]
  24.     end
  25.      
  26.     $VX ||= defined?(Graphics.wait)
  27.      
  28.     if ((Edit_and_Play::Activate) && !(File.file?("Game.rgss#{$VX ? '2a' : 'ad'}")))
  29.      
  30.       char     = $VX ? "v" : "x"
  31.       old_file = "Data/BT_Actors.r#{char}data"
  32.       new_file = "Data/BT_Actors2.r#{char}data"
  33.      
  34.       if ($TEST || $DEBUG)
  35.         File.rename(old_file, new_file) if ($BTEST)
  36.         Thread.new {system("Game.exe")}
  37.         exit
  38.       else
  39.         $TEST = $DEBUG = true
  40.         if (File.file?(new_file))
  41.           File.rename(new_file, old_file)
  42.           $BTEST = true
  43.         end
  44.       end
  45.      
  46.       unless ($VX)
  47.         class Scene_Battle
  48.          
  49.           alias :edit_and_play_1 :main unless ($@)
  50.          
  51.           def main
  52.             edit_and_play_1
  53.             $scene = Scene_Battle.new if ($BTEST)
  54.           end
  55.          
  56.         end
  57.       end
  58.      
  59.       class << Input
  60.       
  61.         alias :edit_and_play_2 :update unless ($@)
  62.       
  63.         def update
  64.           if (trigger?(Edit_and_Play::Update_Key))
  65.             for file in (Dir.entries("Data") - [".", "..", *Edit_and_Play::File_Exclude])
  66.               next if (file.include?("Map"))
  67.               basename = File.basename(file, ".*").downcase!
  68.               if (basename == "scripts")
  69.                 ($VX ? Cache : RPG::Cache).clear
  70.                 for data in load_data("Data/#{file}")
  71.                   next if (Edit_and_Play::Scripts_Exclude.include?(data[1]))
  72.                   eval(Zlib::Inflate.inflate(data[2]))
  73.                 end
  74.                 $game_map.setup($game_map.map_id) if ($game_map != nil && $game_map.map_id != 0)
  75.                 $scene = $scene.class.new
  76.               else
  77.                 eval("$data_#{basename} = load_data('Data/#{file}')")
  78.               end
  79.             end        
  80.           end
  81.           edit_and_play_2
  82.         end
  83.       
  84.       end
  85.      
  86.     end
复制代码


插入在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.

在本版发帖返回顶部