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

Project1

 找回密码
 注册会员
搜索
查看: 1641|回复: 4

[已经过期] 关于几个事件里指令的脚本写法,求解

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
发表于 2016-8-29 09:20:17 | 显示全部楼层 |阅读模式

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

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

x
1.显示选择项

2.场所移动

3.标签与标签跳转
在脚本编辑器里编写脚本,这个类似标签跳转的功能怎么写?

4.更改事件的行走图形
更改角色行走图形倒是知道,但是要更改事件的行走图则要在设置移动路线里改,直接用脚本怎么写?

其他的事件指令我基本上能找到,就差这几个了,往大神解答

Lv1.梦旅人

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
帖子
151
发表于 2016-8-29 11:06:55 | 显示全部楼层
最麻烦的就是显示选择项,建议用这个脚本。可以随时调用的是或否选择窗口

教程作者:洛克人SZ
首发网址:点此进入本教学的原始帖
适宜用户:喜欢用的都可以用吧^^
技术通用度:★★★★★
技术应用复杂度:20 (满分150分)
学习的理解难度:35 (满分150分)



--------------------------------------------------------------------------------

作者的话:

在需要向玩家询问 是/否 的时候可以用到的东西。
要显示选项窗口在地图画面或战斗画面中可以用显示对话的选项功能实现,在其他画面中就需要建立一个命令窗口,还要写相关的代码,比较麻烦。这个脚本在只需询问 是/否 两个选项的情况下只用一个简单的判断语句就可以完成,应该比较方便吧。

如果已经有类似的东西就请无视吧……

v 1.3: 在 enghao_lim 大人的提醒下继续精简代码
v 1.2: 除掉了一个BUG
v 1.1: 精简代码

