Project1

标题: 想问下变量数值输入的上限要如何改呢 [打印本页]

作者: 南下雪貂    时间: 2022-8-11 03:02
标题: 想问下变量数值输入的上限要如何改呢
就是一个道具我希望使用它的时候直接可以输入密码,可是上限是8,我设置的密码是十位,鼓捣了半天也不会,希望有大佬帮忙!
作者: alexncf125    时间: 2022-8-11 09:48
本帖最后由 alexncf125 于 2022-8-11 09:51 编辑

使用方法

在输入数字事件命令之后,创建注释并写入

   <num input digits: x>
  
其中 `x` 是您想要的位数

例子:
<num input digits: 10>

  1. =begin
  2. #===============================================================================
  3. Title: More Input Digits
  4. Author: Hime
  5. Date: Jan 29, 2015
  6. URL: http://himeworks.com/2015/01/more-input-digits/
  7. --------------------------------------------------------------------------------
  8. ** Change log
  9. Jan 29, 2015
  10.    - Initial release
  11. --------------------------------------------------------------------------------   
  12. ** Terms of Use
  13. * Free to use in non-commercial projects
  14. * Contact me for commercial use
  15. * No real support. The script is provided as-is
  16. * Will do bug fixes, but no compatibility patches
  17. * Features may be requested but no guarantees, especially if it is non-trivial
  18. * Credits to Hime Works in your project
  19. * Preserve this header
  20. --------------------------------------------------------------------------------
  21. ** Description

  22. This script allows you to set more digits for your number input event command.
  23. By default, the event editor only supports up to 8 digits.

  24. --------------------------------------------------------------------------------
  25. ** Installation

  26. In the script editor, place this script below Materials and above Main

  27. --------------------------------------------------------------------------------
  28. ** Usage

  29. Right after an input number event command, create a comment and write

  30.    <num input digits: x>
  31.   
  32. Where `x` is the number of digits you would like
  33. #===============================================================================
  34. =end
  35. $imported = {} if $imported.nil?
  36. $imported[:TH_MoreInputDigits] = true
  37. #===============================================================================
  38. # ** Configuration
  39. #===============================================================================
  40. module TH
  41.   module More_Input_Digits
  42.     Regex = /<num[-_ ]input[-_ ]digits:\s*(\d+)\s*>/i
  43.   end
  44. end
  45. #===============================================================================
  46. # ** Rest of script
  47. #===============================================================================
  48. module RPG
  49.   class Event::Page
  50.     alias :th_more_input_digits_list :list
  51.     def list
  52.       parse_more_input_digits unless @more_input_digits_parsed
  53.       th_more_input_digits_list
  54.     end
  55.    
  56.     def parse_more_input_digits
  57.       @more_input_digits_parsed = true
  58.       i = 0
  59.       while i < @list.size
  60.         cmd = @list[i]
  61.         
  62.         # Number Input command
  63.         if cmd.code == 103         
  64.                     
  65.           # Collect all comments under it
  66.           next_cmd = @list[i+1]
  67.           comment = ""
  68.           while next_cmd.code == 108 || next_cmd.code == 408
  69.             i += 1
  70.             comment << "\n" << next_cmd.parameters[0]
  71.             next_cmd = @list[i+1]            
  72.           end
  73.          
  74.           # Check if there's something special
  75.           if comment =~ TH::More_Input_Digits::Regex
  76.             num = $1.to_i         
  77.             cmd.parameters[1] = num            
  78.           end
  79.         end
  80.         i += 1
  81.       end      
  82.     end
  83.   end
  84. end
复制代码

作者: 南下雪貂    时间: 2022-8-11 19:37
alexncf125 发表于 2022-8-11 09:48
使用方法

在输入数字事件命令之后,创建注释并写入

谢谢您!但是这个脚本貌似公共事件不行,因为我是在公共事件里写的再插入到道具使用里,是还要加点别的嘛
作者: alexncf125    时间: 2022-8-11 20:01
55行的class Event::Page改成class CommonEvent吧?
作者: 喵呜喵5    时间: 2022-8-12 00:47
插入这个脚本
https://script.miaowm5.com/post/27

然后在数值输入处理指令前插入一个执行脚本指令执行以下代码
  1. m520150501_change({2=>10})
复制代码







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