Project1

标题: 方便玩脚本的人的变量实时查看脚本 [打印本页]

作者: shoed    时间: 2011-8-27 16:25
标题: 方便玩脚本的人的变量实时查看脚本
本帖最后由 shoed 于 2011-8-27 16:25 编辑

本人感觉用RM玩脚本时总感觉非常不方便,不能实时的查看变量值的情况,
就像是VS2005那样,可以在一个输出窗口中看到变量的变化情况,因此
整了个简单的实时查看脚本,代码不复杂,个人感觉还是蛮方便的,但
是现在只能查看单个变量的情况,也算是个Bug吧~~~

先上图:


脚本:
  1. #--------------------------------------------------------------------------
  2. # ● 调试模板ver1.00
  3. # 制作者  小飞侠_shoed
  4. # 用法:
  5. # Debug::OutPutDebugString("map_x",map_x)
  6. # 参数1:调试的变量名  参数2:调试的变量
  7. #--------------------------------------------------------------------------



  8. module Debug

  9.   @@debug_win={}
  10.   @@win_x=0
  11.   @@win_y=0
  12.   @@win_wid=160
  13.   @@win_hei=36*2+32
  14.   
  15.   def Debug.OutPutDebugString(name,variable)
  16.     if @@debug_win.include?(name)
  17.       @@debug_win[name].refresh(name,variable)
  18.     else
  19.       @@win_x=@@debug_win.size%4*@@win_wid
  20.       @@win_y=@@debug_win.size/4*@@win_hei
  21.       @@debug_win[name]=Debug_Window.new(@@win_x,@@win_y,@@win_wid,@@win_hei,name,variable)
  22.       @@debug_win[name].z=9999
  23.     end
  24.   end
  25.   
  26.   class Debug_Window <Window_Base
  27.    
  28.     def initialize(cx,cy,cw,ch,me,str)
  29.       super(cx, cy, cw, ch)
  30.       @variable=[]
  31.       @variable[0]="---"
  32.       @variable[1]=str
  33.       self.contents = Bitmap.new(width - 32, height - 32)
  34.       self.contents.font.size = 32
  35.       refresh("---","---")
  36.     end
  37.    
  38.     def refresh(me,str)
  39.       if me!="---" and @variable[1] != str
  40.         @variable.shift
  41.         @variable.push(str)
  42.       end
  43.       self.contents.clear
  44.       self.contents.font.color = Color.new(255,255,0,255)
  45.       self.contents.draw_text(0, 2, width-32, 32, "#{me} : #{@variable[0]}")
  46.       self.contents.font.color = Color.new(255,0,0,255)
  47.       self.contents.draw_text(0, 38, width-32, 32, "#{me} : #{@variable[1]}")
  48.     end
  49.   end
  50. end
复制代码
使用方法也很简单:
Debug::OutPutDebugString("主角_X",$game_player.x)
Debug::OutPutDebugString("主角_Y",$game_player.y)

第一个参数你可以随意,只要自已认识就行,第二个参数就是变量了
这个函数可以放在while的循环中,也可以放在只执行一次的初始化中,基本没限制
呵呵,功能还很简单。。。
作者: fux2    时间: 2011-8-27 21:32
一般P一下就可以了.




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1