教学正文:
RUBY 代码复制
  1. #================================================================
  2. #   可以随时调用的 是/否 选择窗口      by 洛克人SZ
  3. #   用法:                               v 1.3
  4. #     if yes_no("提示信息")
  5. #       选择 是 的情况下
  6. #     else
  7. #       选择 否 的情况下
  8. #     end
  9. #
  10. #   也可以用在事件中的条件分歧里。
  11. #================================================================
  12.  
  13.  
  14. def yes_no(info = "请选择:")
  15.   dummy_bitmap = Bitmap.new(608, 32)
  16.   dummy_bitmap.font.size = 22
  17.   strwidth = dummy_bitmap.text_size(info).width
  18.   dummy_bitmap.dispose
  19.   dummy_bitmap = nil
  20.   strwidth = 88 if strwidth < 88
  21.   strwidth = strwidth / 2 + strwidth + 32
  22.   strwidth = 640 if strwidth > 640
  23.   yes_no_window = Window_YesNoCommand.new(info, strwidth)
  24.   yes_no_window.visible = true
  25.   yes_no_window.active = true
  26.   loop do
  27.     Graphics.update
  28.     Input.update
  29.     yes_no_window.update
  30.     if yes_no_window.active != true
  31.       break
  32.     end
  33.   end
  34.   fhxx = yes_no_window.fhxx
  35.   yes_no_window.dispose
  36.   yes_no_window = nil
  37.   return fhxx
  38. end
  39.  
  40.  
  41. #==============================================================================
  42. # ■ Window_HorizSelectable
  43. #------------------------------------------------------------------------------
  44. #  拥有光标的移动以及滚动功能的窗口类。 (水平命令窗口专用)
  45. #==============================================================================
  46.  
  47. class Window_HorizSelectable < Window_Base
  48.   #--------------------------------------------------------------------------
  49.   # ● 定义实例变量
  50.   #--------------------------------------------------------------------------
  51.   attr_reader   :index                    # 光标位置
  52.   attr_reader   :help_window              # 帮助窗口
  53.   attr_reader   :help_windowa             # 帮助窗口a
  54.   #--------------------------------------------------------------------------
  55.   # ● 初始化对像
  56.   #     x      : 窗口的 X 坐标
  57.   #     y      : 窗口的 Y 坐标
  58.   #     width  : 窗口的宽
  59.   #     height : 窗口的高
  60.   #--------------------------------------------------------------------------
  61.   def initialize(x, y, width, height)
  62.     super(x, y, width, height)
  63.     @index = -1
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 设置光标的位置
  67.   #     index : 新的光标位置
  68.   #--------------------------------------------------------------------------
  69.   def index=(index)
  70.     @index = index
  71.     # 刷新帮助文本 (update_help 定义了继承目标)
  72.     if self.active and @help_window != nil
  73.       update_help
  74.     end
  75.     if self.active and @help_windowa != nil
  76.       update_helpa
  77.     end
  78.     # 刷新光标矩形
  79.     update_cursor_rect
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 帮助窗口的设置
  83.   #     help_window : 新的帮助窗口
  84.   #--------------------------------------------------------------------------
  85.   def help_window=(help_window)
  86.     @help_window = help_window
  87.     # 刷新帮助文本 (update_help 定义了继承目标)
  88.     if self.active and @help_window != nil
  89.       update_help
  90.     end
  91.   end
  92.  
  93.   def help_windowa=(help_windowa)
  94.     @help_windowa = help_windowa
  95.     # 刷新帮助文本 (update_help 定义了继承目标)
  96.     if self.active and @help_windowa != nil
  97.       update_helpa
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 更新光标矩形
  102.   #--------------------------------------------------------------------------
  103.   def update_cursor_rect
  104.     # 光标位置不满 0 的情况下
  105.     if @index < 0
  106.       self.cursor_rect.empty
  107.       return
  108.     end
  109.     # 计算光标的宽度
  110.     cursor_width = self.width / @item_max - 32
  111.     # 计算光标坐标
  112.     x = @index % @item_max * (cursor_width + 32)
  113.     y = @index / @item_max * 32 - self.oy
  114.     # 更新光标矩形
  115.     self.cursor_rect.set(x, y, cursor_width, 32)
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 刷新画面
  119.   #--------------------------------------------------------------------------
  120.   def update
  121.     super
  122.     # 可以移动光标的情况下
  123.     if self.active and @item_max > 0 and @index >= 0
  124.       # 方向键右被按下的情况下
  125.       if Input.repeat?(Input::RIGHT)
  126.         # 列数为 2 以上并且、光标位置在最后一个项目上的情况下
  127.         if @item_max >= 2 and @index == @item_max - 1 and
  128.           Input.trigger?(Input::RIGHT)
  129.           # 光标返回第一个项目
  130.           $game_system.se_play($data_system.cursor_se)
  131.           @index = 0
  132.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  133.         elsif @item_max >= 2 and @index < @item_max - 1
  134.           # 光标向右移动
  135.           $game_system.se_play($data_system.cursor_se)
  136.           @index += 1
  137.         end
  138.       end
  139.       # 方向键左被按下的情况下
  140.       if Input.repeat?(Input::LEFT)
  141.         # 列数为 2 以上并且、光标位置在 0 的情况下
  142.         if @item_max >= 2 and @index == 0 and
  143.           Input.trigger?(Input::LEFT)
  144.           # 光标移动到最后一个项目
  145.           $game_system.se_play($data_system.cursor_se)
  146.           @index = @item_max - 1
  147.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  148.         elsif @item_max >= 2 and @index > 0
  149.           # 光标向左移动
  150.           $game_system.se_play($data_system.cursor_se)
  151.           @index -= 1
  152.         end
  153.       end
  154.     end
  155.     # 刷新帮助文本 (update_help 定义了继承目标)
  156.     if self.active and @help_window != nil
  157.       update_help
  158.     end
  159.     # 刷新帮助文本 (update_help 定义了继承目标)
  160.     if self.active and @help_windowa != nil
  161.       update_helpa
  162.     end
  163.     # 刷新光标矩形
  164.     update_cursor_rect
  165.   end
  166. end
  167.  
  168.  
  169.  
  170. #==============================================================================
  171. # ■ Window_YesNoCommand
  172. #------------------------------------------------------------------------------
  173. #  选择是或否的命令选择行窗口。
  174. #==============================================================================
  175.  
  176. class Window_YesNoCommand < Window_HorizSelectable
  177.   #--------------------------------------------------------------------------
  178.   # ● 定义实例变量
  179.   #--------------------------------------------------------------------------
  180.   attr_reader   :fhxx
  181.   #--------------------------------------------------------------------------
  182.   # ● 初始化对像
  183.   #     info     : 窗口的提示信息
  184.   #     width    : 窗口的宽度
  185.   #     height   : 窗口的高度
  186.   #--------------------------------------------------------------------------
  187.   def initialize(info = "欢迎", width = 480, height = 96)
  188.     x = 320 - width / 2
  189.     y = 240 - height / 2
  190.     super(x, y, width, height)
  191.     self.visible = false
  192.     self.active = false
  193.     self.opacity = 200
  194.     self.contents = Bitmap.new(width - 32, height - 32)
  195.     @commands = ["是", "否"]
  196.     @item_max = @commands.size
  197.     @woff = (self.width - 32) / 4 - 19
  198.     @fhxx = false
  199.     refresh(info)
  200.     self.index = 0
  201.     self.z = 10000
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 刷新
  205.   #--------------------------------------------------------------------------
  206.   def refresh(info)
  207.     self.contents.clear
  208.     self.contents.font.size = 22
  209.     self.contents.font.color = system_color
  210.     self.contents.draw_text(0, 0, self.width - 32, 32, info, 1)
  211.     for i in 0...@item_max
  212.       draw_item(i, normal_color)
  213.     end
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 描绘项目
  217.   #     index : 项目编号
  218.   #--------------------------------------------------------------------------
  219.   def draw_item(index, color)
  220.     self.contents.font.color = color
  221.     x = self.width / @item_max * index + @woff
  222.     off = self.width / @item_max - 32
  223.     self.contents.draw_text(x, 32, 32, 32, @commands[index])
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 项目无效化
  227.   #     index : 项目编号
  228.   #--------------------------------------------------------------------------
  229.   def disable_item(index)
  230.     draw_item(index, disabled_color)
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 更新光标矩形
  234.   #--------------------------------------------------------------------------
  235.   def update_cursor_rect
  236.     # 光标位置不满 0 的情况下
  237.     if @index < 0
  238.       self.cursor_rect.empty
  239.       return
  240.     end
  241.     # 计算光标的宽度
  242.     cursor_width = self.width / @item_max - 32
  243.     # 计算光标坐标
  244.     x = @index % @item_max * (cursor_width + 32)
  245.     y = 32
  246.     # 更新光标矩形
  247.     self.cursor_rect.set(x, y, cursor_width, 32)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 刷新画面
  251.   #--------------------------------------------------------------------------
  252.   def update
  253.     super
  254.     # 按下取消键的情况下
  255.     if Input.trigger?(Input::B)
  256.       # 演奏确定 SE
  257.       $game_system.se_play($data_system.decision_se)
  258.       @fhxx = false
  259.       self.visible = false
  260.       self.active = false
  261.       return
  262.     end
  263.     # 按下确定键的情况下
  264.     if Input.trigger?(Input::C)
  265.       # 演奏确定 SE
  266.       $game_system.se_play($data_system.decision_se)
  267.       # 命令窗口的光标位置分支
  268.       case self.index
  269.       when 0  # 是
  270.         @fhxx = true
  271.         self.visible = false
  272.         self.active = false
  273.       when 1  # 否
  274.         @fhxx = false
  275.         self.visible = false
  276.         self.active = false
  277.       end
  278.       return
  279.     end
  280.   end
  281. end

编辑的话:

嗯,可以算新手脚本的范畴吧。
代码虽有些许的赘余,但是功能非常赞呢。
内容全部为自定义的,基本上没有冲突的可能。

评分

参与人数 1星屑 +66 收起 理由
hys111111 + 66 塞糖

查看全部评分

Vanyogin
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
帖子
1698

开拓者

发表于 2016-8-30 08:50:59 | 显示全部楼层
自己抄 Interpreter
1. command_102
2. command_201
3. command_118 _119
4. command_209 -> RPG::MoveRoute(F1 RGSS参考)

  -fk: -azogi:
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
 楼主| 发表于 2016-9-1 21:50:53 | 显示全部楼层
kuerlulu 发表于 2016-8-30 08:50
自己抄 Interpreter
1. command_102
2. command_201

能不能具体点
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
 楼主| 发表于 2016-9-1 23:43:37 | 显示全部楼层
2357691704 发表于 2016-8-29 11:06
最麻烦的就是显示选择项,建议用这个脚本。可以随时调用的是或否选择窗口

教程作者:洛克人SZ

感谢你的回答,不过对我来说还是有点难懂,
而且我需要的不仅仅是两种选项
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 20:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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