查看: 91|回复: 0

[转载发布] 突破四选项限制,N选项再无限制!

[复制链接]
  • TA的每日心情
    开心
    7 天前
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月四日(秋) | 显示全部楼层 |阅读模式

    原本默认对话框的选项被限制在四个,此脚本就是用来突破此限制,从此N选项任你遨游……

    截图:


    工程范例(建议下载):

    谷歌盘
    百度盘

    @Index 抱歉,为了避免脚本错误,先 @ 了你先……==

    脚本(完整):
    1. #==============================================================================# ■ 多选项脚本#------------------------------------------------------------------------------#    v 1.0 by enghao_lim#    理论性无限突破四个选项的脚本#------------------------------------------------------------------------------## 使用方法:# #  1. 在事件里使用【脚本】:多选项(选项数组,取消时执行的选项)#     #         选项数组例子:@c = ["选项一","选项二"..."选项100"]#         所有选项必须是文字,即被 "" 符包括。#         #         取消时执行的选项:代表 ESC (也就是B键) 按下时执行的选项#         不填写 或 为0 时,代表选项不可被取消。#         此值不可大过选项的数量,否者会出错。#         #  2. 使用条件分歧:选项场合(选项编号)来执行选中选项后执行的事件。#     具体请看范例。# #  3. for 脚本党:#     获取 被选中的选项 的 index :$game_temp.choice_result#         #  4. 范例里已经有各种 多选项 的利用方法,自个儿都觉得多选项也挺好用的。#  #  5. 如有神马 bug ,请通知我,谢谢,感谢阅读。##==============================================================================#==============================================================================# ■ Game_Temp#------------------------------------------------------------------------------#  临时资料记录器。#==============================================================================class Game_Temp  #--------------------------------------------------------------------------  # ● 读写器  #--------------------------------------------------------------------------  attr_accessor :choice_result  attr_accessor :choice_last  #--------------------------------------------------------------------------  # ● 初始化  #--------------------------------------------------------------------------  alias initialize0 initialize  def initialize    initialize0    @choice_result = -1    @choice_last = -1  endend#==============================================================================# ■ Interpreter#------------------------------------------------------------------------------#  事件处理器。#==============================================================================class Interpreter  #--------------------------------------------------------------------------  # ● 多选项  #--------------------------------------------------------------------------  def 多选项(选项, 取消 = 0)    取消 = 取消 == "取消" ? 选项.size + 1 : 取消    MultiChoice(选项,取消)  end  #--------------------------------------------------------------------------  # ● 获取选择的选项  #--------------------------------------------------------------------------  def 选项场合(n)    if n == "取消"      return ($game_temp.choice_last + 1) == $game_temp.choice_result    end    return $game_temp.choice_result == (n - 1)  end  #--------------------------------------------------------------------------  # ● 多选项执行  #--------------------------------------------------------------------------  def MultiChoice(choice,cancel = 0)    # 设置信息结束后待机和返回调用标志    @message_waiting = true    $game_temp.message_proc = Proc.new { @message_waiting = false }    # 设置选项设置    $game_temp.choice_max = choice.size    $game_temp.choice_last = choice.size - 1    $game_temp.choice_cancel_type = cancel    $game_temp.choice_start = 0    $game_temp.message_text = ""    $game_temp.choice_proc = Proc.new { |n| $game_temp.choice_result = n }    # 设置选择选项    for c in choice      $game_temp.message_text += c + "\n"    end  end  end#==============================================================================# ■ Window_Message#------------------------------------------------------------------------------#  对话框。#==============================================================================class Window_Message  #--------------------------------------------------------------------------  # ● 重置窗口  #--------------------------------------------------------------------------  alias reset_window_0 reset_window  def reset_window    # 默认重置法    reset_window_0    # 还原 ox 和 oy    self.ox = self.oy = 0    # 重新生成 bitmap    if $game_temp.choice_max > 4      self.contents.dispose      self.contents = Bitmap.new(self.width-32,$game_temp.choice_max*32)    else      self.contents.dispose      self.contents = Bitmap.new(self.width-32,self.height-32)    end  end  #--------------------------------------------------------------------------  # ● 刷新光标矩形  #--------------------------------------------------------------------------  def update_cursor_rect    if [url=home.php?mod=space&uid=370741]@Index[/url] >= 0      if $game_temp.choice_start == 0        super        rect = self.cursor_rect        self.cursor_rect.set(8,rect.y,@cursor_width,rect.height)      else        n = $game_temp.choice_start + @index        self.cursor_rect.set(8, n * 32, @cursor_width, 32)      end    else      self.cursor_rect.empty    end  endend复制代码
    复制代码
                 本帖来自P1论坛作者enghao_lim,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=338647  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-17 19:35 , Processed in 0.047755 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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